Skip to main content

Queries

Queries are the read side of your GraphQL API. Each field in your Query type has a resolver — an async function that fetches and returns data.

Writing Resolvers

A resolver receives a PrismGraphQLResolveInfo with everything it needs:
Resolver Context
Resolvers are @Sendable and async — you can safely call databases, APIs, and other async services from within them.

Simple Query

Hello World Query

Queries with Arguments

Pass arguments to filter, paginate, or customize results:
Query with Arguments

Multiple Arguments

Filtering and Pagination
The client queries:

Nested Object Resolution

When a field returns an object type, the executor resolves its sub-fields using the returned value as parentValue:
Nested Resolution
Now a client can query deeply nested data:

Introspection

Prism’s executor handles __typename, __schema, and __type introspection queries automatically. Clients (like GraphiQL) use these to discover your API:
Introspection is always enabled. In production, you might want to disable it — a future version of Prism will add a config flag for this.

Error Handling

Resolvers can throw errors. The executor catches them per-field and includes them in the response while still returning data for other fields:
Partial Errors
Response:

What’s Next

Mutations

Learn how to modify data through GraphQL

Playground

Set up the interactive GraphQL playground