File tree 2 files changed +42
-3
lines changed
2 files changed +42
-3
lines changed Original file line number Diff line number Diff line change @@ -193,7 +193,7 @@ def enter_field(
193
193
# Key not found in result.
194
194
# Should never happen in theory with a correct GraphQL backend
195
195
# Silently ignoring this field
196
- log .debug (f"Key { name } not found in result --> REMOVE" )
196
+ log .debug (f" Key { name } not found in result --> REMOVE" )
197
197
return REMOVE
198
198
199
199
log .debug (f" result_value={ result_value } " )
@@ -232,8 +232,11 @@ def enter_field(
232
232
)
233
233
234
234
# Get parent SelectionSet node
235
- new_node = ancestors [- 1 ]
236
- assert isinstance (new_node , SelectionSetNode )
235
+ selection_set_node = ancestors [- 1 ]
236
+ assert isinstance (selection_set_node , SelectionSetNode )
237
+
238
+ # Keep only the current node in a new selection set node
239
+ new_node = SelectionSetNode (selections = [node ])
237
240
238
241
for item in result_value :
239
242
Original file line number Diff line number Diff line change @@ -37,6 +37,42 @@ def test_hero_name_and_friends_query():
37
37
assert result == parsed_result
38
38
39
39
40
+ def test_hero_name_and_friends_query_with_fragment ():
41
+ """Testing for issue #445"""
42
+
43
+ query = gql (
44
+ """
45
+ query HeroNameAndFriendsQuery {
46
+ hero {
47
+ ...HeroSummary
48
+ friends {
49
+ name
50
+ }
51
+ }
52
+ }
53
+ fragment HeroSummary on Character {
54
+ id
55
+ name
56
+ }
57
+ """
58
+ )
59
+ result = {
60
+ "hero" : {
61
+ "id" : "2001" ,
62
+ "friends" : [
63
+ {"name" : "Luke Skywalker" },
64
+ {"name" : "Han Solo" },
65
+ {"name" : "Leia Organa" },
66
+ ],
67
+ "name" : "R2-D2" ,
68
+ }
69
+ }
70
+
71
+ parsed_result = parse_result (StarWarsSchema , query , result )
72
+
73
+ assert result == parsed_result
74
+
75
+
40
76
def test_key_not_found_in_result ():
41
77
42
78
query = gql (
You can’t perform that action at this time.
0 commit comments