Skip to main content

build_schema

Compiles decorated query, mutation, and subscription roots into a Schema. It also accepts additional reachable types, a type registry, and SchemaConfig.
Schema(query=...) is a convenient constructor that performs the same compilation when passed decorated Python classes.

execute

The query may be a string, Source, or parsed DocumentNode. Execution parses when needed, selects an operation, validates, coerces variables, resolves fields, completes values, and returns ExecutionResult. Pass mask_errors=True (with an optional mask_message) to replace unexpected resolver errors with a generic message in the response; explicit GraphQLErrors pass through and the original exception stays on GraphQLError.original_error.

subscribe

Runs a subscription and returns an async iterator yielding one ExecutionResult per source event, or a single ExecutionResult (with executed=False) when the document is invalid or is not a subscription. See Subscriptions.

execute_incremental

Executes an operation as an incremental-delivery stream of JSON payloads for @defer / @stream. See Incremental delivery.

Schema extensions

Schema(query=..., extensions=[...]) (and build_schema(..., extensions=[...])) attach schema extensions that observe the operation lifecycle and wrap field resolution.

validate and parse

Use parse(source) when an application benefits from retaining the GraphQL AST. Use validate(schema, document) to inspect validation errors without executing.