1 | import type { TypedDocumentNode } from '@graphql-typed-document-node/core';
|
2 | import type { BatchRequestDocument, BatchRequestsOptions, BatchResult } from '../functions/batchRequests.js';
|
3 | import type { RequestDocument, RequestOptions, VariablesAndRequestHeadersArgs } from '../helpers/types.js';
|
4 | import { type GraphQLClientResponse, type RawRequestOptions, type RequestConfig, type Variables } from '../helpers/types.js';
|
5 |
|
6 |
|
7 |
|
8 | export declare class GraphQLClient {
|
9 | private url;
|
10 | readonly requestConfig: RequestConfig;
|
11 | constructor(url: string, requestConfig?: RequestConfig);
|
12 | /**
|
13 | * Send a GraphQL query to the server.
|
14 | */
|
15 | rawRequest: RawRequestMethod;
|
16 | /**
|
17 | * Send a GraphQL document to the server.
|
18 | */
|
19 | request<T, V extends Variables = Variables>(document: RequestDocument | TypedDocumentNode<T, V>, ...variablesAndRequestHeaders: VariablesAndRequestHeadersArgs<V>): Promise<T>;
|
20 | request<T, V extends Variables = Variables>(options: RequestOptions<V, T>): Promise<T>;
|
21 | /**
|
22 | * Send GraphQL documents in batch to the server.
|
23 | */
|
24 | batchRequests<$BatchResult extends BatchResult, $Variables extends Variables = Variables>(documents: BatchRequestDocument<$Variables>[], requestHeaders?: HeadersInit): Promise<$BatchResult>;
|
25 | batchRequests<$BatchResult extends BatchResult, $Variables extends Variables = Variables>(options: BatchRequestsOptions<$Variables>): Promise<$BatchResult>;
|
26 | setHeaders(headers: HeadersInit): this;
|
27 | /**
|
28 | * Attach a header to the client. All subsequent requests will have this header.
|
29 | */
|
30 | setHeader(key: string, value: string): this;
|
31 | /**
|
32 | * Change the client endpoint. All subsequent requests will send to this endpoint.
|
33 | */
|
34 | setEndpoint(value: string): this;
|
35 | }
|
36 | interface RawRequestMethod {
|
37 | <T, V extends Variables = Variables>(query: string, variables?: V, requestHeaders?: HeadersInit): Promise<GraphQLClientResponse<T>>;
|
38 | <T, V extends Variables = Variables>(options: RawRequestOptions<V>): Promise<GraphQLClientResponse<T>>;
|
39 | }
|
40 | export {};
|
41 |
|
\ | No newline at end of file |