Skip to content

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.

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.

T

string

Record<string, unknown>

Promise<T>