Function: query()
query(
fn,config?):Query
Creates a Query definition.
Queries are server-side read-only operations. They can be invoked from
the client (with caching via useQuery) and the server. List the
entities the query reads from so Wasp can inject the matching Prisma
delegates into context.entities and invalidate the client cache when
related actions modify them.
See Queries.
Parametersโ
fnโ
Reference<AnyFunction>
Reference to the Query's NodeJS implementation.
See the docs for details on the implementation and its context.
Use reference imports when passing values from your app into the Wasp spec. If a direct import is not practical, use ref as a fallback.
config?โ
auth?โ
boolean
Whether this Query requires auth. If your app has auth enabled, this
defaults to true.
Only available if your app has auth enabled.
entities?โ
string[]
A list of entities you wish to use inside your Query.
See Using Entities in Queries.
Returnsโ
Exampleโ
import { app, query } from "@wasp.sh/spec"
import { getTasks } from './src/queries' with { type: 'ref' }
export default app({
// ...
spec: [
query(getTasks, { entities: ["Foo"] }),
],
})