1 | import type { EndpointOptions, RequestParameters as RequestParametersType, EndpointInterface } from "@octokit/types";
|
2 | export type GraphQlEndpointOptions = EndpointOptions & {
|
3 | variables?: {
|
4 | [key: string]: unknown;
|
5 | };
|
6 | };
|
7 | export type RequestParameters = RequestParametersType;
|
8 | export type Query = string;
|
9 | export interface graphql {
|
10 | /**
|
11 | * Sends a GraphQL query request based on endpoint options
|
12 | * The GraphQL query must be specified in `options`.
|
13 | *
|
14 | * @param {object} endpoint Must set `method` and `url`. Plus URL, query or body parameters, as well as `headers`, `mediaType.{format|previews}`, `request`, or `baseUrl`.
|
15 | */
|
16 | <ResponseData>(options: RequestParameters): GraphQlResponse<ResponseData>;
|
17 | /**
|
18 | * Sends a GraphQL query request based on endpoint options
|
19 | *
|
20 | * @param {string} query GraphQL query. Example: `'query { viewer { login } }'`.
|
21 | * @param {object} [parameters] URL, query or body parameters, as well as `headers`, `mediaType.{format|previews}`, `request`, or `baseUrl`.
|
22 | */
|
23 | <ResponseData>(query: Query, parameters?: RequestParameters): GraphQlResponse<ResponseData>;
|
24 | /**
|
25 | * Returns a new `endpoint` with updated route and parameters
|
26 | */
|
27 | defaults: (newDefaults: RequestParameters) => graphql;
|
28 | /**
|
29 | * Octokit endpoint API, see {@link https://github.com/octokit/endpoint.js|@octokit/endpoint}
|
30 | */
|
31 | endpoint: EndpointInterface;
|
32 | }
|
33 | export type GraphQlResponse<ResponseData> = Promise<ResponseData>;
|
34 | export type GraphQlQueryResponseData = {
|
35 | [key: string]: any;
|
36 | };
|
37 | export type GraphQlQueryResponse<ResponseData> = {
|
38 | data: ResponseData;
|
39 | errors?: [
|
40 | {
|
41 | type: string;
|
42 | message: string;
|
43 | path: [string];
|
44 | extensions: {
|
45 | [key: string]: any;
|
46 | };
|
47 | locations: [
|
48 | {
|
49 | line: number;
|
50 | column: number;
|
51 | }
|
52 | ];
|
53 | }
|
54 | ];
|
55 | };
|