Skip to content

Commit

Permalink
defined context in README example
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason Kao committed Mar 6, 2018
1 parent 573946b commit 22fe7a5
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ Low-level GraphQL client for Go.
* Simple error handling

```go
import "context"

// create a client (safe to share across requests)
client := graphql.NewClient("https://machinebox.io/graphql")

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

// define a Context for the request
ctx := context.Background()

// run it and capture the response
var respData ResponseStruct
if err := client.Run(ctx, req, &respData); err != nil {
Expand Down

0 comments on commit 22fe7a5

Please sign in to comment.