1 | import { SourceLocation } from '../language/location';
|
2 | import { GraphQLError } from './GraphQLError';
|
3 |
|
4 | /**
|
5 | * Given a GraphQLError, format it according to the rules described by the
|
6 | * Response Format, Errors section of the GraphQL Specification.
|
7 | */
|
8 | export function formatError(error: GraphQLError): GraphQLFormattedError;
|
9 |
|
10 | /**
|
11 | * @see https://github.com/graphql/graphql-spec/blob/master/spec/Section%207%20--%20Response.md#errors
|
12 | */
|
13 | export interface GraphQLFormattedError<
|
14 | TExtensions extends Record<string, any> = Record<string, any>
|
15 | > {
|
16 | /**
|
17 | * A short, human-readable summary of the problem that **SHOULD NOT** change
|
18 | * from occurrence to occurrence of the problem, except for purposes of
|
19 | * localization.
|
20 | */
|
21 | readonly message: string;
|
22 | /**
|
23 | * If an error can be associated to a particular point in the requested
|
24 | * GraphQL document, it should contain a list of locations.
|
25 | */
|
26 | readonly locations?: ReadonlyArray<SourceLocation>;
|
27 | /**
|
28 | * If an error can be associated to a particular field in the GraphQL result,
|
29 | * it _must_ contain an entry with the key `path` that details the path of
|
30 | * the response field which experienced the error. This allows clients to
|
31 | * identify whether a null result is intentional or caused by a runtime error.
|
32 | */
|
33 | readonly path?: ReadonlyArray<string | number>;
|
34 | /**
|
35 | * Reserved for implementors to extend the protocol however they see fit,
|
36 | * and hence there are no additional restrictions on its contents.
|
37 | */
|
38 | readonly extensions?: TExtensions;
|
39 | }
|