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

Method QueryWithContext

api/client.go:147–155  ·  view source on GitHub ↗

QueryWithContext 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.

(ctx context.Context, hostname, name string, query any, variables map[string]any)

Source from the content-addressed store, hash-verified

145// QueryWithContext 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,
146// GraphQLError will be returned, but the receiver will also be partially populated.
147func (c Client) QueryWithContext(ctx context.Context, hostname, name string, query any, variables map[string]any) error {
148 opts := clientOptions(hostname, c.http.Transport)
149 opts.Headers[graphqlFeatures] = features
150 gqlClient, err := ghAPI.NewGraphQLClient(opts)
151 if err != nil {
152 return err
153 }
154 return handleResponse(gqlClient.QueryWithContext(ctx, name, query, variables))
155}
156
157// REST performs a REST request and parses the response.
158func (c Client) REST(hostname string, method string, p string, body io.Reader, data any) error {

Callers 1

fetchDraftReleaseFunction · 0.80

Calls 2

clientOptionsFunction · 0.85
handleResponseFunction · 0.85

Tested by

no test coverage detected