|
1 | 1 | import asyncio
|
2 |
| -from typing import cast |
| 2 | +from typing import cast, Awaitable |
3 | 3 |
|
4 | 4 | from pytest import raises, mark # type: ignore
|
5 | 5 |
|
@@ -84,10 +84,10 @@ def pic(self, _info, size=50):
|
84 | 84 | return f"Pic of size: {size}"
|
85 | 85 |
|
86 | 86 | def deep(self, _info):
|
87 |
| - return DeepData() # type: ignore |
| 87 | + return DeepData() |
88 | 88 |
|
89 | 89 | def promise(self, _info):
|
90 |
| - return promise_data() # type: ignore |
| 90 | + return promise_data() |
91 | 91 |
|
92 | 92 | # noinspection PyMethodMayBeStatic,PyMethodMayBeStatic
|
93 | 93 | class DeepData:
|
@@ -134,7 +134,7 @@ async def promise_data():
|
134 | 134 | "a": GraphQLField(GraphQLString),
|
135 | 135 | "b": GraphQLField(GraphQLString),
|
136 | 136 | "c": GraphQLField(GraphQLList(GraphQLString)),
|
137 |
| - "deeper": GraphQLList(DataType), |
| 137 | + "deeper": GraphQLField(GraphQLList(DataType)), |
138 | 138 | },
|
139 | 139 | )
|
140 | 140 |
|
@@ -170,9 +170,11 @@ async def promise_data():
|
170 | 170 | """
|
171 | 171 | )
|
172 | 172 |
|
173 |
| - result = await execute( |
| 173 | + awaitable_result = execute( |
174 | 174 | GraphQLSchema(DataType), document, Data(), variable_values={"size": 100}
|
175 | 175 | )
|
| 176 | + assert isinstance(awaitable_result, Awaitable) |
| 177 | + result = await awaitable_result |
176 | 178 |
|
177 | 179 | assert result == (
|
178 | 180 | {
|
@@ -411,7 +413,9 @@ async def asyncReturnErrorWithExtensions(self, _info):
|
411 | 413 | extensions={"foo": "bar"},
|
412 | 414 | )
|
413 | 415 |
|
414 |
| - result = await execute(schema, document, Data()) |
| 416 | + awaitable_result = execute(schema, document, Data()) |
| 417 | + assert isinstance(awaitable_result, Awaitable) |
| 418 | + result = await awaitable_result |
415 | 419 |
|
416 | 420 | assert result == (
|
417 | 421 | {
|
@@ -719,7 +723,9 @@ async def d(self, _info):
|
719 | 723 | def e(self, _info):
|
720 | 724 | return "e"
|
721 | 725 |
|
722 |
| - result = await execute(schema, document, Data()) |
| 726 | + awaitable_result = execute(schema, document, Data()) |
| 727 | + assert isinstance(awaitable_result, Awaitable) |
| 728 | + result = await awaitable_result |
723 | 729 |
|
724 | 730 | assert result == ({"a": "a", "b": "b", "c": "c", "d": "d", "e": "e"}, None)
|
725 | 731 |
|
@@ -874,13 +880,14 @@ def uses_a_custom_type_resolver():
|
874 | 880 | types=[foo_object],
|
875 | 881 | )
|
876 | 882 |
|
| 883 | + possible_types = None |
| 884 | + |
877 | 885 | def type_resolver(_source, info, abstract_type):
|
878 | 886 | # Resolver should be able to figure out all possible types on its own
|
879 | 887 | nonlocal possible_types
|
880 | 888 | possible_types = info.schema.get_possible_types(abstract_type)
|
881 | 889 | return "FooObject"
|
882 | 890 |
|
883 |
| - possible_types = None |
884 | 891 | root_value = {"foo": {"bar": "bar"}}
|
885 | 892 | result = execute(schema, document, root_value, type_resolver=type_resolver)
|
886 | 893 |
|
|
0 commit comments