question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Customizable ExecutionResult, or how to get other API response parts

See original GitHub issue

https://github.com/graphql-python/gql/blob/459d5ebacce95c817effcd18be152d6cf360cf2b/gql/transport/requests.py#L174

Case:

The GraphQL API that I need to make requests to, responds with some other useful information, except of data block:

{
    "data": {...},
    "extensions": {
        "pageInfo": {
            "limitPage": 200,
            "totalCount": 23306516,
            "hasNextPage": true,
            "lastId": 41922710
        }
    }
}

But, as gql transport composes ExecutionResult from data and errors blocks only, I’m not able to get and use the extensions part in my code. I was hoping to use hasNextPage and lastId 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 with data and errors, using gql?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
extrincommented, Jan 23, 2021

Thanks for your answers! I see that the extensions field was added to ExecutionResult in graphql-core. It seems that this change is not in release version yet. I just tried to fork repo and add extensions field for transports, but the ExecutionResult imported from graphql doesn’t have this field either.

0reactions
leszekhanuszcommented, Nov 23, 2021

Finally I choose to add a get_execution_result argument to execute and subscribe methods.

See PR #257

Read more comments on GitHub >

github_iconTop Results From Across the Web

3 Ways to Make Your API Responses Flexible - Zapier
Most APIs deliver their responses the exact same way to every client. That's by design; developers need to know what to expect.
Read more >
Modifying REST API responses | Contentful
This guide illustrates how to use the `select` operator to modify the API payload to include only the relevant data.
Read more >
Customize REST API Responses - OutSystems documentation
Open the OnResponse callback action that's now available under the REST API. Design the logic to customize the information of the response.
Read more >
How to return a custom error object and status code from API ...
Go ahead and play around with it some first. I'll dissect each part later in the article. The Lambda function. Create a Lambda...
Read more >
Understanding And Using REST APIs - Smashing Magazine
Everything you need to know about REST APIs, from start to finish. How and why to use REST APIs, how to deal with...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found