Skip to content

Commit 459bffa

Browse files
committed
better readme
1 parent d1128f7 commit 459bffa

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

README.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ Low-level GraphQL client for Go.
1010
* Simple error handling
1111

1212
```go
13-
ctx := context.Background()
14-
ctx := graphql.NewContext(ctx, "https://machinebox.io/graphql")
13+
// make a request
1514
req := graphql.NewRequest(`
1615
query ($key: String!) {
1716
items (id:$key) {
@@ -21,7 +20,15 @@ req := graphql.NewRequest(`
2120
}
2221
}
2322
`)
23+
24+
// set any variables
2425
req.Var("key", "value")
26+
27+
// get a context
28+
ctx := context.Background()
29+
ctx := graphql.NewContext(ctx, "https://machinebox.io/graphql")
30+
31+
// run it and capture the response
2532
var respData ResponseStruct
2633
if err := req.Run(ctx, &respData); err != nil {
2734
log.Fatalln(err)

0 commit comments

Comments
 (0)