UNPKG

2.03 kBTypeScriptView Raw
1import type { TypedDocumentNode } from '@graphql-typed-document-node/core';
2import type { RequestDocument, RequestOptions, Variables, VariablesAndRequestHeadersArgs } from '../helpers/types.js';
3/**
4 * Send a GraphQL Document to the GraphQL server for execution.
5 *
6 * @example
7 *
8 * ```ts
9 * // You can pass a raw string
10 *
11 * await request('https://foo.bar/graphql', `
12 * {
13 * query {
14 * users
15 * }
16 * }
17 * `)
18 *
19 * // You can also pass a GraphQL DocumentNode. Convenient if you
20 * // are using graphql-tag package.
21 *
22 * import gql from 'graphql-tag'
23 *
24 * await request('https://foo.bar/graphql', gql`...`)
25 *
26 * // If you don't actually care about using DocumentNode but just
27 * // want the tooling support for gql template tag like IDE syntax
28 * // coloring and prettier autoformat then note you can use the
29 * // passthrough gql tag shipped with graphql-request to save a bit
30 * // of performance and not have to install another dep into your project.
31 *
32 * import { gql } from 'graphql-request'
33 *
34 * await request('https://foo.bar/graphql', gql`...`)
35 * ```
36 */
37export declare function request<T, V extends Variables = Variables>(options: RequestExtendedOptions<V, T>): Promise<T>;
38export declare function request<T, V extends Variables = Variables>(url: string, document: RequestDocument | TypedDocumentNode<T, V>, ...variablesAndRequestHeaders: VariablesAndRequestHeadersArgs<V>): Promise<T>;
39export declare const parseRequestArgs: <V extends Variables = object>(documentOrOptions: RequestDocument | RequestOptions<V>, variables?: V, requestHeaders?: HeadersInit) => RequestOptions<V>;
40export type RequestExtendedOptions<V extends Variables = Variables, T = unknown> = {
41 url: string;
42} & RequestOptions<V, T>;
43export declare const parseRequestExtendedArgs: <V extends Variables = object>(urlOrOptions: string | RequestExtendedOptions<V>, document?: RequestDocument, ...variablesAndRequestHeaders: VariablesAndRequestHeadersArgs<V>) => RequestExtendedOptions<V>;
44//# sourceMappingURL=request.d.ts.map
\No newline at end of file