UNPKG

3.3 kBTypeScriptView Raw
1import type { ASTNode } from "graphql";
2import { print } from "../../utilities/index.js";
3import type { Operation } from "../core/index.js";
4export interface Printer {
5 (node: ASTNode, originalPrint: typeof print): string;
6}
7export interface UriFunction {
8 (operation: Operation): string;
9}
10export interface Body {
11 query?: string;
12 operationName?: string;
13 variables?: Record<string, any>;
14 extensions?: Record<string, any>;
15}
16export interface HttpOptions {
17 /**
18 * The URI to use when fetching operations.
19 *
20 * Defaults to '/graphql'.
21 */
22 uri?: string | UriFunction;
23 /**
24 * Passes the extensions field to your graphql server.
25 *
26 * Defaults to false.
27 */
28 includeExtensions?: boolean;
29 /**
30 * A `fetch`-compatible API to use when making requests.
31 */
32 fetch?: typeof fetch;
33 /**
34 * An object representing values to be sent as headers on the request.
35 */
36 headers?: Record<string, string>;
37 /**
38 * If set to true, header names won't be automatically normalized to
39 * lowercase. This allows for non-http-spec-compliant servers that might
40 * expect capitalized header names.
41 */
42 preserveHeaderCase?: boolean;
43 /**
44 * The credentials policy you want to use for the fetch call.
45 */
46 credentials?: string;
47 /**
48 * Any overrides of the fetch options argument to pass to the fetch call.
49 */
50 fetchOptions?: any;
51 /**
52 * If set to true, use the HTTP GET method for query operations. Mutations
53 * will still use the method specified in fetchOptions.method (which defaults
54 * to POST).
55 */
56 useGETForQueries?: boolean;
57 /**
58 * If set to true, the default behavior of stripping unused variables
59 * from the request will be disabled.
60 *
61 * Unused variables are likely to trigger server-side validation errors,
62 * per https://spec.graphql.org/draft/#sec-All-Variables-Used, but this
63 * includeUnusedVariables option can be useful if your server deviates
64 * from the GraphQL specification by not strictly enforcing that rule.
65 */
66 includeUnusedVariables?: boolean;
67 /**
68 * A function to substitute for the default query print function. Can be
69 * used to apply changes to the results of the print function.
70 */
71 print?: Printer;
72}
73export interface HttpQueryOptions {
74 includeQuery?: boolean;
75 includeExtensions?: boolean;
76 preserveHeaderCase?: boolean;
77}
78export interface HttpConfig {
79 http?: HttpQueryOptions;
80 options?: any;
81 headers?: Record<string, string>;
82 credentials?: any;
83}
84export declare const fallbackHttpConfig: {
85 http: HttpQueryOptions;
86 headers: {
87 accept: string;
88 "content-type": string;
89 };
90 options: {
91 method: string;
92 };
93};
94export declare const defaultPrinter: Printer;
95export declare function selectHttpOptionsAndBody(operation: Operation, fallbackConfig: HttpConfig, ...configs: Array<HttpConfig>): {
96 options: HttpConfig & Record<string, any>;
97 body: Body;
98};
99export declare function selectHttpOptionsAndBodyInternal(operation: Operation, printer: Printer, ...configs: HttpConfig[]): {
100 options: HttpConfig & Record<string, any>;
101 body: Body;
102};
103//# sourceMappingURL=selectHttpOptionsAndBody.d.ts.map
\No newline at end of file