Skip to content

Commit

Permalink
Remove dead code, fix coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
kristjanvalur committed Jun 30, 2023
1 parent 9f562f2 commit 1117caf
Showing 1 changed file with 9 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -316,27 +316,13 @@ async def handle_operation(

try:
async for result in result_source:
if (
result.errors
and operation.operation_type != OperationType.SUBSCRIPTION
):
error_payload = [err.formatted for err in result.errors]
error_message = ErrorMessage(
id=operation.id, payload=error_payload
)
await operation.send_message(error_message)
self.schema.process_errors(result.errors)
return
else:
next_payload = {"data": result.data}
if result.errors:
next_payload["errors"] = [
err.formatted for err in result.errors
]
next_message = NextMessage(
id=operation.id, payload=next_payload
)
await operation.send_message(next_message)
next_payload = {"data": result.data}
if result.errors:
next_payload["errors"] = [
err.formatted for err in result.errors
]
next_message = NextMessage(id=operation.id, payload=next_payload)
await operation.send_message(next_message)
await operation.send_message(CompleteMessage(id=operation.id))
finally:
# Close the AsyncGenerator in case of errors or cancellation
Expand Down Expand Up @@ -421,8 +407,9 @@ def __init__(
self.task: Optional[asyncio.Task] = None

async def send_message(self, message: GraphQLTransportMessage) -> None:
# defensive check, should never happen
if self.completed:
return
return # pragma: no cover
if isinstance(message, (CompleteMessage, ErrorMessage)):
self.completed = True
# de-register the operation _before_ sending the final message
Expand Down

0 comments on commit 1117caf

Please sign in to comment.