-
Notifications
You must be signed in to change notification settings - Fork 184
Customizable ExecutionResult, or how to get other API response parts #188
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Currently this is not possible, the If you want direct access to the ExecutionResult instance, you could use the A simple PR could be made to add the extensions field of the ExecutionResult object for all the transports. |
AFAIK the execution result only returns the
EDIT: I remember now this is some new change at graphql-js 15.0 and above. This was discussed at graphql-core issue 107, which I pointed to the spec as well 🙈 https://spec.graphql.org/draft/#sec-Response-Format |
Thanks for your answers! |
Even if "extensions" was added to the ExecutionResult object for all transports, it would not be retrievable using Client.execute, because that method returns a Dict object containing only the contents of the "data" key: https://github.com/graphql-python/gql/blob/master/gql/client.py#L420 |
This should be fixed by #190 |
What we could maybe do, is to add an argument to the execute method to specify a key which will be inserted inside the data Dict. async def execute(self, document: DocumentNode, extensions_key: Optional[str] = None, *args, **kwargs) -> Dict:
....
if result.extensions is not None and extensions_key is not None:
result.data[extensions_key] = result.extensions
return result.data |
Finally I choose to add a See PR #257 |
gql/gql/transport/requests.py
Line 174 in 459d5eb
Case:
The GraphQL API that I need to make requests to, responds with some other useful information, except of
data
block:But, as gql transport composes
ExecutionResult
fromdata
anderrors
blocks only, I'm not able to get and use theextensions
part in my code.I was hoping to use
hasNextPage
andlastId
values to iterate through pages of data, to load all the data to database.Question:
Is there any way to get
extensions
part of response, along withdata
anderrors
, using gql?The text was updated successfully, but these errors were encountered: