@@ -36,16 +36,58 @@ class Query(graphene.ObjectType):
36
36
special_node = relay .NodeField (SpecialNode )
37
37
all_my_nodes = relay .ConnectionField (
38
38
MyNode , connection_type = MyConnection , customArg = graphene .String ())
39
+
40
+ context_nodes = relay .ConnectionField (
41
+ MyNode , connection_type = MyConnection , customArg = graphene .String ())
39
42
40
43
def resolve_all_my_nodes (self , args , info ):
41
44
custom_arg = args .get ('customArg' )
42
45
assert custom_arg == "1"
43
46
return [MyNode (name = 'my' )]
47
+
48
+ @with_context
49
+ def resolve_context_nodes (self , args , context , info ):
50
+ custom_arg = args .get ('customArg' )
51
+ assert custom_arg == "1"
52
+ return [MyNode (name = 'my' )]
44
53
45
54
schema .query = Query
46
55
47
56
48
57
def test_nodefield_query ():
58
+ query = '''
59
+ query RebelsShipsQuery {
60
+ contextNodes (customArg:"1") {
61
+ edges {
62
+ node {
63
+ name
64
+ }
65
+ },
66
+ myCustomField
67
+ pageInfo {
68
+ hasNextPage
69
+ }
70
+ }
71
+ }
72
+ '''
73
+ expected = {
74
+ 'allMyNodes' : {
75
+ 'edges' : [{
76
+ 'node' : {
77
+ 'name' : 'my'
78
+ }
79
+ }],
80
+ 'myCustomField' : 'Custom' ,
81
+ 'pageInfo' : {
82
+ 'hasNextPage' : False ,
83
+ }
84
+ }
85
+ }
86
+ result = schema .execute (query )
87
+ assert not result .errors
88
+ assert result .data == expected
89
+
90
+ def test_connectionfield_context_query ():
49
91
query = '''
50
92
query RebelsShipsQuery {
51
93
myNode(id:"TXlOb2RlOjE=") {
0 commit comments