UNPKG

2.44 kBTypeScriptView Raw
1import "../utilities/globals/index.js";
2import type { GraphQLError, GraphQLErrorExtensions, GraphQLFormattedError } from "graphql";
3import type { ServerParseError } from "../link/http/index.js";
4import type { ServerError } from "../link/utils/index.js";
5import type { FetchResult } from "../link/core/index.js";
6export declare const PROTOCOL_ERRORS_SYMBOL: unique symbol;
7type FetchResultWithSymbolExtensions<T> = FetchResult<T> & {
8 extensions: Record<string | symbol, any>;
9};
10export interface ApolloErrorOptions {
11 graphQLErrors?: ReadonlyArray<GraphQLFormattedError>;
12 protocolErrors?: ReadonlyArray<{
13 message: string;
14 extensions?: GraphQLErrorExtensions[];
15 }>;
16 clientErrors?: ReadonlyArray<Error>;
17 networkError?: Error | ServerParseError | ServerError | null;
18 errorMessage?: string;
19 extraInfo?: any;
20}
21export declare function graphQLResultHasProtocolErrors<T>(result: FetchResult<T>): result is FetchResultWithSymbolExtensions<T>;
22export declare function isApolloError(err: Error): err is ApolloError;
23/**
24 * @deprecated This type is deprecated and will be removed in the next major version of Apollo Client.
25 * It mistakenly referenced `GraqhQLError` instead of `GraphQLFormattedError`.
26 *
27 * Use `ReadonlyArray<GraphQLFormattedError>` instead.
28 */
29export type GraphQLErrors = ReadonlyArray<GraphQLError>;
30export type NetworkError = Error | ServerParseError | ServerError | null;
31export declare class ApolloError extends Error {
32 name: string;
33 message: string;
34 graphQLErrors: ReadonlyArray<GraphQLFormattedError>;
35 protocolErrors: ReadonlyArray<{
36 message: string;
37 extensions?: GraphQLErrorExtensions[];
38 }>;
39 clientErrors: ReadonlyArray<Error>;
40 networkError: Error | ServerParseError | ServerError | null;
41 /**
42 * Indicates the specific original cause of the error.
43 *
44 * This field contains the first available `networkError`, `graphQLError`, `protocolError`, `clientError`, or `null` if none are available.
45 */
46 cause: ({
47 readonly message: string;
48 extensions?: GraphQLErrorExtensions[] | GraphQLFormattedError["extensions"];
49 } & Omit<Partial<Error> & Partial<GraphQLFormattedError>, "extensions">) | null;
50 extraInfo: any;
51 constructor({ graphQLErrors, protocolErrors, clientErrors, networkError, errorMessage, extraInfo, }: ApolloErrorOptions);
52}
53export {};
54//# sourceMappingURL=index.d.ts.map
\No newline at end of file