Skip to content

Commit 753b927

Browse files
committed
Don't check types & directives with custom reducer
The custom reducer might convert custom types and directives, so we should not check them on input. This should be done in the Schema subclass in this case.
1 parent 08b2957 commit 753b927

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

src/graphql/type/definition.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ class GraphQLField:
417417
"""Definition of a GraphQL field"""
418418

419419
type: "GraphQLOutputType"
420-
args: Dict[str, "GraphQLArgument"]
420+
args: GraphQLArgumentMap
421421
resolve: Optional["GraphQLFieldResolver"]
422422
subscribe: Optional["GraphQLFieldResolver"]
423423
description: Optional[str]

src/graphql/type/schema.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,16 +113,21 @@ def __init__(
113113
if types is None:
114114
types = []
115115
else:
116-
if not isinstance(types, AbstractSequence) or not all(
117-
is_named_type(type_) for type_ in types
116+
if not isinstance(types, AbstractSequence) or (
117+
# if reducer has been overridden, don't check types
118+
self.type_map_reducer.__self__.__class__ is GraphQLSchema
119+
and not all(is_named_type(type_) for type_ in types)
118120
):
119121
raise TypeError(
120122
"Schema types must be specified as a sequence"
121123
" of GraphQLNamedType instances."
122124
)
123125
if directives is not None:
124-
if not isinstance(directives, AbstractSequence) or not all(
125-
is_directive(directive) for directive in directives
126+
# noinspection PyUnresolvedReferences
127+
if not isinstance(directives, AbstractSequence) or (
128+
# if reducer has been overridden, don't check directive types
129+
self.type_map_directive_reducer.__self__.__class__ is GraphQLSchema
130+
and not all(is_directive(directive) for directive in directives)
126131
):
127132
raise TypeError(
128133
"Schema directives must be specified as a sequence"

0 commit comments

Comments
 (0)