Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ $ go get github.com/machinebox/graphql
```go
import "context"

type Items struct {
Key string `json:"key"`
}

type ResponseStruct struct {
Items []Items `json:"items"`
}

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

Expand Down Expand Up @@ -49,8 +57,12 @@ var respData ResponseStruct
if err := client.Run(ctx, req, &respData); err != nil {
log.Fatal(err)
}

fmt.Println(respData.Items[0].Key)
```

The response struct does not need the data field as client.Run expects GraphQL will always return data.

### File support via multipart form data

By default, the package will send a JSON body. To enable the sending of files, you can opt to
Expand Down