(Execution) Return valid GraphQL error when @Subscription("Subscription.myField") raises an error
tsunammis opened this issue · 0 comments
tsunammis commented
Hello,
During the execution of a Subscription, if an error is raised. The client is not notified.
SDL
type Subscription {
launchAndWaitCookingTimer(id: Int!): CookingTimer
}
enum CookingStatus {
COOKING,
COOKED
}
type CookingTimer {
remainingTime: Int!,
status: CookingStatus!
}
Resolver
import asyncio
from tartiflette import Subscription
@Subscription("Subscription.launchAndWaitCookingTimer")
async def subscription_cooking_time(
parent_result, args, ctx, info
):
raise Exception(f"Sorry, this is not the time to cook.")
Stacktrace
(tartiflette-aiohttp-tutorial) ➜ tartiflette-aiohttp-tutorial git:(master) ✗ python -m recipes_manager
======== Running on http://0.0.0.0:8080 ========
(Press CTRL+C to quit)
Task was destroyed but it is pending!
task: <Task pending coro=<AIOHTTPSubscriptionHandler._on_message() running at /Users/s.chollet/.local/share/virtualenvs/tartiflette-aiohttp-tutorial-x83JD9P8/lib/python3.7/site-packages/tartiflette_aiohttp/_subscription_ws_handler.py:215> wait_for=<Future pending cb=[<TaskWakeupMethWrapper object at 0x106527b28>()]>>
Task exception was never retrieved
future: <Task finished coro=<AIOHTTPSubscriptionHandler._on_message() done, defined at /Users/s.chollet/.local/share/virtualenvs/tartiflette-aiohttp-tutorial-x83JD9P8/lib/python3.7/site-packages/tartiflette_aiohttp/_subscription_ws_handler.py:203> exception=KeyError('d')>
Traceback (most recent call last):
File "/Users/s.chollet/.local/share/virtualenvs/tartiflette-aiohttp-tutorial-x83JD9P8/lib/python3.7/site-packages/tartiflette_aiohttp/_subscription_ws_handler.py", line 215, in _on_message
return await self._process_message(connection_context, parsed_message)
File "/Users/s.chollet/.local/share/virtualenvs/tartiflette-aiohttp-tutorial-x83JD9P8/lib/python3.7/site-packages/tartiflette_aiohttp/_subscription_ws_handler.py", line 191, in _process_message
connection_context, operation_id, payload
File "/Users/s.chollet/.local/share/virtualenvs/tartiflette-aiohttp-tutorial-x83JD9P8/lib/python3.7/site-packages/tartiflette_aiohttp/_subscription_ws_handler.py", line 161, in _on_start
async for result in iterator:
File "/Users/s.chollet/.local/share/virtualenvs/tartiflette-aiohttp-tutorial-x83JD9P8/lib/python3.7/site-packages/tartiflette/engine.py", line 89, in subscribe
error_coercer=self._error_coercer,
File "/Users/s.chollet/.local/share/virtualenvs/tartiflette-aiohttp-tutorial-x83JD9P8/lib/python3.7/site-packages/tartiflette/executors/basic.py", line 110, in subscribe
async for message in source_event_stream:
File "/Users/s.chollet/workspace/d/tartiflette/tartiflette-aiohttp-tutorial/recipes_manager/subscription_resolvers.py", line 14, in subscription_cooking_time
raise Exception(f"Sorry, this is not the time to cook.")
- Tartiflette version: 0.4.1
- Tartiflette aiohttp: 0.3.1
- Python version: 3.7.1
- Executed in docker: No
- Is a regression from a previous versions? No