From f136758db4c153e47f616c5b62d680f952fda9e5 Mon Sep 17 00:00:00 2001 From: Ben Kraft Date: Thu, 25 Mar 2021 14:13:14 -0700 Subject: [PATCH] misc bits of documentation --- README.md | 4 ++-- graphql/client.go | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index c3879b6..a57dac2 100644 --- a/README.md +++ b/README.md @@ -69,13 +69,13 @@ See [DESIGN.md](DESIGN.md) for documentation of major design decisions in this l (+) denotes things we further need before recommending anyone else use this in prod Generated code: -- add flag(s) to make a field use a pointer (for optionality or perf) +- add flag(s) to make a field use a pointer (for optionality or perf; see DESIGN) - redo support for interfaces, unions, fragments (see DESIGN) - (optional) collapsing -- should be able to have `mutation { myMutation { error { code } } }` just return `(code string, err error)` Config options: - (+) proper config/arguments setup (e.g. with [viper](https://github.com/spf13/viper)) -- make client/context wiring a bit more documented and usable by humans (and allow imports for the client-getter) +- (+) improve client_getter to be more usable (and document it), or flag it out for now. - get schema via HTTP (perhaps even via GraphQL introspection) - send hash rather than full query - whether names should be exported diff --git a/graphql/client.go b/graphql/client.go index e3310bd..7813a86 100644 --- a/graphql/client.go +++ b/graphql/client.go @@ -50,7 +50,7 @@ type client struct { // NewClient returns a Client which makes requests to the given endpoint, // suitable for most users. // -// The client makes requests to the given GraphQL endpoint using standard +// The client makes POST requests to the given GraphQL endpoint using standard // GraphQL HTTP-over-JSON transport. It will use the given http client, or // http.DefaultClient if a nil client is passed. // @@ -73,7 +73,7 @@ type response struct { Errors gqlerror.List `json:"errors"` } -func (client *client) MakeRequest(ctx context.Context, query string, retval interface{}, variables map[string]interface{}) error { +func (c *client) MakeRequest(ctx context.Context, query string, retval interface{}, variables map[string]interface{}) error { body, err := json.Marshal(payload{ Query: query, Variables: variables, @@ -83,8 +83,8 @@ func (client *client) MakeRequest(ctx context.Context, query string, retval inte } req, err := http.NewRequest( - client.method, - client.endpoint, + c.method, + c.endpoint, bytes.NewReader(body)) if err != nil { return err @@ -93,7 +93,7 @@ func (client *client) MakeRequest(ctx context.Context, query string, retval inte if ctx != nil { req = req.WithContext(ctx) } - resp, err := client.httpClient.Do(req) + resp, err := c.httpClient.Do(req) if err != nil { return err }