Skip to content

Commit ad0b3a5

Browse files
Jean-Louis Fuchsjkimbo
Jean-Louis Fuchs
andauthored
The default_value of InputField should be INVALID (#1111)
* The default_value of InputField should be INVALID Since GraphQL 3.0 there is a distinction between None and INVALID (no value). The tests captured the bug and are updated. * Update minimum graphql-core version * Use Undefined instead of INVALID Co-authored-by: Jonathan Kim <jkimbo@gmail.com>
1 parent 9a19447 commit ad0b3a5

File tree

6 files changed

+11
-13
lines changed

6 files changed

+11
-13
lines changed

examples/starwars_relay/tests/snapshots/snap_test_objectidentification.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
input IntroduceShipInput {
4747
shipName: String!
4848
factionId: String!
49-
clientMutationId: String = null
49+
clientMutationId: String
5050
}
5151
5252
type IntroduceShipPayload {

graphene/relay/tests/test_mutation.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,11 @@ class Input(SharedFields):
8080

8181
@staticmethod
8282
def mutate_and_get_payload(
83-
self, info, shared, additional_field, client_mutation_id=None
83+
self, info, shared="", additional_field="", client_mutation_id=None
8484
):
8585
edge_type = MyEdge
8686
return OtherMutation(
87-
name=(shared or "") + (additional_field or ""),
87+
name=shared + additional_field,
8888
my_node_edge=edge_type(cursor="1", node=MyNode(name="name")),
8989
)
9090

graphene/types/inputfield.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from graphql import Undefined
12
from .mountedtype import MountedType
23
from .structures import NonNull
34
from .utils import get_type
@@ -48,7 +49,7 @@ def __init__(
4849
self,
4950
type,
5051
name=None,
51-
default_value=None,
52+
default_value=Undefined,
5253
deprecation_reason=None,
5354
description=None,
5455
required=False,

graphene/types/tests/test_query.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -262,17 +262,14 @@ def resolve_test(self, info, **args):
262262

263263
result = test_schema.execute('{ test(aInput: {aField: "String!"} ) }', "Source!")
264264
assert not result.errors
265-
assert result.data == {
266-
"test": '["Source!",{"a_input":{"a_field":"String!","recursive_field":null}}]'
267-
}
265+
assert result.data == {"test": '["Source!",{"a_input":{"a_field":"String!"}}]'}
268266

269267
result = test_schema.execute(
270268
'{ test(aInput: {recursiveField: {aField: "String!"}}) }', "Source!"
271269
)
272270
assert not result.errors
273271
assert result.data == {
274-
"test": '["Source!",{"a_input":{"a_field":null,"recursive_field":'
275-
'{"a_field":"String!","recursive_field":null}}}]'
272+
"test": '["Source!",{"a_input":{"recursive_field":{"a_field":"String!"}}}]'
276273
}
277274

278275

@@ -408,7 +405,7 @@ def resolve_all_containers(self, info):
408405

409406

410407
def test_big_list_of_containers_multiple_fields_custom_resolvers_query_benchmark(
411-
benchmark
408+
benchmark,
412409
):
413410
class Container(ObjectType):
414411
x = Int()

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def run_tests(self):
8383
keywords="api graphql protocol rest relay graphene",
8484
packages=find_packages(exclude=["tests", "tests.*", "examples"]),
8585
install_requires=[
86-
"graphql-core>=3.0.0,<4",
86+
"graphql-core>=3.0.3,<4",
8787
"graphql-relay>=3.0.0,<4",
8888
"aniso8601>=6,<9",
8989
"unidecode>=1.1.1,<2",

tests_asyncio/test_relay_mutation.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,11 @@ class Input(SharedFields):
4242

4343
@staticmethod
4444
def mutate_and_get_payload(
45-
self, info, shared, additional_field, client_mutation_id=None
45+
self, info, shared="", additional_field="", client_mutation_id=None
4646
):
4747
edge_type = MyEdge
4848
return OtherMutation(
49-
name=(shared or "") + (additional_field or ""),
49+
name=shared + additional_field,
5050
my_node_edge=edge_type(cursor="1", node=MyNode(name="name")),
5151
)
5252

0 commit comments

Comments
 (0)