@@ -38,7 +38,7 @@ def __init__(self, name, pets, friends):
3838 'name' : GraphQLField (GraphQLString ),
3939 'barks' : GraphQLField (GraphQLBoolean ),
4040 },
41- is_type_of = lambda value , info : isinstance (value , Dog )
41+ is_type_of = lambda value , context , info : isinstance (value , Dog )
4242)
4343
4444CatType = GraphQLObjectType (
@@ -48,11 +48,11 @@ def __init__(self, name, pets, friends):
4848 'name' : GraphQLField (GraphQLString ),
4949 'meows' : GraphQLField (GraphQLBoolean ),
5050 },
51- is_type_of = lambda value , info : isinstance (value , Cat )
51+ is_type_of = lambda value , context , info : isinstance (value , Cat )
5252)
5353
5454
55- def resolve_pet_type (value , info ):
55+ def resolve_pet_type (value , context , info ):
5656 if isinstance (value , Dog ):
5757 return DogType
5858 if isinstance (value , Cat ):
@@ -70,7 +70,7 @@ def resolve_pet_type(value, info):
7070 'pets' : GraphQLField (GraphQLList (PetType )),
7171 'friends' : GraphQLField (GraphQLList (NamedType )),
7272 },
73- is_type_of = lambda value , info : isinstance (value , Person )
73+ is_type_of = lambda value , context , info : isinstance (value , Person )
7474)
7575
7676schema = GraphQLSchema (query = PersonType , types = [PetType ])
@@ -107,6 +107,7 @@ def test_can_introspect_on_union_and_intersection_types():
107107 }''' )
108108
109109 result = execute (schema , ast )
110+ assert not result .errors
110111 assert result .data == {
111112 'Named' : {
112113 'enumValues' : None ,
@@ -311,12 +312,15 @@ def test_only_include_fields_from_matching_fragment_condition():
311312
312313
313314def test_gets_execution_info_in_resolver ():
314- encountered_schema = [None ]
315- encountered_root_value = [None ]
316-
317- def resolve_type (obj , info ):
318- encountered_schema [0 ] = info .schema
319- encountered_root_value [0 ] = info .root_value
315+ class encountered :
316+ schema = None
317+ root_value = None
318+ context = None
319+
320+ def resolve_type (obj , context , info ):
321+ encountered .schema = info .schema
322+ encountered .root_value = info .root_value
323+ encountered .context = context
320324 return PersonType2
321325
322326 NamedType2 = GraphQLInterfaceType (
@@ -338,12 +342,15 @@ def resolve_type(obj, info):
338342
339343 schema2 = GraphQLSchema (query = PersonType2 )
340344 john2 = Person ('John' , [], [liz ])
345+ context = {'hey' }
341346 ast = parse ('''{ name, friends { name } }''' )
342347
343- result = execute (schema2 , ast , john2 )
348+ result = execute (schema2 , ast , john2 , context_value = context )
349+ assert not result .errors
344350 assert result .data == {
345351 'name' : 'John' , 'friends' : [{'name' : 'Liz' }]
346352 }
347353
348- assert encountered_schema [0 ] == schema2
349- assert encountered_root_value [0 ] == john2
354+ assert encountered .schema == schema2
355+ assert encountered .root_value == john2
356+ assert encountered .context == context
0 commit comments