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

Method GraphQL

api/client.go:109–119  ·  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

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