def provides_info_about_current_execution_state(): resolved_infos = [] def resolve(_obj, info): resolved_infos.append(info) test_type = GraphQLObjectType( "Test", {"test": GraphQLField(GraphQLString, resolve=resolve)}) schema = GraphQLSchema(test_type) document = parse("query ($var: String) { result: test }") root_value = {"root": "val"} variable_values = {"var": "abc"} execute(schema, document, root_value, variable_values=variable_values) assert len(resolved_infos) == 1 operation = cast(OperationDefinitionNode, document.definitions[0]) assert operation and operation.kind == "operation_definition" field = cast(FieldNode, operation.selection_set.selections[0]) assert resolved_infos[0] == GraphQLResolveInfo( field_name="test", field_nodes=[field], return_type=GraphQLString, parent_type=cast(GraphQLObjectType, schema.query_type), path=ResponsePath(None, "result"), schema=schema, fragments={}, root_value=root_value, operation=operation, variable_values=variable_values, context=None, )
def provides_info_about_current_execution_state(): ast = parse('query ($var: String) { result: test }') infos = [] def resolve(_obj, info): infos.append(info) schema = GraphQLSchema( GraphQLObjectType( 'Test', {'test': GraphQLField(GraphQLString, resolve=resolve)})) root_value = {'root': 'val'} execute(schema, ast, root_value, variable_values={'var': 'abc'}) assert len(infos) == 1 operation = cast(OperationDefinitionNode, ast.definitions[0]) field = cast(FieldNode, operation.selection_set.selections[0]) assert infos[0] == GraphQLResolveInfo(field_name='test', field_nodes=[field], return_type=GraphQLString, parent_type=schema.query_type, path=ResponsePath( None, 'result'), schema=schema, fragments={}, root_value=root_value, operation=operation, variable_values={'var': 'abc'}, context=None)