UNPKG

2.82 kBTypeScriptView Raw
1import type { GraphQLFormattedError } from "graphql";
2import type { DocumentNode } from "graphql";
3import type { DefaultContext } from "../../core/index.js";
4export type { DocumentNode };
5import type { Observable } from "../../utilities/index.js";
6export type Path = ReadonlyArray<string | number>;
7interface ExecutionPatchResultBase {
8 hasNext?: boolean;
9}
10export interface ExecutionPatchInitialResult<TData = Record<string, any>, TExtensions = Record<string, any>> extends ExecutionPatchResultBase {
11 data: TData | null | undefined;
12 incremental?: never;
13 errors?: ReadonlyArray<GraphQLFormattedError>;
14 extensions?: TExtensions;
15}
16export interface IncrementalPayload<TData, TExtensions> {
17 data: TData | null;
18 label?: string;
19 path: Path;
20 errors?: ReadonlyArray<GraphQLFormattedError>;
21 extensions?: TExtensions;
22}
23export interface ExecutionPatchIncrementalResult<TData = Record<string, any>, TExtensions = Record<string, any>> extends ExecutionPatchResultBase {
24 incremental?: IncrementalPayload<TData, TExtensions>[];
25 data?: never;
26 errors?: never;
27 extensions?: never;
28}
29export interface ApolloPayloadResult<TData = Record<string, any>, TExtensions = Record<string, any>> {
30 payload: SingleExecutionResult | ExecutionPatchResult | null;
31 errors?: ReadonlyArray<Error | string>;
32}
33export type ExecutionPatchResult<TData = Record<string, any>, TExtensions = Record<string, any>> = ExecutionPatchInitialResult<TData, TExtensions> | ExecutionPatchIncrementalResult<TData, TExtensions>;
34export interface GraphQLRequest<TVariables = Record<string, any>> {
35 query: DocumentNode;
36 variables?: TVariables;
37 operationName?: string;
38 context?: DefaultContext;
39 extensions?: Record<string, any>;
40}
41export interface Operation {
42 query: DocumentNode;
43 variables: Record<string, any>;
44 operationName: string;
45 extensions: Record<string, any>;
46 setContext: {
47 (context: Partial<DefaultContext>): void;
48 (updateContext: (previousContext: DefaultContext) => Partial<DefaultContext>): void;
49 };
50 getContext: () => DefaultContext;
51}
52export interface SingleExecutionResult<TData = Record<string, any>, TContext = DefaultContext, TExtensions = Record<string, any>> {
53 data?: TData | null;
54 context?: TContext;
55 errors?: ReadonlyArray<GraphQLFormattedError>;
56 extensions?: TExtensions;
57}
58export type FetchResult<TData = Record<string, any>, TContext = Record<string, any>, TExtensions = Record<string, any>> = SingleExecutionResult<TData, TContext, TExtensions> | ExecutionPatchResult<TData, TExtensions>;
59export type NextLink = (operation: Operation) => Observable<FetchResult>;
60export type RequestHandler = (operation: Operation, forward: NextLink) => Observable<FetchResult> | null;
61//# sourceMappingURL=types.d.ts.map
\No newline at end of file