Skip to content

Commit d17a4d4

Browse files
committed
Mypy support for SubscriptionExecutionResult
1 parent 4084639 commit d17a4d4

File tree

1 file changed

+7
-3
lines changed
  • strawberry/subscriptions/protocols/graphql_transport_ws

1 file changed

+7
-3
lines changed

strawberry/subscriptions/protocols/graphql_transport_ws/handlers.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
SubscribeMessage,
3131
SubscribeMessagePayload,
3232
)
33+
from strawberry.types import ExecutionResult
3334
from strawberry.types.graphql import OperationType
3435
from strawberry.types.unset import UNSET
3536
from strawberry.utils.debug import pretty_print_graphql_operation
@@ -42,7 +43,7 @@
4243
from strawberry.subscriptions.protocols.graphql_transport_ws.types import (
4344
GraphQLTransportMessage,
4445
)
45-
from strawberry.types import ExecutionResult
46+
4647

4748

4849
class BaseGraphQLTransportWSHandler(ABC):
@@ -274,13 +275,16 @@ async def start_operation() -> Union[AsyncGenerator[Any, None], Any]:
274275
root_value=root_value,
275276
operation_name=message.payload.operationName,
276277
)
278+
# Note: result may be SubscriptionExecutionResult or ExecutionResult
279+
# now, but we don't support the former properly yet, hence the "ignore" below.
280+
277281
# Both validation and execution errors are handled the same way.
278-
if result.errors:
282+
if isinstance(result, ExecutionResult) and result.errors:
279283
return result
280284

281285
# create AsyncGenerator returning a single result
282286
async def single_result() -> AsyncIterator[ExecutionResult]:
283-
yield result
287+
yield result # type: ignore
284288

285289
return single_result()
286290

0 commit comments

Comments
 (0)