Skip to content

Commit 6662e3b

Browse files
committed
Remove unnecessary async code, part 2
Replicates graphql/graphql-relay-js@bae5ead
1 parent f195718 commit 6662e3b

File tree

2 files changed

+12
-17
lines changed

2 files changed

+12
-17
lines changed

src/graphql_relay/node/plural.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Any, Callable
1+
from typing import Any, Callable, cast
22

33
from graphql.type import (
44
GraphQLArgument,
@@ -20,12 +20,7 @@ def plural_identifying_root_field(
2020
description: str = None,
2121
) -> GraphQLField:
2222
if is_non_null_type(input_type):
23-
input_type = input_type.of_type
24-
input_args = {
25-
arg_name: GraphQLArgument(
26-
GraphQLNonNull(GraphQLList(GraphQLNonNull(input_type)))
27-
)
28-
}
23+
input_type = cast(GraphQLNonNull, input_type).of_type
2924

3025
def resolve(_obj, info, **args):
3126
inputs = args[arg_name]
@@ -34,6 +29,10 @@ def resolve(_obj, info, **args):
3429
return GraphQLField(
3530
GraphQLList(output_type),
3631
description=description,
37-
args=input_args,
32+
args={
33+
arg_name: GraphQLArgument(
34+
GraphQLNonNull(GraphQLList(GraphQLNonNull(input_type)))
35+
)
36+
},
3837
resolve=resolve,
3938
)

tests/node/test_plural.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
from typing import NamedTuple
22

3-
from pytest import mark # type: ignore
4-
5-
from graphql import graphql
3+
from graphql import graphql_sync
64
from graphql.type import (
75
GraphQLField,
86
GraphQLObjectType,
@@ -55,8 +53,7 @@ class Context:
5553

5654

5755
def describe_plural_identifying_root_field():
58-
@mark.asyncio
59-
async def allows_fetching():
56+
def allows_fetching():
6057
query = """
6158
{
6259
usernames(usernames:["dschafer", "leebyron", "schrockn"]) {
@@ -65,7 +62,7 @@ async def allows_fetching():
6562
}
6663
}
6764
"""
68-
assert await graphql(schema, query, context_value=Context()) == (
65+
assert graphql_sync(schema, query, context_value=Context()) == (
6966
{
7067
"usernames": [
7168
{
@@ -85,8 +82,7 @@ async def allows_fetching():
8582
None,
8683
)
8784

88-
@mark.asyncio
89-
async def correctly_introspects():
85+
def correctly_introspects():
9086
query = """
9187
{
9288
__schema {
@@ -121,7 +117,7 @@ async def correctly_introspects():
121117
}
122118
}
123119
"""
124-
assert await graphql(schema, query) == (
120+
assert graphql_sync(schema, query) == (
125121
{
126122
"__schema": {
127123
"queryType": {

0 commit comments

Comments
 (0)