API Reference
Note
Unless specified otherwise, components documented here can be imported from tartiflette_asgi directly, e.g. from tartiflette_asgi import TartifletteApp.
TartifletteApp
Parameters
Note: all parameters are keyword-only.
engine(Engine): a Tartiflette engine. Required ifsdlis not given.sdl(str): a GraphQL schema defined using the GraphQL Schema Definition Language. Required ifengineis not given.path(str, optional): the path which clients should make GraphQL queries to. Defaults to"/".graphiql(GraphiQLorbool, optional): configuration for the GraphiQL client. Defaults toTrue, which is equivalent toGraphiQL(). UseFalseto not register the GraphiQL client.subscriptions(Subscriptionsorbool, optional): subscriptions configuration. Defaults toTrue, which is equivalent toSubscriptions(path="/subscriptions"). Leave empty or passNoneto not register the subscription WebSocket endpoint.context(dict, optional): a copy of this dictionary is passed to resolvers when executing a query. Defaults to{}. Note: the StarletteRequestobject is always present asreq.schema_name(str, optional): name of the GraphQL schema from the Schema Registry which should be used — mostly for advanced usage. Defaults to"default".
Methods
__call__(scope, receive, send): ASGI3 implementation.
Error responses
| Status code | Description |
|---|---|
| 400 Bad Request | The GraphQL query could not be found in the request data. |
| 404 Not Found | The request does not match the GraphQL or GraphiQL endpoint paths. |
| 405 Method Not Allowed | The HTTP method is not one of GET, HEAD or POST. |
| 415 Unsupported Media Type | The POST request made to the GraphQL endpoint uses a Content-Type different from application/json and application/graphql. |
GraphiQL
Configuration helper for the GraphiQL client.
Parameters
Note: all parameters are keyword-only.
path(str, optional): the path of the GraphiQL endpoint, relative to the root path whichTartifletteAppis served at. If not given, defaults to thepathgiven toTartifletteApp.default_headers(dict, optional): extra HTTP headers to send when calling the GraphQL endpoint.default_query(str, optional): the default query to display when accessing the GraphiQL interface.default_variables(dict, optional): default variables to display when accessing the GraphiQL interface.template(str, optional): an HTML template to use instead of the default one. In the template,default_headers,default_queryanddefault_variables, as well as the GraphQLendpoint, are available as strings (JSON-encoded if needed) using template string substitutions, e.g.:
const endpoint = `${endpoint}`; // This is where the API call should be made.
const defaultHeaders = JSON.parse(`${default_headers}`);
Subscriptions
Configuration helper for WebSocket subscriptions.
Parameters
Note: all parameters are keyword-only.
path(str): the path of the subscriptions WebSocket endpoint, relative to the root path whichTartifletteAppis served at. If not given, defaults to/subscriptions.