|
4 | 4 |
|
5 | 5 | ```ts |
6 | 6 |
|
7 | | -import type { GraphQLError } from 'graphql'; |
8 | | -import type { GraphQLErrorExtensions } from 'graphql'; |
| 7 | +import type { ApolloLink } from '@apollo/client/link'; |
| 8 | +import { ErrorLike } from '@apollo/client'; |
| 9 | +import type { FormattedExecutionResult } from 'graphql'; |
9 | 10 | import type { GraphQLFormattedError } from 'graphql'; |
10 | 11 |
|
11 | 12 | // @public (undocumented) |
12 | | -export class ApolloError extends Error { |
13 | | - constructor({ graphQLErrors, protocolErrors, clientErrors, networkError, errorMessage, extraInfo, }: ApolloErrorOptions); |
14 | | - cause: ({ |
15 | | - readonly message: string; |
16 | | - extensions?: GraphQLErrorExtensions[] | GraphQLFormattedError["extensions"]; |
17 | | - } & Omit<Partial<Error> & Partial<GraphQLFormattedError>, "extensions">) | null; |
18 | | - // (undocumented) |
19 | | - clientErrors: ReadonlyArray<Error>; |
20 | | - // (undocumented) |
21 | | - extraInfo: any; |
22 | | - // (undocumented) |
23 | | - graphQLErrors: ReadonlyArray<GraphQLFormattedError>; |
24 | | - // (undocumented) |
25 | | - message: string; |
26 | | - // (undocumented) |
27 | | - name: string; |
28 | | - // Warning: (ae-forgotten-export) The symbol "ServerParseError" needs to be exported by the entry point index.d.ts |
29 | | - // Warning: (ae-forgotten-export) The symbol "ServerError" needs to be exported by the entry point index.d.ts |
30 | | - // |
31 | | - // (undocumented) |
32 | | - networkError: Error | ServerParseError | ServerError | null; |
33 | | - // (undocumented) |
34 | | - protocolErrors: ReadonlyArray<GraphQLFormattedError>; |
| 13 | +export namespace CombinedGraphQLErrors { |
| 14 | + // (undocumented) |
| 15 | + export namespace DocumentationTypes { |
| 16 | + export function formatMessage(errors: ReadonlyArray<GraphQLFormattedError>, options: MessageFormatterOptions): string; |
| 17 | + // (undocumented) |
| 18 | + export interface InstanceProperties { |
| 19 | + readonly data: Record<string, unknown> | null | undefined; |
| 20 | + readonly errors: ReadonlyArray<GraphQLFormattedError>; |
| 21 | + readonly extensions: Record<string, unknown> | undefined; |
| 22 | + } |
| 23 | + export function is(error: unknown): boolean; |
| 24 | + } |
| 25 | + export type MessageFormatter = (errors: ReadonlyArray<GraphQLFormattedError>, options: MessageFormatterOptions) => string; |
| 26 | + // (undocumented) |
| 27 | + export interface MessageFormatterOptions { |
| 28 | + defaultFormatMessage: (errors: ReadonlyArray<GraphQLFormattedError>) => string; |
| 29 | + result: ApolloLink.Result<unknown>; |
| 30 | + } |
35 | 31 | } |
36 | 32 |
|
37 | | -// @public (undocumented) |
38 | | -export interface ApolloErrorOptions { |
39 | | - // (undocumented) |
40 | | - clientErrors?: ReadonlyArray<Error>; |
41 | | - // (undocumented) |
42 | | - errorMessage?: string; |
43 | | - // (undocumented) |
44 | | - extraInfo?: any; |
45 | | - // (undocumented) |
46 | | - graphQLErrors?: ReadonlyArray<GraphQLFormattedError>; |
47 | | - // (undocumented) |
48 | | - networkError?: Error | ServerParseError | ServerError | null; |
49 | | - // (undocumented) |
50 | | - protocolErrors?: ReadonlyArray<GraphQLFormattedError>; |
| 33 | +// @public |
| 34 | +export class CombinedGraphQLErrors extends Error { |
| 35 | + constructor(result: FormattedExecutionResult<any>); |
| 36 | + constructor(result: ApolloLink.Result<any>, errors: ReadonlyArray<GraphQLFormattedError>); |
| 37 | + readonly data: Record<string, unknown> | null | undefined; |
| 38 | + readonly errors: ReadonlyArray<GraphQLFormattedError>; |
| 39 | + readonly extensions: Record<string, unknown> | undefined; |
| 40 | + static formatMessage: CombinedGraphQLErrors.MessageFormatter; |
| 41 | + static is(error: unknown): error is CombinedGraphQLErrors; |
51 | 42 | } |
52 | 43 |
|
53 | 44 | // @public (undocumented) |
54 | | -interface DefaultContext extends Record<string, any> { |
| 45 | +export namespace CombinedProtocolErrors { |
| 46 | + // (undocumented) |
| 47 | + export namespace DocumentationTypes { |
| 48 | + export function formatMessage(errors: ReadonlyArray<GraphQLFormattedError>, options: MessageFormatterOptions): string; |
| 49 | + // (undocumented) |
| 50 | + export interface InstanceProperties { |
| 51 | + readonly errors: ReadonlyArray<GraphQLFormattedError>; |
| 52 | + } |
| 53 | + } |
| 54 | + export type MessageFormatter = (errors: ReadonlyArray<GraphQLFormattedError>, options: MessageFormatterOptions) => string; |
| 55 | + // (undocumented) |
| 56 | + export interface MessageFormatterOptions { |
| 57 | + defaultFormatMessage: (errors: ReadonlyArray<GraphQLFormattedError>) => string; |
| 58 | + } |
55 | 59 | } |
56 | 60 |
|
57 | | -// Warning: (ae-forgotten-export) The symbol "ExecutionPatchResultBase" needs to be exported by the entry point index.d.ts |
58 | | -// |
59 | | -// @public @deprecated (undocumented) |
60 | | -interface ExecutionPatchIncrementalResult<TData = Record<string, any>, TExtensions = Record<string, any>> extends ExecutionPatchResultBase { |
61 | | - // (undocumented) |
62 | | - data?: never; |
63 | | - // (undocumented) |
64 | | - errors?: never; |
65 | | - // (undocumented) |
66 | | - extensions?: never; |
67 | | - // Warning: (ae-forgotten-export) The symbol "IncrementalPayload" needs to be exported by the entry point index.d.ts |
68 | | - // |
69 | | - // (undocumented) |
70 | | - incremental?: IncrementalPayload<TData, TExtensions>[]; |
| 61 | +// @public |
| 62 | +export class CombinedProtocolErrors extends Error { |
| 63 | + constructor(protocolErrors: Array<GraphQLFormattedError> | ReadonlyArray<GraphQLFormattedError>); |
| 64 | + readonly errors: ReadonlyArray<GraphQLFormattedError>; |
| 65 | + static formatMessage: CombinedProtocolErrors.MessageFormatter; |
| 66 | + static is(error: unknown): error is CombinedProtocolErrors; |
71 | 67 | } |
72 | 68 |
|
73 | | -// @public @deprecated (undocumented) |
74 | | -interface ExecutionPatchInitialResult<TData = Record<string, any>, TExtensions = Record<string, any>> extends ExecutionPatchResultBase { |
75 | | - // (undocumented) |
76 | | - data: TData | null | undefined; |
77 | | - // (undocumented) |
78 | | - errors?: ReadonlyArray<GraphQLFormattedError>; |
79 | | - // (undocumented) |
80 | | - extensions?: TExtensions; |
81 | | - // (undocumented) |
82 | | - incremental?: never; |
83 | | -} |
84 | | - |
85 | | -// Warning: (ae-forgotten-export) The symbol "ExecutionPatchInitialResult" needs to be exported by the entry point index.d.ts |
86 | | -// Warning: (ae-forgotten-export) The symbol "ExecutionPatchIncrementalResult" needs to be exported by the entry point index.d.ts |
87 | | -// |
88 | | -// @public @deprecated (undocumented) |
89 | | -type ExecutionPatchResult<TData = Record<string, any>, TExtensions = Record<string, any>> = ExecutionPatchInitialResult<TData, TExtensions> | ExecutionPatchIncrementalResult<TData, TExtensions>; |
90 | | - |
91 | 69 | // @public (undocumented) |
92 | | -interface ExecutionPatchResultBase { |
93 | | - // (undocumented) |
94 | | - hasNext?: boolean; |
95 | | -} |
| 70 | +export function graphQLResultHasProtocolErrors<T extends {}>(result: T): result is T & { |
| 71 | + extensions: Record<string | symbol, any>; |
| 72 | +}; |
96 | 73 |
|
97 | | -// Warning: (ae-forgotten-export) The symbol "SingleExecutionResult" needs to be exported by the entry point index.d.ts |
98 | | -// Warning: (ae-forgotten-export) The symbol "ExecutionPatchResult" needs to be exported by the entry point index.d.ts |
99 | | -// |
100 | 74 | // @public (undocumented) |
101 | | -type FetchResult<TData = Record<string, any>, TContext = Record<string, any>, TExtensions = Record<string, any>> = SingleExecutionResult<TData, TContext, TExtensions> | ExecutionPatchResult<TData, TExtensions>; |
| 75 | +export function isErrorLike(error: unknown): error is ErrorLike; |
102 | 76 |
|
103 | | -// Warning: (ae-forgotten-export) The symbol "FetchResult" needs to be exported by the entry point index.d.ts |
104 | | -// |
105 | | -// @public (undocumented) |
106 | | -type FetchResultWithSymbolExtensions<T> = FetchResult<T> & { |
107 | | - extensions: Record<string | symbol, any>; |
| 77 | +// @public |
| 78 | +export const LinkError: { |
| 79 | + is: (error: unknown) => boolean; |
108 | 80 | }; |
109 | 81 |
|
110 | | -// @public @deprecated (undocumented) |
111 | | -export type GraphQLErrors = ReadonlyArray<GraphQLError>; |
112 | | - |
113 | | -// Warning: (ae-forgotten-export) The symbol "FetchResultWithSymbolExtensions" needs to be exported by the entry point index.d.ts |
114 | | -// |
115 | 82 | // @public (undocumented) |
116 | | -export function graphQLResultHasProtocolErrors<T>(result: FetchResult<T>): result is FetchResultWithSymbolExtensions<T>; |
117 | | - |
118 | | -// @public @deprecated (undocumented) |
119 | | -interface IncrementalPayload<TData, TExtensions> { |
120 | | - // (undocumented) |
121 | | - data: TData | null; |
122 | | - // (undocumented) |
123 | | - errors?: ReadonlyArray<GraphQLFormattedError>; |
124 | | - // (undocumented) |
125 | | - extensions?: TExtensions; |
126 | | - // (undocumented) |
127 | | - label?: string; |
128 | | - // Warning: (ae-forgotten-export) The symbol "Path" needs to be exported by the entry point index.d.ts |
129 | | - // |
130 | | - // (undocumented) |
131 | | - path: Path; |
| 83 | +export namespace LocalStateError { |
| 84 | + // (undocumented) |
| 85 | + export namespace DocumentationTypes { |
| 86 | + // (undocumented) |
| 87 | + export interface InstanceProperties { |
| 88 | + readonly path?: Array<string | number>; |
| 89 | + } |
| 90 | + } |
| 91 | + // (undocumented) |
| 92 | + export interface Options { |
| 93 | + // (undocumented) |
| 94 | + path?: Array<string | number>; |
| 95 | + // (undocumented) |
| 96 | + sourceError?: unknown; |
| 97 | + } |
132 | 98 | } |
133 | 99 |
|
134 | | -// @public @deprecated (undocumented) |
135 | | -export function isApolloError(err: Error): err is ApolloError; |
| 100 | +// @public |
| 101 | +export class LocalStateError extends Error { |
| 102 | + constructor(message: string, options?: LocalStateError.Options); |
| 103 | + static is(error: unknown): error is LocalStateError; |
| 104 | + readonly path?: Array<string | number>; |
| 105 | +} |
136 | 106 |
|
137 | 107 | // @public (undocumented) |
138 | | -export type NetworkError = Error | ServerParseError | ServerError | null; |
| 108 | +export const PROTOCOL_ERRORS_SYMBOL: unique symbol; |
139 | 109 |
|
140 | | -// @public @deprecated (undocumented) |
141 | | -type Path = ReadonlyArray<string | number>; |
| 110 | +// @internal @deprecated |
| 111 | +export function registerLinkError(error: ErrorLike): void; |
142 | 112 |
|
143 | 113 | // @public (undocumented) |
144 | | -export const PROTOCOL_ERRORS_SYMBOL: unique symbol; |
| 114 | +export namespace ServerError { |
| 115 | + // (undocumented) |
| 116 | + export namespace DocumentationTypes { |
| 117 | + // (undocumented) |
| 118 | + export interface InstanceProperties { |
| 119 | + readonly bodyText: string; |
| 120 | + readonly response: Response; |
| 121 | + readonly statusCode: number; |
| 122 | + } |
| 123 | + } |
| 124 | + // (undocumented) |
| 125 | + export interface Options { |
| 126 | + // (undocumented) |
| 127 | + bodyText: string; |
| 128 | + // (undocumented) |
| 129 | + response: Response; |
| 130 | + } |
| 131 | +} |
145 | 132 |
|
146 | | -// @public (undocumented) |
147 | | -type ServerError = Error & { |
148 | | - response: Response; |
149 | | - result: Record<string, any> | string; |
150 | | - statusCode: number; |
151 | | -}; |
| 133 | +// @public |
| 134 | +export class ServerError extends Error { |
| 135 | + constructor(message: string, options: ServerError.Options); |
| 136 | + readonly bodyText: string; |
| 137 | + static is(error: unknown): error is ServerError; |
| 138 | + readonly response: Response; |
| 139 | + readonly statusCode: number; |
| 140 | +} |
152 | 141 |
|
153 | 142 | // @public (undocumented) |
154 | | -type ServerParseError = Error & { |
155 | | - response: Response; |
156 | | - statusCode: number; |
157 | | - bodyText: string; |
158 | | -}; |
| 143 | +export namespace ServerParseError { |
| 144 | + // (undocumented) |
| 145 | + export namespace DocumentationTypes { |
| 146 | + // (undocumented) |
| 147 | + export interface InstanceProperties { |
| 148 | + readonly bodyText: string; |
| 149 | + readonly response: Response; |
| 150 | + readonly statusCode: number; |
| 151 | + } |
| 152 | + } |
| 153 | + // (undocumented) |
| 154 | + export interface Options { |
| 155 | + // (undocumented) |
| 156 | + bodyText: string; |
| 157 | + // (undocumented) |
| 158 | + response: Response; |
| 159 | + } |
| 160 | +} |
| 161 | + |
| 162 | +// @public |
| 163 | +export class ServerParseError extends Error { |
| 164 | + constructor(originalParseError: unknown, options: ServerParseError.Options); |
| 165 | + readonly bodyText: string; |
| 166 | + static is(error: unknown): error is ServerParseError; |
| 167 | + readonly response: Response; |
| 168 | + readonly statusCode: number; |
| 169 | +} |
159 | 170 |
|
160 | | -// Warning: (ae-forgotten-export) The symbol "DefaultContext" needs to be exported by the entry point index.d.ts |
161 | | -// |
162 | 171 | // @public (undocumented) |
163 | | -interface SingleExecutionResult<TData = Record<string, any>, TContext = DefaultContext, TExtensions = Record<string, any>> { |
164 | | - // (undocumented) |
165 | | - context?: TContext; |
166 | | - // (undocumented) |
167 | | - data?: TData | null; |
168 | | - // (undocumented) |
169 | | - errors?: ReadonlyArray<GraphQLFormattedError>; |
170 | | - // (undocumented) |
171 | | - extensions?: TExtensions; |
| 172 | +export function toErrorLike(error: unknown): ErrorLike; |
| 173 | + |
| 174 | +// @public |
| 175 | +export class UnconventionalError extends Error { |
| 176 | + constructor(errorType: unknown); |
| 177 | + static is(error: unknown): error is UnconventionalError; |
172 | 178 | } |
173 | 179 |
|
174 | 180 | // (No @packageDocumentation comment for this package) |
|
0 commit comments