diff --git a/api/client.go b/api/client.go index 61b5d844b..575da6a6c 100644 --- a/api/client.go +++ b/api/client.go @@ -1,6 +1,7 @@ package api import ( + "context" "encoding/json" "errors" "fmt" @@ -51,8 +52,8 @@ func (err HTTPError) ScopesSuggestion() string { return err.scopesSuggestion } -// GraphQL performs a GraphQL request and parses the response. If there are errors in the response, -// GraphQLError will be returned, but the data will also be parsed into the receiver. +// GraphQL performs a GraphQL request using the query string and parses the response into data receiver. If there are errors in the response, +// GraphQLError will be returned, but the receiver will also be partially populated. func (c Client) GraphQL(hostname string, query string, variables map[string]interface{}, data interface{}) error { opts := clientOptions(hostname, c.http.Transport) opts.Headers[graphqlFeatures] = features @@ -63,8 +64,8 @@ func (c Client) GraphQL(hostname string, query string, variables map[string]inte return handleResponse(gqlClient.Do(query, variables, data)) } -// GraphQL performs a GraphQL mutation and parses the response. If there are errors in the response, -// GraphQLError will be returned, but the data will also be parsed into the receiver. +// Mutate performs a GraphQL mutation based on a struct and parses the response with the same struct as the receiver. If there are errors in the response, +// GraphQLError will be returned, but the receiver will also be partially populated. func (c Client) Mutate(hostname, name string, mutation interface{}, variables map[string]interface{}) error { opts := clientOptions(hostname, c.http.Transport) opts.Headers[graphqlFeatures] = features @@ -75,8 +76,8 @@ func (c Client) Mutate(hostname, name string, mutation interface{}, variables ma return handleResponse(gqlClient.Mutate(name, mutation, variables)) } -// GraphQL performs a GraphQL query and parses the response. If there are errors in the response, -// GraphQLError will be returned, but the data will also be parsed into the receiver. +// Query performs a GraphQL query based on a struct and parses the response with the same struct as the receiver. If there are errors in the response, +// GraphQLError will be returned, but the receiver will also be partially populated. func (c Client) Query(hostname, name string, query interface{}, variables map[string]interface{}) error { opts := clientOptions(hostname, c.http.Transport) opts.Headers[graphqlFeatures] = features