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

feat: decode extensions from response via BindExtensions option #146

Merged
merged 3 commits into from
Jun 29, 2024

Conversation

hgiasac
Copy link

@hgiasac hgiasac commented Jun 29, 2024

The response map may also contain an entry with key extensions. To decode this field you need to bind a struct or map pointer. The client will optionally unmarshal the field using json decoder.

var q struct {
	User struct {
		ID   string `graphql:"id"`
		Name string `graphql:"name"`
	}
}

var ext struct {
	ID     int    `json:"id"`
	Domain string `json:"domain"`
}

err := client.Query(context.Background(), &q, map[string]interface{}{}, graphql.BindExtensions(&ext))
if err != nil {
	t.Fatal(err)
}

Copy link

github-actions bot commented Jun 29, 2024

Code Coverage

Package Line Rate Health
github.com/hasura/go-graphql-client 67%
github.com/hasura/go-graphql-client/ident 100%
github.com/hasura/go-graphql-client/pkg/jsonutil 84%
Summary 72% (1412 / 1959)

Minimum allowed line rate is 60%

@hgiasac hgiasac merged commit 1d68c4a into master Jun 29, 2024
1 check passed
@hgiasac hgiasac deleted the add-query-mutation-with-extensions branch June 29, 2024 07:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant