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

Method QueryWithContext

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

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