You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
I am using genqlient to query the shopify graphql api. It works fine but the shopify api is rate limited to 50 data points per second. To facilitate not being throttled the shopify api includes rate limit information (leaky bucket algorithm) as part of the response. A response looks like this:
The extensions object provides the rate limit data. But genqlient only makes the products part of the response available.
Describe the solution you'd like
Ideally it would be nice to access extra data as part of the type genqlient returns for each query, but if that's not possible then accessing the raw http response would allow for a user to manually marshal the data into a type and access it.
The text was updated successfully, but these errors were encountered:
First, customize the graphql.Client -- basically, write your own implementation of the interface (likely extending the provided one similar to how auth works) that extracts those extensions. (Actually, we already parse them to a map[string]interface{}.) That works well if you want to, say, retry at a given time, or attach data to the error, or update the context somehow (say, if you want to keep track in some quasi-global way of the last rate limit status). But it doesn't really let you add a field to the response for the caller to handle.
Alternately, the option use_extensions adds a return parameter with the extensions. This was added in #184 (see the issue #183 for a bit of discussion on why it's set up this way). It will work better if you want the caller to handle the extensions.
While writing this I realize we could maybe do better on the second half by letting you make the extensions typed? Something like
and then instead of map[string]interface{} you get *mypkg.Extensions. Arguably we could even do that if you don't have use_extensions, just for the benefit of a custom graphql.Client. Not sure how important that is for your use case, but it seems reasonable to add.
Is your feature request related to a problem? Please describe.
I am using genqlient to query the shopify graphql api. It works fine but the shopify api is rate limited to 50 data points per second. To facilitate not being throttled the shopify api includes rate limit information (leaky bucket algorithm) as part of the response. A response looks like this:
The
extensions
object provides the rate limit data. But genqlient only makes theproducts
part of the response available.Describe the solution you'd like
Ideally it would be nice to access extra data as part of the type genqlient returns for each query, but if that's not possible then accessing the raw http response would allow for a user to manually marshal the data into a type and access it.
The text was updated successfully, but these errors were encountered: