Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions gql/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 2 additions & 0 deletions gql/transport/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down