mirror of
https://github.com/graphql-python/graphene.git
synced 2025-09-21 11:22:33 +03:00
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.
This commit is contained in:
parent
55a03ba716
commit
8fccdd7e3a
|
@ -46,7 +46,7 @@ type Faction implements Node {
|
||||||
input IntroduceShipInput {
|
input IntroduceShipInput {
|
||||||
shipName: String!
|
shipName: String!
|
||||||
factionId: String!
|
factionId: String!
|
||||||
clientMutationId: String = null
|
clientMutationId: String
|
||||||
}
|
}
|
||||||
|
|
||||||
type IntroduceShipPayload {
|
type IntroduceShipPayload {
|
||||||
|
|
|
@ -80,11 +80,11 @@ class OtherMutation(ClientIDMutation):
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def mutate_and_get_payload(
|
def mutate_and_get_payload(
|
||||||
self, info, shared, additional_field, client_mutation_id=None
|
self, info, shared="", additional_field="", client_mutation_id=None
|
||||||
):
|
):
|
||||||
edge_type = MyEdge
|
edge_type = MyEdge
|
||||||
return OtherMutation(
|
return OtherMutation(
|
||||||
name=(shared or "") + (additional_field or ""),
|
name=shared + additional_field,
|
||||||
my_node_edge=edge_type(cursor="1", node=MyNode(name="name")),
|
my_node_edge=edge_type(cursor="1", node=MyNode(name="name")),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
from graphql.error import INVALID
|
||||||
from .mountedtype import MountedType
|
from .mountedtype import MountedType
|
||||||
from .structures import NonNull
|
from .structures import NonNull
|
||||||
from .utils import get_type
|
from .utils import get_type
|
||||||
|
@ -48,7 +49,7 @@ class InputField(MountedType):
|
||||||
self,
|
self,
|
||||||
type,
|
type,
|
||||||
name=None,
|
name=None,
|
||||||
default_value=None,
|
default_value=INVALID,
|
||||||
deprecation_reason=None,
|
deprecation_reason=None,
|
||||||
description=None,
|
description=None,
|
||||||
required=False,
|
required=False,
|
||||||
|
|
|
@ -262,17 +262,14 @@ def test_query_input_field():
|
||||||
|
|
||||||
result = test_schema.execute('{ test(aInput: {aField: "String!"} ) }', "Source!")
|
result = test_schema.execute('{ test(aInput: {aField: "String!"} ) }', "Source!")
|
||||||
assert not result.errors
|
assert not result.errors
|
||||||
assert result.data == {
|
assert result.data == {"test": '["Source!",{"a_input":{"a_field":"String!"}}]'}
|
||||||
"test": '["Source!",{"a_input":{"a_field":"String!","recursive_field":null}}]'
|
|
||||||
}
|
|
||||||
|
|
||||||
result = test_schema.execute(
|
result = test_schema.execute(
|
||||||
'{ test(aInput: {recursiveField: {aField: "String!"}}) }', "Source!"
|
'{ test(aInput: {recursiveField: {aField: "String!"}}) }', "Source!"
|
||||||
)
|
)
|
||||||
assert not result.errors
|
assert not result.errors
|
||||||
assert result.data == {
|
assert result.data == {
|
||||||
"test": '["Source!",{"a_input":{"a_field":null,"recursive_field":'
|
"test": '["Source!",{"a_input":{"recursive_field":{"a_field":"String!"}}}]'
|
||||||
'{"a_field":"String!","recursive_field":null}}}]'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -408,7 +405,7 @@ def test_big_list_of_containers_multiple_fields_query_benchmark(benchmark):
|
||||||
|
|
||||||
|
|
||||||
def test_big_list_of_containers_multiple_fields_custom_resolvers_query_benchmark(
|
def test_big_list_of_containers_multiple_fields_custom_resolvers_query_benchmark(
|
||||||
benchmark
|
benchmark,
|
||||||
):
|
):
|
||||||
class Container(ObjectType):
|
class Container(ObjectType):
|
||||||
x = Int()
|
x = Int()
|
||||||
|
|
|
@ -42,11 +42,11 @@ class OtherMutation(ClientIDMutation):
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def mutate_and_get_payload(
|
def mutate_and_get_payload(
|
||||||
self, info, shared, additional_field, client_mutation_id=None
|
self, info, shared="", additional_field="", client_mutation_id=None
|
||||||
):
|
):
|
||||||
edge_type = MyEdge
|
edge_type = MyEdge
|
||||||
return OtherMutation(
|
return OtherMutation(
|
||||||
name=(shared or "") + (additional_field or ""),
|
name=shared + additional_field,
|
||||||
my_node_edge=edge_type(cursor="1", node=MyNode(name="name")),
|
my_node_edge=edge_type(cursor="1", node=MyNode(name="name")),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user