File tree Expand file tree Collapse file tree 2 files changed +35
-3
lines changed Expand file tree Collapse file tree 2 files changed +35
-3
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,15 @@ Low-level GraphQL client for Go.
9
9
* Use variables and upload files
10
10
* Simple error handling
11
11
12
+ ## Installation
13
+ Make sure you have a working Go environment. To install graphql, simply run:
14
+
15
+ ```
16
+ $ go get github.com/machinebox/graphql
17
+ ```
18
+
19
+ ## Usage
20
+
12
21
``` go
13
22
import " context"
14
23
@@ -29,6 +38,9 @@ req := graphql.NewRequest(`
29
38
// set any variables
30
39
req.Var (" key" , " value" )
31
40
41
+ // set header fields
42
+ req.Header .Set (" Cache-Control" , " no-cache" )
43
+
32
44
// define a Context for the request
33
45
ctx := context.Background ()
34
46
Original file line number Diff line number Diff line change @@ -178,9 +178,29 @@ type graphResponse struct {
178
178
179
179
// Request is a GraphQL request.
180
180
type Request struct {
181
- q string
182
- vars map [string ]interface {}
183
- files []file
181
+ q string
182
+ vars map [string ]interface {}
183
+ files []file
184
+
185
+ // Header mirrors the Header of a http.Request. It contains
186
+ // the request header fields either received
187
+ // by the server or to be sent by the client.
188
+ //
189
+ // If a server received a request with header lines,
190
+ //
191
+ // Host: example.com
192
+ // accept-encoding: gzip, deflate
193
+ // Accept-Language: en-us
194
+ // fOO: Bar
195
+ // foo: two
196
+ //
197
+ // then
198
+ //
199
+ // Header = map[string][]string{
200
+ // "Accept-Encoding": {"gzip, deflate"},
201
+ // "Accept-Language": {"en-us"},
202
+ // "Foo": {"Bar", "two"},
203
+ // }
184
204
Header Header
185
205
}
186
206
You can’t perform that action at this time.
0 commit comments