Skip to content

Commit 22fe7a5

Browse files
author
Jason Kao
committed
defined context in README example
1 parent 573946b commit 22fe7a5

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

README.md

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

1212
```go
13+
import "context"
14+
1315
// create a client (safe to share across requests)
1416
client := graphql.NewClient("https://machinebox.io/graphql")
1517

@@ -27,6 +29,9 @@ req := graphql.NewRequest(`
2729
// set any variables
2830
req.Var("key", "value")
2931

32+
// define a Context for the request
33+
ctx := context.Background()
34+
3035
// run it and capture the response
3136
var respData ResponseStruct
3237
if err := client.Run(ctx, req, &respData); err != nil {

0 commit comments

Comments
 (0)