Skip to content

Commit 3ce5dba

Browse files
committed
get_fragment() will raise a KeyError if the fragment is not found, not return a falsey value.
1 parent 7fefee5 commit 3ce5dba

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

graphql/core/validation/__init__.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,13 @@ def enter(self, node, key, parent, path, ancestors):
6868
result = False
6969

7070
if result is None and getattr(self.instance, 'visit_spread_fragments', False) and isinstance(node, FragmentSpread):
71-
fragment = self.instance.context.get_fragment(node.name.value)
72-
if fragment:
73-
visit(fragment, self)
71+
try:
72+
fragment = self.instance.context.get_fragment(node.name.value)
73+
except KeyError:
74+
pass
75+
else:
76+
if fragment:
77+
visit(fragment, self)
7478

7579
if result is False:
7680
self.type_info.leave(node)

0 commit comments

Comments
 (0)