Execution
Aside from building the Engine
, the execute
method is responsible for executing the GraphQL query coming from the client.
Its parameters are:
query
: The GraphQL Request/Query as UTF8-encoded string (sent by the client)operation_name
: Operation name to executecontext
: A dict containing anything you need to be pass through the execution processvariables
: The variables used in the GraphQL requestinitial_value
: An initial value given to the resolver of the root type
from tartiflette import create_engine
engine = await create_engine(
"myDsl.graphql"
)
result = engine.execute(
query="query MyVideo($id: String) { video(id: $id) { id title } }",
operation_name="hello_world",
context={
"mysql_client": MySQLClient(),
"auth_info": AuthInfo()
},
variables: {
"id": "1234"
},
initial_value: {}
)
# `result` will contain something like
# {
# "data": {
# "video": {
# "id": "1234",
# "title": "My fabulous title"
# }
# }
# }