File tree Expand file tree Collapse file tree 2 files changed +42
-3
lines changed Expand file tree Collapse file tree 2 files changed +42
-3
lines changed Original file line number Diff line number Diff line change @@ -193,7 +193,7 @@ def enter_field(
193193 # Key not found in result.
194194 # Should never happen in theory with a correct GraphQL backend
195195 # 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" )
197197 return REMOVE
198198
199199 log .debug (f" result_value={ result_value } " )
@@ -232,8 +232,11 @@ def enter_field(
232232 )
233233
234234 # 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 ])
237240
238241 for item in result_value :
239242
Original file line number Diff line number Diff line change @@ -37,6 +37,42 @@ def test_hero_name_and_friends_query():
3737 assert result == parsed_result
3838
3939
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+
4076def test_key_not_found_in_result ():
4177
4278 query = gql (
You can’t perform that action at this time.
0 commit comments