From 29d637b95902b04f086fb731619bb81aed8b04b9 Mon Sep 17 00:00:00 2001 From: Hanusz Leszek Date: Fri, 28 Aug 2020 00:53:31 +0200 Subject: [PATCH] put data in TransportQueryError --- gql/client.py | 12 +++++++++--- gql/transport/exceptions.py | 2 ++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/gql/client.py b/gql/client.py index 348592be..c4dca409 100644 --- a/gql/client.py +++ b/gql/client.py @@ -240,7 +240,9 @@ def execute(self, document: DocumentNode, *args, **kwargs) -> Dict: # Raise an error if an error is returned in the ExecutionResult object if result.errors: - raise TransportQueryError(str(result.errors[0]), errors=result.errors) + raise TransportQueryError( + str(result.errors[0]), errors=result.errors, data=result.data + ) assert ( result.data is not None @@ -315,7 +317,9 @@ async def subscribe( # Raise an error if an error is returned in the ExecutionResult object if result.errors: - raise TransportQueryError(str(result.errors[0]), errors=result.errors) + raise TransportQueryError( + str(result.errors[0]), errors=result.errors, data=result.data + ) elif result.data is not None: yield result.data @@ -340,7 +344,9 @@ async def execute(self, document: DocumentNode, *args, **kwargs) -> Dict: # Raise an error if an error is returned in the ExecutionResult object if result.errors: - raise TransportQueryError(str(result.errors[0]), errors=result.errors) + raise TransportQueryError( + str(result.errors[0]), errors=result.errors, data=result.data + ) assert ( result.data is not None diff --git a/gql/transport/exceptions.py b/gql/transport/exceptions.py index 8119c8d2..4df2ec43 100644 --- a/gql/transport/exceptions.py +++ b/gql/transport/exceptions.py @@ -30,10 +30,12 @@ def __init__( msg: str, query_id: Optional[int] = None, errors: Optional[List[Any]] = None, + data: Optional[Any] = None, ): super().__init__(msg) self.query_id = query_id self.errors = errors + self.data = data class TransportClosed(TransportError):