WaspW
Wasp17mo ago
dtschannen

Query an entity throws "unexpected token: entities" Error

Hi everyone. I try to query an entity as follow:

Wasp File:

query findQRCodeById {
fn: import { findQRCodeById } from "@src/qr-generator/findQRCodeById"
entities: [QRCode]
}

And my findQRCodeById Typescript file:

import { QRCode } from 'wasp/entities'
import { type FindQRCodeById } from 'wasp/server/operations'

type GetQRCodeByIdArgs = {
id: string
}

export const getQRCodeById: FindQRCodeById<GetQRCodeByIdArgs, QRCode | null> = async (args, context) => {
return context.entities.QRCode.findUnique({
where: { id: args.id },
})
}

It gives me this Error:


4 errors found:
  • /home/dtschannen/projects/qrftw/app/main.wasp @ 204:3-10Parse error: Unexpected token: entities Expected one of the following tokens instead: '}',',' 203 | fn: import { findQRCodeById } from "@src/qr-generator/findQRCodeById" 204 | entities: [QRCode] 205 | }
  • /home/dtschannen/projects/qrftw/app/main.wasp @ 204:11Parse error: Unexpected token: : Expected one of the following tokens instead: <identifier> 203 | fn: import { findQRCodeById } from "@src/qr-generator/findQRCodeById" 204 | entities: [QRCode] 205 | }
  • /home/dtschannen/projects/qrftw/app/main.wasp @ 204:13Parse error: Unexpected token: [ Expected one of the following tokens instead: <identifier>,<eof> 203 | fn: import { findQRCodeById } from "@src/qr-generator/findQRCodeById" 204 | entities: [QRCode] 205 | }
  • /home/dtschannen/projects/qrftw/app/main.wasp @ 204:14-19Parse error: Unexpected token: QRCode Expected one of the following tokens instead: <eof> 203 | fn: import { findQRCodeById } from "@src/qr-generator/findQRCodeById" 204 | entities: [QRCode] 205 | }
Was this page helpful?