GithubHelp home page GithubHelp logo

Comments (2)

benjaminjkraft avatar benjaminjkraft commented on June 26, 2024

Two options here that exist today:

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

# genqlient.yaml
extensions_type: path/to/mypkg.Extensions
package mypkg
type Extensions struct {
  Cost struct { ... } `json:"cost"
}

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.

from genqlient.

adrianocr avatar adrianocr commented on June 26, 2024

use_extensions is perfect, thank you so much. I had no idea it was an option. Resolved my issues

from genqlient.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.