From ade2bce1e6992bfafd30fc71a8a73ca2a450af57 Mon Sep 17 00:00:00 2001 From: Cole Wagner Date: Tue, 25 Sep 2018 13:35:08 -0700 Subject: [PATCH] Update vendored graphql library to include shurcooL/graphql#30. --- Gopkg.lock | 2 +- vendor/github.com/shurcooL/graphql/graphql.go | 6 +++++- vendor/github.com/shurcooL/graphql/query.go | 4 ++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Gopkg.lock b/Gopkg.lock index 3f00b32206a4..880c74855113 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -727,7 +727,7 @@ "ident", "internal/jsonutil", ] - revision = "62c9ce094e75302d560f7adcdf16c06d05aaa958" + revision = "e4a3a37e6d42afa87afee2edeeced52300b63893" [[projects]] name = "github.com/sirupsen/logrus" diff --git a/vendor/github.com/shurcooL/graphql/graphql.go b/vendor/github.com/shurcooL/graphql/graphql.go index f2c5b54f4a7e..e0248fd4d1c2 100644 --- a/vendor/github.com/shurcooL/graphql/graphql.go +++ b/vendor/github.com/shurcooL/graphql/graphql.go @@ -5,6 +5,7 @@ import ( "context" "encoding/json" "fmt" + "io/ioutil" "net/http" "github.com/shurcooL/go/ctxhttp" @@ -70,7 +71,8 @@ func (c *Client) do(ctx context.Context, op operationType, v interface{}, variab } defer resp.Body.Close() if resp.StatusCode != http.StatusOK { - return fmt.Errorf("unexpected status: %v", resp.Status) + body, _ := ioutil.ReadAll(resp.Body) + return fmt.Errorf("non-200 OK status code: %v body: %q", resp.Status, body) } var out struct { Data *json.RawMessage @@ -79,11 +81,13 @@ func (c *Client) do(ctx context.Context, op operationType, v interface{}, variab } err = json.NewDecoder(resp.Body).Decode(&out) if err != nil { + // TODO: Consider including response body in returned error, if deemed helpful. return err } if out.Data != nil { err := jsonutil.UnmarshalGraphQL(*out.Data, v) if err != nil { + // TODO: Consider including response body in returned error, if deemed helpful. return err } } diff --git a/vendor/github.com/shurcooL/graphql/query.go b/vendor/github.com/shurcooL/graphql/query.go index e0a7ac5a4f58..e10b77189bea 100644 --- a/vendor/github.com/shurcooL/graphql/query.go +++ b/vendor/github.com/shurcooL/graphql/query.go @@ -12,7 +12,7 @@ import ( func constructQuery(v interface{}, variables map[string]interface{}) string { query := query(v) - if variables != nil { + if len(variables) > 0 { return "query(" + queryArguments(variables) + ")" + query } return query @@ -20,7 +20,7 @@ func constructQuery(v interface{}, variables map[string]interface{}) string { func constructMutation(v interface{}, variables map[string]interface{}) string { query := query(v) - if variables != nil { + if len(variables) > 0 { return "mutation(" + queryArguments(variables) + ")" + query } return "mutation" + query