Anything documented here is part of the public API that Flask-Magql provides, unless otherwise indicated. Anything not documented here is considered internal or private and may change at any time.
- class flask_magql.MagqlExtension(schema, *, decorators=None)#
Serve a Magql
Schemato provide a GraphQL API.
The following views are registered. The blueprint’s name is
magqlby default, which is the prefix for each endpoint name.
The GraphQL API view. Supports the multipart spec and batched operations.
The GraphQL schema document served as a text file. Useful if a tool does not use the introspection query to discover the API.
The GraphiQL UI for exploring the schema and building queries.
schema (magql.Schema) – The schema to serve.
decorators (list[t.Callable[[t.Callable[..., ResponseReturnValue]], t.Callable[..., ResponseReturnValue]]] | None) – View decorators applied to each view function. This can be used to apply authentication, CORS, etc.
The Magql schema to serve.
- blueprint: Blueprint#
The Flask blueprint that will hold these GraphQL routes and be registered on the app. The blueprint can be modified, for example to add a URL prefix:
me.blueprint.url_prefix = "/api".
View decorators to apply to each view function. This can be used to apply authentication, CORS, etc.
Register the GraphQL API on the given Flask app.
app (Flask) – The app to register on.
- Return type:
Decorate a function that should be called by
execute()to provide a value for
- execute(source, variables=None, operation=None)#
Execute a GraphQL operation (query or mutation). The SQLAlchemy session is passed as the context.
source (str) – The operation (query or mutation) written in GraphQL language to execute on the schema.
operation (str | None) – The name of the operation if the source defines multiple.
- Return type: