graphql.execution package is responsible for the execution phase of
fulfilling a GraphQL request.
execute(schema: graphql.type.schema.GraphQLSchema, document: graphql.language.ast.DocumentNode, root_value: Any = None, context_value: Any = None, variable_values: Dict[str, Any] = None, operation_name: str = None, field_resolver: Callable[[...], Any] = None, type_resolver: Callable[[Any, graphql.type.definition.GraphQLResolveInfo, GraphQLAbstractType], Union[Awaitable[Union[GraphQLObjectType, str, None]], GraphQLObjectType, str, None]] = None, middleware: Union[Tuple, List[T], graphql.execution.middleware.MiddlewareManager, None] = None, execution_context_class: Type[ExecutionContext] = None) → Union[Awaitable[graphql.execution.execute.ExecutionResult], graphql.execution.execute.ExecutionResult]¶
Execute a GraphQL operation.
Implements the “Evaluating requests” section of the GraphQL specification.
Returns an ExecutionResult (if all encountered resolvers are synchronous), or a coroutine object eventually yielding an ExecutionResult.
If the arguments to this function do not result in a legal execution context, a GraphQLError will be thrown immediately explaining the invalid input.
default_field_resolver(source, info, **args)¶
Default field resolver.
If a resolve function is not given, then a default resolve behavior is used which takes the property of the source object of the same name as the field and returns it as the result, or if it’s a function, returns the result of calling that function while passing along args and context.
For dictionaries, the field names are used as keys, for all other objects they are used as attribute names.
ExecutionContext(schema: graphql.type.schema.GraphQLSchema, fragments: Dict[str, graphql.language.ast.FragmentDefinitionNode], root_value: Any, context_value: Any, operation: graphql.language.ast.OperationDefinitionNode, variable_values: Dict[str, Any], field_resolver: Callable[[...], Any], type_resolver: Callable[[Any, graphql.type.definition.GraphQLResolveInfo, GraphQLAbstractType], Union[Awaitable[Union[GraphQLObjectType, str, None]], GraphQLObjectType, str, None]], errors: List[graphql.error.graphql_error.GraphQLError], middleware_manager: Optional[graphql.execution.middleware.MiddlewareManager])¶
Data that must be available at all points during query execution.
Namely, schema of the type system that is currently executing, and the fragments defined in the query document.
The result of GraphQL execution.
- data is the result of a successful execution of the query.
- errors is included when any errors occurred as a non-empty list.
get_directive_values(directive_def: graphql.type.directives.GraphQLDirective, node: Union[graphql.language.ast.ExecutableDefinitionNode, graphql.language.ast.SelectionNode, graphql.language.ast.SchemaDefinitionNode, graphql.language.ast.TypeDefinitionNode, graphql.language.ast.TypeExtensionNode], variable_values: Dict[str, Any] = None) → Optional[Dict[str, Any]]¶
Get coerced argument values based on provided nodes.
Prepares a dict of argument values given a directive definition and an AST node which may contain directives. Optionally also accepts a dict of variable values.
If the directive does not exist on the node, returns None.