From e58bf212fed0cec78687cfc767bf24ea86ec951b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mislav=20Marohni=C4=87?= Date: Mon, 28 Nov 2022 12:18:43 +0100 Subject: [PATCH] Fix API client code docs --- api/client.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) 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