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