Skip to content

Commit 6654cc9

Browse files
committed
Move validation into more logical place
1 parent c4cb892 commit 6654cc9

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

graphql/type/definition.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,9 @@ def define_field_map(type, field_map):
195195

196196
for field_name, field in field_map.items():
197197
assert_valid_name(field_name)
198+
assert isinstance(field, GraphQLField), (
199+
'{}.{} must be an instance of GraphQLField.'.format(type, field_name)
200+
)
198201
field_args = getattr(field, 'args', None)
199202

200203
if field_args:

graphql/type/typemap.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from functools import reduce
33

44
from ..utils.type_comparators import is_equal_type, is_type_sub_type_of
5-
from .definition import (GraphQLArgument, GraphQLField,
5+
from .definition import (GraphQLArgument,
66
GraphQLInputObjectField, GraphQLInputObjectType,
77
GraphQLInterfaceType, GraphQLList, GraphQLNonNull,
88
GraphQLObjectType, GraphQLUnionType, is_input_type,
@@ -87,9 +87,6 @@ def reducer(cls, map, type):
8787
'{}.{} field type must be Input Type but got: {}.'.format(type, field_name, field.type)
8888
)
8989
else:
90-
assert isinstance(field, (GraphQLField, GraphQLField)), (
91-
'{}.{} must be an instance of GraphQLField.'.format(type, field_name)
92-
)
9390
assert is_output_type(field.type), (
9491
'{}.{} field type must be Output Type but got: {}.'.format(type, field_name, field.type)
9592
)

0 commit comments

Comments
 (0)