Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

documenting the fact that GraphQL will always return data #39

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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