MCPcopy Create free account
hub / github.com/cli/cli / GraphQL

Method GraphQL

api/client.go:108–118  ·  view source on GitHub ↗

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.

(hostname string, query string, variables map[string]any, data any, opts ...RequestOption)

Source from the content-addressed store, hash-verified

106// GraphQL performs a GraphQL request using the query string and parses the response into data receiver. If there are errors in the response,
107// GraphQLError will be returned, but the receiver will also be partially populated.
108func (c Client) GraphQL(hostname string, query string, variables map[string]any, data any, opts ...RequestOption) error {
109 cfg := newRequestConfig(opts)
110 clientOpts := clientOptions(hostname, c.http.Transport)
111 clientOpts.Headers[graphqlFeatures] = features
112 maps.Copy(clientOpts.Headers, cfg.headers)
113 gqlClient, err := ghAPI.NewGraphQLClient(clientOpts)
114 if err != nil {
115 return err
116 }
117 return handleResponse(gqlClient.Do(query, variables, data))
118}
119
120// 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,
121// GraphQLError will be returned, but the receiver will also be partially populated.

Callers 15

listRulesetsFunction · 0.80
GetCurrentLoginFunction · 0.80
listLabelsFunction · 0.80
listOrgsFunction · 0.80
listIssuesFunction · 0.80
searchIssuesFunction · 0.80
FindIssueOrPRFunction · 0.80
listReposFunction · 0.80
searchReposFunction · 0.80
repoCreateFunction · 0.80
listTemplateRepositoriesFunction · 0.80
LoadSearchResultsMethod · 0.80

Calls 5

newRequestConfigFunction · 0.85
clientOptionsFunction · 0.85
handleResponseFunction · 0.85
DoMethod · 0.65
CopyMethod · 0.45

Tested by 3

TestGraphQLFunction · 0.64
TestGraphQLErrorFunction · 0.64
TestGraphQLWithHeaderFunction · 0.64