Skip to content

Commit 5506e9a

Browse files
committed
Assert that GraphQLInputObjectFields are being passed to GraphQLInputObject's fields.
1 parent 7e99b63 commit 5506e9a

File tree

3 files changed

+14
-8
lines changed

3 files changed

+14
-8
lines changed

graphql/core/type/definition.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,10 @@ def __init__(self, name, fields, description=None):
409409
assert name, 'Type must be named.'
410410
self.name = name
411411
self.description = description
412+
413+
for field in fields.values():
414+
assert isinstance(field, GraphQLInputObjectField)
415+
412416
self._fields = fields
413417
self._field_map = None
414418

tests/core_execution/test_variables.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
GraphQLObjectType,
88
GraphQLField,
99
GraphQLArgument,
10+
GraphQLInputObjectField,
1011
GraphQLInputObjectType,
1112
GraphQLList,
1213
GraphQLString,
@@ -15,9 +16,9 @@
1516
from graphql.core.error import GraphQLError
1617

1718
TestInputObject = GraphQLInputObjectType('TestInputObject', {
18-
'a': GraphQLField(GraphQLString),
19-
'b': GraphQLField(GraphQLList(GraphQLString)),
20-
'c': GraphQLField(GraphQLNonNull(GraphQLString)),
19+
'a': GraphQLInputObjectField(GraphQLString),
20+
'b': GraphQLInputObjectField(GraphQLList(GraphQLString)),
21+
'c': GraphQLInputObjectField(GraphQLNonNull(GraphQLString)),
2122
})
2223

2324
TestType = GraphQLObjectType('TestType', {

tests/core_validation/utils.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
GraphQLInterfaceType,
1515
GraphQLEnumType,
1616
GraphQLEnumValue,
17+
GraphQLInputObjectField,
1718
GraphQLInputObjectType,
1819
GraphQLUnionType,
1920
GraphQLList)
@@ -95,11 +96,11 @@
9596
})
9697

9798
ComplexInput = GraphQLInputObjectType('ComplexInput', {
98-
'requiredField': GraphQLField(GraphQLNonNull(GraphQLBoolean)),
99-
'intField': GraphQLField(GraphQLInt),
100-
'stringField': GraphQLField(GraphQLString),
101-
'booleanField': GraphQLField(GraphQLBoolean),
102-
'stringListField': GraphQLField(GraphQLList(GraphQLString)),
99+
'requiredField': GraphQLInputObjectField(GraphQLNonNull(GraphQLBoolean)),
100+
'intField': GraphQLInputObjectField(GraphQLInt),
101+
'stringField': GraphQLInputObjectField(GraphQLString),
102+
'booleanField': GraphQLInputObjectField(GraphQLBoolean),
103+
'stringListField': GraphQLInputObjectField(GraphQLList(GraphQLString)),
103104
})
104105

105106
ComplicatedArgs = GraphQLObjectType('ComplicatedArgs', {

0 commit comments

Comments
 (0)