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 ifsdl
is not given.sdl
(str
): a GraphQL schema defined using the GraphQL Schema Definition Language. Required ifengine
is not given.path
(str
, optional): the path which clients should make GraphQL queries to. Defaults to"/"
.graphiql
(GraphiQL
orbool
, optional): configuration for the GraphiQL client. Defaults toTrue
, which is equivalent toGraphiQL()
. UseFalse
to not register the GraphiQL client.subscriptions
(Subscriptions
orbool
, optional): subscriptions configuration. Defaults toTrue
, which is equivalent toSubscriptions(path="/subscriptions")
. Leave empty or passNone
to 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 StarletteRequest
object 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 whichTartifletteApp
is served at. If not given, defaults to thepath
given 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_query
anddefault_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 whichTartifletteApp
is served at. If not given, defaults to/subscriptions
.