Skip to content

Commit af8b653

Browse files
committed
Improve test coverage
Replicates graphql/graphql-relay-js@dc7c027
1 parent 6662e3b commit af8b653

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

Diff for: src/graphql_relay/node/plural.py

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Any, Callable, cast
1+
from typing import Any, Callable
22

33
from graphql.type import (
44
GraphQLArgument,
@@ -8,7 +8,7 @@
88
GraphQLList,
99
GraphQLNonNull,
1010
GraphQLResolveInfo,
11-
is_non_null_type,
11+
get_nullable_type,
1212
)
1313

1414

@@ -19,9 +19,6 @@ def plural_identifying_root_field(
1919
resolve_single_input: Callable[[GraphQLResolveInfo, str], Any],
2020
description: str = None,
2121
) -> GraphQLField:
22-
if is_non_null_type(input_type):
23-
input_type = cast(GraphQLNonNull, input_type).of_type
24-
2522
def resolve(_obj, info, **args):
2623
inputs = args[arg_name]
2724
return [resolve_single_input(info, input_) for input_ in inputs]
@@ -31,7 +28,11 @@ def resolve(_obj, info, **args):
3128
description=description,
3229
args={
3330
arg_name: GraphQLArgument(
34-
GraphQLNonNull(GraphQLList(GraphQLNonNull(input_type)))
31+
GraphQLNonNull(
32+
GraphQLList(
33+
GraphQLNonNull(get_nullable_type(input_type)) # type: ignore
34+
)
35+
)
3536
)
3637
},
3738
resolve=resolve,

Diff for: tests/mutation/test_mutation.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -20,26 +20,30 @@ def __init__(self, result, clientMutationId=None):
2020
self.result = result
2121

2222

23+
def dummy_resolve(_info, **_input):
24+
return Result(1)
25+
26+
2327
simple_mutation = mutation_with_client_mutation_id(
2428
"SimpleMutation",
2529
input_fields={},
2630
output_fields={"result": GraphQLField(GraphQLInt)},
27-
mutate_and_get_payload=lambda _info, **_input: Result(1),
31+
mutate_and_get_payload=dummy_resolve,
2832
)
2933

3034
simple_mutation_with_description = mutation_with_client_mutation_id(
3135
"SimpleMutationWithDescription",
3236
description="Simple Mutation Description",
3337
input_fields={},
3438
output_fields={"result": GraphQLField(GraphQLInt)},
35-
mutate_and_get_payload=lambda _info, **_input: Result(1),
39+
mutate_and_get_payload=dummy_resolve,
3640
)
3741

3842
simple_mutation_with_deprecation_reason = mutation_with_client_mutation_id(
3943
"SimpleMutationWithDeprecationReason",
4044
input_fields={},
4145
output_fields={"result": GraphQLField(GraphQLInt)},
42-
mutate_and_get_payload=lambda _info, **_input: Result(1),
46+
mutate_and_get_payload=dummy_resolve,
4347
deprecation_reason="Just because",
4448
)
4549

0 commit comments

Comments
 (0)