graphql-tools-monorepo / utils/src / GraphQLError
Class: GraphQLError
utils/src.GraphQLError
Hierarchy
-
GraphQLError↳
GraphQLError
Table of contents
Constructors
Properties
- cause
- coordinate
- extensions
- locations
- message
- name
- nodes
- originalError
- path
- positions
- source
- stack
- stackTraceLimit
Accessors
Methods
Constructors
constructor
• new GraphQLError(message, options?): GraphQLError
Parameters
| Name | Type |
|---|---|
message | string |
options? | GraphQLErrorOptions |
Returns
Overrides
_GraphQLError.constructor
Defined in
packages/utils/src/errors.ts:31
• new GraphQLError(...args): GraphQLError
Parameters
| Name | Type |
|---|---|
...args | [message: string, nodes?: null | ASTNode | readonly ASTNode[], source?: Maybe<Source>, positions?: Maybe<readonly number[]>, path?: Maybe<readonly (string | number)[]>, originalError?: Maybe<Error & Object>, extensions?: Maybe<GraphQLErrorExtensions>] |
Returns
Overrides
_GraphQLError.constructor
Defined in
packages/utils/src/errors.ts:32
Properties
cause
• Optional cause: unknown
Inherited from
_GraphQLError.cause
Defined in
node_modules/typescript/lib/lib.es2022.error.d.ts:26
coordinate
• Optional coordinate: string
Coordinate in the schema of the field which is the source of this error (type.field)
Note: This is an experimental RFC proposal (https://github.com/graphql/graphql-spec/pull/1200 )
Defined in
packages/utils/src/errors.ts:29
extensions
• Readonly extensions: GraphQLErrorExtensions
Extension fields to add to the formatted error.
Inherited from
_GraphQLError.extensions
Defined in
node_modules/graphql/error/GraphQLError.d.ts:89
locations
• Readonly locations: undefined | readonly SourceLocation[]
An array of { line, column } locations within the source GraphQL document
which correspond to this error.
Errors during validation often contain multiple locations, for example to point out two things with the same name. Errors during execution include a single location, the field which produced the error.
Enumerable, and appears in the result of JSON.stringify().
Inherited from
_GraphQLError.locations
Defined in
node_modules/graphql/error/GraphQLError.d.ts:58
message
• message: string
Inherited from
_GraphQLError.message
Defined in
node_modules/typescript/lib/lib.es5.d.ts:1077
name
• name: string
Inherited from
_GraphQLError.name
Defined in
node_modules/typescript/lib/lib.es5.d.ts:1076
nodes
• Readonly nodes: undefined | readonly ASTNode[]
An array of GraphQL AST Nodes corresponding to this error.
Inherited from
_GraphQLError.nodes
Defined in
node_modules/graphql/error/GraphQLError.d.ts:69
originalError
• Readonly originalError: undefined | Error
The original error thrown from a field resolver during execution.
Inherited from
_GraphQLError.originalError
Defined in
node_modules/graphql/error/GraphQLError.d.ts:85
path
• Readonly path: undefined | readonly (string | number)[]
An array describing the JSON-path into the execution response which corresponds to this error. Only included for errors during execution.
Enumerable, and appears in the result of JSON.stringify().
Inherited from
_GraphQLError.path
Defined in
node_modules/graphql/error/GraphQLError.d.ts:65
positions
• Readonly positions: undefined | readonly number[]
An array of character offsets within the source GraphQL document which correspond to this error.
Inherited from
_GraphQLError.positions
Defined in
node_modules/graphql/error/GraphQLError.d.ts:81
source
• Readonly source: undefined | Source
The source GraphQL document for the first location of this error.
Note that if this Error represents more than one node, the source may not represent nodes after the first node.
Inherited from
_GraphQLError.source
Defined in
node_modules/graphql/error/GraphQLError.d.ts:76
stack
• Optional stack: string
Inherited from
_GraphQLError.stack
Defined in
node_modules/typescript/lib/lib.es5.d.ts:1078
stackTraceLimit
▪ Static stackTraceLimit: number
The Error.stackTraceLimit property specifies the number of stack frames
collected by a stack trace (whether generated by new Error().stack or
Error.captureStackTrace(obj)).
The default value is 10 but may be set to any valid JavaScript number. Changes
will affect any stack trace captured after the value has been changed.
If set to a non-number value, or set to a negative number, stack traces will not capture any frames.
Inherited from
_GraphQLError.stackTraceLimit
Defined in
node_modules/@types/node/globals.d.ts:68
Accessors
[toStringTag]
• get [toStringTag](): string
Returns
string
Inherited from
_GraphQLError.[toStringTag]
Defined in
node_modules/graphql/error/GraphQLError.d.ts:107
Methods
toJSON
▸ toJSON(): GraphQLFormattedError
Returns
GraphQLFormattedError
Inherited from
_GraphQLError.toJSON
Defined in
node_modules/graphql/error/GraphQLError.d.ts:109
toString
▸ toString(): string
Returns
string
Inherited from
_GraphQLError.toString
Defined in
node_modules/graphql/error/GraphQLError.d.ts:108
captureStackTrace
▸ captureStackTrace(targetObject, constructorOpt?): void
Creates a .stack property on targetObject, which when accessed returns
a string representing the location in the code at which
Error.captureStackTrace() was called.
const myObject = {};
Error.captureStackTrace(myObject);
myObject.stack; // Similar to `new Error().stack`The first line of the trace will be prefixed with
${myObject.name}: ${myObject.message}.
The optional constructorOpt argument accepts a function. If given, all frames
above constructorOpt, including constructorOpt, will be omitted from the
generated stack trace.
The constructorOpt argument is useful for hiding implementation
details of error generation from the user. For instance:
function a() {
b();
}
function b() {
c();
}
function c() {
// Create an error without stack trace to avoid calculating the stack trace twice.
const { stackTraceLimit } = Error;
Error.stackTraceLimit = 0;
const error = new Error();
Error.stackTraceLimit = stackTraceLimit;
// Capture the stack trace above function b
Error.captureStackTrace(error, b); // Neither function c, nor b is included in the stack trace
throw error;
}
a();Parameters
| Name | Type |
|---|---|
targetObject | object |
constructorOpt? | Function |
Returns
void
Inherited from
_GraphQLError.captureStackTrace
Defined in
node_modules/@types/node/globals.d.ts:52
isError
▸ isError(error): error is Error
Indicates whether the argument provided is a built-in Error instance or not.
Parameters
| Name | Type |
|---|---|
error | unknown |
Returns
error is Error
Inherited from
_GraphQLError.isError
Defined in
node_modules/typescript/lib/lib.esnext.error.d.ts:23
prepareStackTrace
▸ prepareStackTrace(err, stackTraces): any
Parameters
| Name | Type |
|---|---|
err | Error |
stackTraces | CallSite[] |
Returns
any
See
https://v8.dev/docs/stack-trace-api#customizing-stack-traces
Inherited from
_GraphQLError.prepareStackTrace
Defined in
node_modules/@types/node/globals.d.ts:56