Skip to content
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

Difficulty getting non-data "extensions" info from response #285

Open
johnhainline opened this issue Mar 13, 2024 · 0 comments
Open

Difficulty getting non-data "extensions" info from response #285

johnhainline opened this issue Mar 13, 2024 · 0 comments

Comments

@johnhainline
Copy link

johnhainline commented Mar 13, 2024

So, the GraphQL spec apparently includes an optional section in responses called "extensions". https://spec.graphql.org/October2021/#sec-Response-Format So some implementations may return important data outside the {"data": ...} field in a response. Specifically, Shopify responds with

{
    "data": ...,
    "extensions": {
        "cost": {
            "requestedQueryCost": 65,
            "actualQueryCost": 16,
            "throttleStatus": {
                "maximumAvailable": 2000.0,
                "currentlyAvailable": 1984,
                "restoreRate": 100.0
            }
        }
    }
}

to provide meta information on a request throttling scheme that Shopify uses.
Unfortunately I can see no easy way of getting this information when using ariadne-codegen to generate requests. A plugin can fix this by re-writing all the return values from generate_client_method, but would you all consider an optional return value for this extensions dictionary? (in a hacky plugin I have the generated client.py returning Tuple[MyShopifyResponseType, Optional[Dict[str, Any]]] on every function) Or perhaps some other mechanism for easy access to this data in responses?

Thanks for your time, and I love the library!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant