Add GraphQL Extensions (#184)

This enables accessing the Extensions field, as defined in the response
format: https://spec.graphql.org/October2021/#sec-Response-Format

Extensions can be enabled using configuration option use_extensions.
This will change the return parameters of the generated client
functions. Making it a breaking change if enabled.

Since extensions are untyped as defined in the spec, the Client will
return an interface of type map[string]interface{}.
This commit is contained in:
Jan-Hendrik Boll
2022-03-30 13:48:01 -07:00
committed by GitHub
parent e81d19c8be
commit b2422452a1
63 changed files with 1792 additions and 951 deletions
+3 -3
View File
@@ -88,16 +88,16 @@ func (c *roundtripClient) roundtripResponse(resp interface{}) {
assert.Equal(c.t, string(body), string(bodyAgain))
}
func (c *roundtripClient) MakeRequest(ctx context.Context, opName, query string, retval, variables interface{}) error {
func (c *roundtripClient) MakeRequest(ctx context.Context, req *graphql.Request, resp *graphql.Response) error {
// TODO(benkraft): Also check the variables round-trip. This is a bit less
// important since most of the code is the same (and input types are
// strictly simpler), and a bit hard to do because when asserting about
// structs we need to worry about things like equality of time.Time values.
err := c.wrapped.MakeRequest(ctx, opName, query, retval, variables)
err := c.wrapped.MakeRequest(ctx, req, resp)
if err != nil {
return err
}
c.roundtripResponse(retval)
c.roundtripResponse(resp.Data)
return nil
}