GraphQLClient
Defined in: graphql/graphql.ts:20
GitHub’s GraphQL API has exactly one endpoint (POST /graphql, always) —
unlike REST’s per-resource paths, there’s nothing here for createRestClient()
to route on. Reused anyway for the transport it already gets right (auth
header, JSON body/parsing, network-failure wrapping into ProviderApiError
with status: 0) — only the response-shape difference needs handling on
top: GraphQL always answers 200 OK, even for a query error, with the
error(s) in the response body’s own errors array rather than the HTTP
status. createRestClient()’s own !res.ok branch never fires for a
GraphQL error — this wrapper’s the one place that translates a 200 with a
populated errors array into a thrown ProviderApiError, matching the
REST client’s own error-throwing contract so callers don’t need to know
which transport they’re talking to.
Methods
Section titled “Methods”query()
Section titled “query()”query<
T>(document,variables?):Promise<T>
Defined in: graphql/graphql.ts:25
Sends one query or mutation to POST /graphql and returns its data. Throws a ProviderApiError (status 200, with the
distinct errors as a JSON string in details) when GitHub answers with errors, and the transport’s own ProviderApiError for a network or HTTP failure.
Type Parameters
Section titled “Type Parameters”T
Parameters
Section titled “Parameters”document
Section titled “document”string
variables?
Section titled “variables?”Record<string, unknown>
Returns
Section titled “Returns”Promise<T>