UNPKG

2.31 kBTypeScriptView Raw
1import { ASTNode, GraphQLError, GraphQLFormattedError, Source, SourceLocation } from 'graphql';
2declare module 'graphql' {
3 interface GraphQLErrorExtensions {
4 exception?: {
5 code?: string;
6 stacktrace?: ReadonlyArray<string>;
7 };
8 }
9}
10export declare class ApolloError extends Error implements GraphQLError {
11 extensions: Record<string, any>;
12 readonly name: string;
13 readonly locations: ReadonlyArray<SourceLocation> | undefined;
14 readonly path: ReadonlyArray<string | number> | undefined;
15 readonly source: Source | undefined;
16 readonly positions: ReadonlyArray<number> | undefined;
17 readonly nodes: ReadonlyArray<ASTNode> | undefined;
18 originalError: Error | undefined;
19 [key: string]: any;
20 constructor(message: string, code?: string, extensions?: Record<string, any>);
21 toJSON(): GraphQLFormattedError;
22 toString(): string;
23 get [Symbol.toStringTag](): string;
24}
25export declare function toApolloError(error: Error & {
26 extensions?: Record<string, any>;
27}, code?: string): Error & {
28 extensions: Record<string, any>;
29};
30export interface ErrorOptions {
31 code?: string;
32 errorClass?: new (message: string) => ApolloError;
33}
34export declare function fromGraphQLError(error: GraphQLError, options?: ErrorOptions): ApolloError;
35export declare class SyntaxError extends ApolloError {
36 constructor(message: string);
37}
38export declare class ValidationError extends ApolloError {
39 constructor(message: string);
40}
41export declare class AuthenticationError extends ApolloError {
42 constructor(message: string, extensions?: Record<string, any>);
43}
44export declare class ForbiddenError extends ApolloError {
45 constructor(message: string, extensions?: Record<string, any>);
46}
47export declare class PersistedQueryNotFoundError extends ApolloError {
48 constructor();
49}
50export declare class PersistedQueryNotSupportedError extends ApolloError {
51 constructor();
52}
53export declare class UserInputError extends ApolloError {
54 constructor(message: string, extensions?: Record<string, any>);
55}
56export declare function formatApolloErrors(errors: ReadonlyArray<Error>, options?: {
57 formatter?: (error: GraphQLError) => GraphQLFormattedError;
58 debug?: boolean;
59}): Array<ApolloError>;
60//# sourceMappingURL=index.d.ts.map
\No newline at end of file