mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-19 08:31:17 +08:00
update graphql/error/* -> v0.13.2.
https://github.com/graphql/graphql-js/tree/v0.13.2/src/error
This commit is contained in:
29
types/graphql/error/GraphQLError.d.ts
vendored
29
types/graphql/error/GraphQLError.d.ts
vendored
@@ -1,6 +1,7 @@
|
||||
import { getLocation } from "../language";
|
||||
import { ASTNode } from "../language/ast";
|
||||
import { Source } from "../language/source";
|
||||
import { SourceLocation } from "../language/location";
|
||||
|
||||
/**
|
||||
* A GraphQLError describes an Error found during the parse, validate, or
|
||||
@@ -13,6 +14,8 @@ export class GraphQLError extends Error {
|
||||
* A message describing the Error for debugging purposes.
|
||||
*
|
||||
* Enumerable, and appears in the result of JSON.stringify().
|
||||
*
|
||||
* Note: should be treated as readonly, despite invariant usage.
|
||||
*/
|
||||
message: string;
|
||||
|
||||
@@ -26,7 +29,7 @@ export class GraphQLError extends Error {
|
||||
*
|
||||
* Enumerable, and appears in the result of JSON.stringify().
|
||||
*/
|
||||
locations?: Array<{ line: number; column: number }> | undefined;
|
||||
readonly locations: ReadonlyArray<SourceLocation> | undefined;
|
||||
|
||||
/**
|
||||
* An array describing the JSON-path into the execution response which
|
||||
@@ -34,41 +37,41 @@ export class GraphQLError extends Error {
|
||||
*
|
||||
* Enumerable, and appears in the result of JSON.stringify().
|
||||
*/
|
||||
path?: Array<string | number> | undefined;
|
||||
readonly path: ReadonlyArray<string | number> | undefined;
|
||||
|
||||
/**
|
||||
* An array of GraphQL AST Nodes corresponding to this error.
|
||||
*/
|
||||
nodes?: ASTNode[] | undefined;
|
||||
readonly nodes: ReadonlyArray<ASTNode> | undefined;
|
||||
|
||||
/**
|
||||
* The source GraphQL document corresponding to this error.
|
||||
*/
|
||||
source?: Source | undefined;
|
||||
readonly source: Source | undefined;
|
||||
|
||||
/**
|
||||
* An array of character offsets within the source GraphQL document
|
||||
* which correspond to this error.
|
||||
*/
|
||||
positions?: number[] | undefined;
|
||||
readonly positions: ReadonlyArray<number> | undefined;
|
||||
|
||||
/**
|
||||
* The original error thrown from a field resolver during execution.
|
||||
*/
|
||||
originalError?: Error;
|
||||
readonly originalError: Error | void;
|
||||
|
||||
/**
|
||||
* Extension fields to add to the formatted error.
|
||||
*/
|
||||
extensions?: { [key: string]: any } | undefined;
|
||||
readonly extensions: { [key: string]: any } | void;
|
||||
|
||||
constructor(
|
||||
message: string,
|
||||
nodes?: any[],
|
||||
source?: Source,
|
||||
positions?: number[],
|
||||
path?: Array<string | number>,
|
||||
originalError?: Error,
|
||||
extensions?: { [key: string]: any }
|
||||
nodes?: ReadonlyArray<ASTNode> | ASTNode | undefined,
|
||||
source?: Source | void,
|
||||
positions?: ReadonlyArray<number> | void,
|
||||
path?: ReadonlyArray<string | number> | void,
|
||||
originalError?: Error | void,
|
||||
extensions?: { [key: string]: any } | void
|
||||
);
|
||||
}
|
||||
|
||||
14
types/graphql/error/formatError.d.ts
vendored
14
types/graphql/error/formatError.d.ts
vendored
@@ -1,4 +1,5 @@
|
||||
import { GraphQLError } from "./GraphQLError";
|
||||
import { SourceLocation } from "../language/location";
|
||||
|
||||
/**
|
||||
* Given a GraphQLError, format it according to the rules described by the
|
||||
@@ -7,12 +8,9 @@ import { GraphQLError } from "./GraphQLError";
|
||||
export function formatError(error: GraphQLError): GraphQLFormattedError;
|
||||
|
||||
export interface GraphQLFormattedError {
|
||||
message: string;
|
||||
locations?: GraphQLErrorLocation[];
|
||||
path?: Array<string | number>;
|
||||
}
|
||||
|
||||
export interface GraphQLErrorLocation {
|
||||
line: number;
|
||||
column: number;
|
||||
readonly message: string;
|
||||
readonly locations: ReadonlyArray<SourceLocation> | undefined;
|
||||
readonly path: ReadonlyArray<string | number> | undefined;
|
||||
// Extensions
|
||||
readonly [key: string]: any;
|
||||
}
|
||||
|
||||
3
types/graphql/error/index.d.ts
vendored
3
types/graphql/error/index.d.ts
vendored
@@ -1,4 +1,5 @@
|
||||
export { GraphQLError } from "./GraphQLError";
|
||||
export { syntaxError } from "./syntaxError";
|
||||
export { locatedError } from "./locatedError";
|
||||
export { formatError, GraphQLFormattedError, GraphQLErrorLocation } from "./formatError";
|
||||
export { printError } from "./printError";
|
||||
export { formatError, GraphQLFormattedError } from "./formatError";
|
||||
|
||||
7
types/graphql/error/locatedError.d.ts
vendored
7
types/graphql/error/locatedError.d.ts
vendored
@@ -1,8 +1,13 @@
|
||||
import { GraphQLError } from "./GraphQLError";
|
||||
import { ASTNode } from "../language/ast";
|
||||
|
||||
/**
|
||||
* Given an arbitrary Error, presumably thrown while attempting to execute a
|
||||
* GraphQL operation, produce a new GraphQLError aware of the location in the
|
||||
* document responsible for the original Error.
|
||||
*/
|
||||
export function locatedError<T>(originalError: Error, nodes: T[], path: Array<string | number>): GraphQLError;
|
||||
export function locatedError(
|
||||
originalError: Error,
|
||||
nodes: ReadonlyArray<ASTNode>,
|
||||
path: ReadonlyArray<string | number>
|
||||
): GraphQLError;
|
||||
|
||||
7
types/graphql/error/printError.d.ts
vendored
Normal file
7
types/graphql/error/printError.d.ts
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
import { GraphQLError } from "./GraphQLError";
|
||||
|
||||
/**
|
||||
* Prints a GraphQLError to a string, representing useful location information
|
||||
* about the error's position in the source.
|
||||
*/
|
||||
export function printError(error: GraphQLError): string;
|
||||
Reference in New Issue
Block a user