1 | import type { TypedDocumentNode } from '@graphql-typed-document-node/core';
|
2 | import type { GraphQLError } from 'graphql';
|
3 | import type { DocumentNode } from 'graphql';
|
4 | import type { MaybeLazy, MaybePromise, RemoveIndex } from '../../lib/prelude.js';
|
5 | import type { ClientError } from '../classes/ClientError.js';
|
6 | export type Fetch = typeof fetch;
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 | export type ErrorPolicy = 'none' | 'ignore' | 'all';
|
15 | export interface JsonSerializer {
|
16 | stringify: (obj: any) => string;
|
17 | parse: (obj: string) => unknown;
|
18 | }
|
19 | export interface AdditionalRequestOptions {
|
20 | jsonSerializer?: JsonSerializer;
|
21 | |
22 |
|
23 |
|
24 | errorPolicy?: ErrorPolicy;
|
25 | }
|
26 | export interface FetchOptions extends RequestInit, AdditionalRequestOptions {
|
27 | }
|
28 | export type { GraphQLError };
|
29 | export type Variables = object;
|
30 | export type BatchVariables = (Variables | undefined)[];
|
31 | export interface GraphQLResponse<T = unknown> {
|
32 | data?: T;
|
33 | errors?: GraphQLError[];
|
34 | extensions?: unknown;
|
35 | status: number;
|
36 | [key: string]: unknown;
|
37 | }
|
38 | export interface GraphQLRequestContext<V extends Variables = Variables> {
|
39 | query: string | string[];
|
40 | variables?: V;
|
41 | }
|
42 | export type RequestDocument = string | DocumentNode;
|
43 | export interface GraphQLClientResponse<Data> {
|
44 | status: number;
|
45 | headers: Headers;
|
46 | data: Data;
|
47 | extensions?: unknown;
|
48 | errors?: GraphQLError[];
|
49 | }
|
50 | export type HTTPMethodInput = 'GET' | 'POST' | 'get' | 'post';
|
51 | export interface RequestConfig extends Omit<RequestInit, 'headers' | 'method'>, AdditionalRequestOptions {
|
52 | fetch?: Fetch;
|
53 | method?: HTTPMethodInput;
|
54 | headers?: MaybeLazy<HeadersInit>;
|
55 | requestMiddleware?: RequestMiddleware;
|
56 | responseMiddleware?: ResponseMiddleware;
|
57 | jsonSerializer?: JsonSerializer;
|
58 | excludeOperationName?: boolean;
|
59 | }
|
60 | export type RawRequestOptions<V extends Variables = Variables> = {
|
61 | query: string;
|
62 | requestHeaders?: HeadersInit;
|
63 | signal?: RequestInit['signal'];
|
64 | } & (V extends Record<any, never> ? {
|
65 | variables?: V;
|
66 | } : keyof RemoveIndex<V> extends never ? {
|
67 | variables?: V;
|
68 | } : {
|
69 | variables: V;
|
70 | });
|
71 | export type RequestOptions<V extends Variables = Variables, T = unknown> = {
|
72 | document: RequestDocument | TypedDocumentNode<T, V>;
|
73 | requestHeaders?: HeadersInit;
|
74 | signal?: RequestInit['signal'];
|
75 | } & (V extends Record<any, never> ? {
|
76 | variables?: V;
|
77 | } : keyof RemoveIndex<V> extends never ? {
|
78 | variables?: V;
|
79 | } : {
|
80 | variables: V;
|
81 | });
|
82 | export type ResponseMiddleware = (response: GraphQLClientResponse<unknown> | ClientError | Error, request: RequestInitExtended) => MaybePromise<void>;
|
83 | export type RequestMiddleware<V extends Variables = Variables> = (request: RequestInitExtended<V>) => RequestInitExtended | Promise<RequestInitExtended>;
|
84 | export type RequestInitExtended<V extends Variables = Variables> = RequestInit & {
|
85 | url: string;
|
86 | operationName?: string;
|
87 | variables?: V;
|
88 | };
|
89 | export type VariablesAndRequestHeadersArgs<V extends Variables> = V extends Record<any, never> ? [variables?: V, requestHeaders?: HeadersInit] : keyof RemoveIndex<V> extends never ? [variables?: V, requestHeaders?: HeadersInit] : [variables: V, requestHeaders?: HeadersInit];
|
90 |
|
\ | No newline at end of file |