Skip to content

Commit a2c9213

Browse files
authored
Merge branch 'master' into logging
2 parents ec43952 + 8ad1e3f commit a2c9213

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ language: go
33
go:
44
- 1.7.x
55
- 1.8.x
6-
- master
6+
- 1.9.x
77

88
before_install:
99
- go get github.com/golang/lint/golint

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# graphql [![GoDoc](https://godoc.org/github.com/machinebox/graphql?status.png)](http://godoc.org/github.com/machinebox/graphql) [![Build Status](https://travis-ci.org/machinebox/graphql.svg?branch=master)](https://travis-ci.org/machinebox/graphql)
1+
# graphql [![GoDoc](https://godoc.org/github.com/machinebox/graphql?status.png)](http://godoc.org/github.com/machinebox/graphql) [![Build Status](https://travis-ci.org/machinebox/graphql.svg?branch=master)](https://travis-ci.org/machinebox/graphql) [![Go Report Card](https://goreportcard.com/badge/github.com/machinebox/graphql)](https://goreportcard.com/report/github.com/machinebox/graphql)
22

33
Low-level GraphQL client for Go.
44

graphql.go

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,10 @@ func (c *Client) Run(ctx context.Context, req *Request, resp interface{}) error
107107
return errors.Wrap(err, "close writer")
108108
}
109109
c.logf(">> vars:%+v files:%d query:%s", req.vars, len(req.files), req.q)
110-
var graphResponse = struct {
111-
Data interface{}
112-
Errors []graphErr
113-
}{
110+
gr := &graphResponse{
114111
Data: resp,
115112
}
113+
116114
r, err := http.NewRequest(http.MethodPost, c.endpoint, &requestBody)
117115
if err != nil {
118116
return err
@@ -130,12 +128,12 @@ func (c *Client) Run(ctx context.Context, req *Request, resp interface{}) error
130128
return errors.Wrap(err, "reading body")
131129
}
132130
c.logf("<< %s", buf.String())
133-
if err := json.NewDecoder(&buf).Decode(&graphResponse); err != nil {
131+
if err := json.NewDecoder(&buf).Decode(&gr); err != nil {
134132
return errors.Wrap(err, "decoding response")
135133
}
136-
if len(graphResponse.Errors) > 0 {
134+
if len(gr.Errors) > 0 {
137135
// return first error
138-
return graphResponse.Errors[0]
136+
return gr.Errors[0]
139137
}
140138
return nil
141139
}
@@ -161,6 +159,11 @@ func (e graphErr) Error() string {
161159
return "graphql: " + e.Message
162160
}
163161

162+
type graphResponse struct {
163+
Data interface{}
164+
Errors []graphErr
165+
}
166+
164167
// Request is a GraphQL request.
165168
type Request struct {
166169
q string

0 commit comments

Comments
 (0)