Initial Save
This commit is contained in:
87
node_modules/graphql/error/GraphQLError.d.ts
generated
vendored
Normal file
87
node_modules/graphql/error/GraphQLError.d.ts
generated
vendored
Normal file
@@ -0,0 +1,87 @@
|
||||
import Maybe from '../tsutils/Maybe';
|
||||
|
||||
import { ASTNode } from '../language/ast';
|
||||
import { Source } from '../language/source';
|
||||
import { SourceLocation, getLocation } from '../language/location';
|
||||
|
||||
/**
|
||||
* A GraphQLError describes an Error found during the parse, validate, or
|
||||
* execute phases of performing a GraphQL operation. In addition to a message
|
||||
* and stack trace, it also includes information about the locations in a
|
||||
* GraphQL document and/or execution result that correspond to the Error.
|
||||
*/
|
||||
export class GraphQLError extends Error {
|
||||
constructor(
|
||||
message: string,
|
||||
nodes?: ReadonlyArray<ASTNode> | ASTNode | undefined,
|
||||
source?: Maybe<Source>,
|
||||
positions?: Maybe<ReadonlyArray<number>>,
|
||||
path?: Maybe<ReadonlyArray<string | number>>,
|
||||
originalError?: Maybe<Error>,
|
||||
extensions?: Maybe<{ [key: string]: any }>,
|
||||
);
|
||||
|
||||
/**
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* 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().
|
||||
*/
|
||||
readonly locations: ReadonlyArray<SourceLocation> | undefined;
|
||||
|
||||
/**
|
||||
* 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().
|
||||
*/
|
||||
readonly path: ReadonlyArray<string | number> | undefined;
|
||||
|
||||
/**
|
||||
* An array of GraphQL AST Nodes corresponding to this error.
|
||||
*/
|
||||
readonly nodes: ReadonlyArray<ASTNode> | undefined;
|
||||
|
||||
/**
|
||||
* The source GraphQL document corresponding to this error.
|
||||
*
|
||||
* Note that if this Error represents more than one node, the source may not
|
||||
* represent nodes after the first node.
|
||||
*/
|
||||
readonly source: Source | undefined;
|
||||
|
||||
/**
|
||||
* An array of character offsets within the source GraphQL document
|
||||
* which correspond to this error.
|
||||
*/
|
||||
readonly positions: ReadonlyArray<number> | undefined;
|
||||
|
||||
/**
|
||||
* The original error thrown from a field resolver during execution.
|
||||
*/
|
||||
readonly originalError: Maybe<Error>;
|
||||
|
||||
/**
|
||||
* Extension fields to add to the formatted error.
|
||||
*/
|
||||
readonly extensions: { [key: string]: any } | undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints a GraphQLError to a string, representing useful location information
|
||||
* about the error's position in the source.
|
||||
*/
|
||||
export function printError(error: GraphQLError): string;
|
||||
176
node_modules/graphql/error/GraphQLError.js
generated
vendored
Normal file
176
node_modules/graphql/error/GraphQLError.js
generated
vendored
Normal file
@@ -0,0 +1,176 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.GraphQLError = GraphQLError;
|
||||
exports.printError = printError;
|
||||
|
||||
var _isObjectLike = _interopRequireDefault(require("../jsutils/isObjectLike"));
|
||||
|
||||
var _location = require("../language/location");
|
||||
|
||||
var _printLocation = require("../language/printLocation");
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
function GraphQLError( // eslint-disable-line no-redeclare
|
||||
message, nodes, source, positions, path, originalError, extensions) {
|
||||
// Compute list of blame nodes.
|
||||
var _nodes = Array.isArray(nodes) ? nodes.length !== 0 ? nodes : undefined : nodes ? [nodes] : undefined; // Compute locations in the source for the given nodes/positions.
|
||||
|
||||
|
||||
var _source = source;
|
||||
|
||||
if (!_source && _nodes) {
|
||||
var node = _nodes[0];
|
||||
_source = node && node.loc && node.loc.source;
|
||||
}
|
||||
|
||||
var _positions = positions;
|
||||
|
||||
if (!_positions && _nodes) {
|
||||
_positions = _nodes.reduce(function (list, node) {
|
||||
if (node.loc) {
|
||||
list.push(node.loc.start);
|
||||
}
|
||||
|
||||
return list;
|
||||
}, []);
|
||||
}
|
||||
|
||||
if (_positions && _positions.length === 0) {
|
||||
_positions = undefined;
|
||||
}
|
||||
|
||||
var _locations;
|
||||
|
||||
if (positions && source) {
|
||||
_locations = positions.map(function (pos) {
|
||||
return (0, _location.getLocation)(source, pos);
|
||||
});
|
||||
} else if (_nodes) {
|
||||
_locations = _nodes.reduce(function (list, node) {
|
||||
if (node.loc) {
|
||||
list.push((0, _location.getLocation)(node.loc.source, node.loc.start));
|
||||
}
|
||||
|
||||
return list;
|
||||
}, []);
|
||||
}
|
||||
|
||||
var _extensions = extensions;
|
||||
|
||||
if (_extensions == null && originalError != null) {
|
||||
var originalExtensions = originalError.extensions;
|
||||
|
||||
if ((0, _isObjectLike.default)(originalExtensions)) {
|
||||
_extensions = originalExtensions;
|
||||
}
|
||||
}
|
||||
|
||||
Object.defineProperties(this, {
|
||||
message: {
|
||||
value: message,
|
||||
// By being enumerable, JSON.stringify will include `message` in the
|
||||
// resulting output. This ensures that the simplest possible GraphQL
|
||||
// service adheres to the spec.
|
||||
enumerable: true,
|
||||
writable: true
|
||||
},
|
||||
locations: {
|
||||
// Coercing falsey values to undefined ensures they will not be included
|
||||
// in JSON.stringify() when not provided.
|
||||
value: _locations || undefined,
|
||||
// By being enumerable, JSON.stringify will include `locations` in the
|
||||
// resulting output. This ensures that the simplest possible GraphQL
|
||||
// service adheres to the spec.
|
||||
enumerable: Boolean(_locations)
|
||||
},
|
||||
path: {
|
||||
// Coercing falsey values to undefined ensures they will not be included
|
||||
// in JSON.stringify() when not provided.
|
||||
value: path || undefined,
|
||||
// By being enumerable, JSON.stringify will include `path` in the
|
||||
// resulting output. This ensures that the simplest possible GraphQL
|
||||
// service adheres to the spec.
|
||||
enumerable: Boolean(path)
|
||||
},
|
||||
nodes: {
|
||||
value: _nodes || undefined
|
||||
},
|
||||
source: {
|
||||
value: _source || undefined
|
||||
},
|
||||
positions: {
|
||||
value: _positions || undefined
|
||||
},
|
||||
originalError: {
|
||||
value: originalError
|
||||
},
|
||||
extensions: {
|
||||
// Coercing falsey values to undefined ensures they will not be included
|
||||
// in JSON.stringify() when not provided.
|
||||
value: _extensions || undefined,
|
||||
// By being enumerable, JSON.stringify will include `path` in the
|
||||
// resulting output. This ensures that the simplest possible GraphQL
|
||||
// service adheres to the spec.
|
||||
enumerable: Boolean(_extensions)
|
||||
}
|
||||
}); // Include (non-enumerable) stack trace.
|
||||
|
||||
if (originalError && originalError.stack) {
|
||||
Object.defineProperty(this, 'stack', {
|
||||
value: originalError.stack,
|
||||
writable: true,
|
||||
configurable: true
|
||||
});
|
||||
} else if (Error.captureStackTrace) {
|
||||
Error.captureStackTrace(this, GraphQLError);
|
||||
} else {
|
||||
Object.defineProperty(this, 'stack', {
|
||||
value: Error().stack,
|
||||
writable: true,
|
||||
configurable: true
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
GraphQLError.prototype = Object.create(Error.prototype, {
|
||||
constructor: {
|
||||
value: GraphQLError
|
||||
},
|
||||
name: {
|
||||
value: 'GraphQLError'
|
||||
},
|
||||
toString: {
|
||||
value: function toString() {
|
||||
return printError(this);
|
||||
}
|
||||
}
|
||||
});
|
||||
/**
|
||||
* Prints a GraphQLError to a string, representing useful location information
|
||||
* about the error's position in the source.
|
||||
*/
|
||||
|
||||
function printError(error) {
|
||||
var output = error.message;
|
||||
|
||||
if (error.nodes) {
|
||||
for (var _i2 = 0, _error$nodes2 = error.nodes; _i2 < _error$nodes2.length; _i2++) {
|
||||
var node = _error$nodes2[_i2];
|
||||
|
||||
if (node.loc) {
|
||||
output += '\n\n' + (0, _printLocation.printLocation)(node.loc);
|
||||
}
|
||||
}
|
||||
} else if (error.source && error.locations) {
|
||||
for (var _i4 = 0, _error$locations2 = error.locations; _i4 < _error$locations2.length; _i4++) {
|
||||
var location = _error$locations2[_i4];
|
||||
output += '\n\n' + (0, _printLocation.printSourceLocation)(error.source, location);
|
||||
}
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
242
node_modules/graphql/error/GraphQLError.js.flow
generated
vendored
Normal file
242
node_modules/graphql/error/GraphQLError.js.flow
generated
vendored
Normal file
@@ -0,0 +1,242 @@
|
||||
// @flow strict
|
||||
|
||||
import isObjectLike from '../jsutils/isObjectLike';
|
||||
|
||||
import { type ASTNode } from '../language/ast';
|
||||
import { type Source } from '../language/source';
|
||||
import { type SourceLocation, getLocation } from '../language/location';
|
||||
import { printLocation, printSourceLocation } from '../language/printLocation';
|
||||
|
||||
/**
|
||||
* A GraphQLError describes an Error found during the parse, validate, or
|
||||
* execute phases of performing a GraphQL operation. In addition to a message
|
||||
* and stack trace, it also includes information about the locations in a
|
||||
* GraphQL document and/or execution result that correspond to the Error.
|
||||
*/
|
||||
declare class GraphQLError extends Error {
|
||||
constructor(
|
||||
message: string,
|
||||
nodes?: $ReadOnlyArray<ASTNode> | ASTNode | void | null,
|
||||
source?: ?Source,
|
||||
positions?: ?$ReadOnlyArray<number>,
|
||||
path?: ?$ReadOnlyArray<string | number>,
|
||||
originalError?: ?Error,
|
||||
extensions?: ?{ [key: string]: mixed, ... },
|
||||
): void;
|
||||
|
||||
/**
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* 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().
|
||||
*/
|
||||
+locations: $ReadOnlyArray<SourceLocation> | void;
|
||||
|
||||
/**
|
||||
* 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().
|
||||
*/
|
||||
+path: $ReadOnlyArray<string | number> | void;
|
||||
|
||||
/**
|
||||
* An array of GraphQL AST Nodes corresponding to this error.
|
||||
*/
|
||||
+nodes: $ReadOnlyArray<ASTNode> | void;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
+source: Source | void;
|
||||
|
||||
/**
|
||||
* An array of character offsets within the source GraphQL document
|
||||
* which correspond to this error.
|
||||
*/
|
||||
+positions: $ReadOnlyArray<number> | void;
|
||||
|
||||
/**
|
||||
* The original error thrown from a field resolver during execution.
|
||||
*/
|
||||
+originalError: ?Error;
|
||||
|
||||
/**
|
||||
* Extension fields to add to the formatted error.
|
||||
*/
|
||||
+extensions: { [key: string]: mixed, ... } | void;
|
||||
}
|
||||
|
||||
export function GraphQLError( // eslint-disable-line no-redeclare
|
||||
message: string,
|
||||
nodes?: $ReadOnlyArray<ASTNode> | ASTNode | void,
|
||||
source?: ?Source,
|
||||
positions?: ?$ReadOnlyArray<number>,
|
||||
path?: ?$ReadOnlyArray<string | number>,
|
||||
originalError?: ?Error & { +extensions: mixed, ... },
|
||||
extensions?: ?{ [key: string]: mixed, ... },
|
||||
) {
|
||||
// Compute list of blame nodes.
|
||||
const _nodes = Array.isArray(nodes)
|
||||
? nodes.length !== 0
|
||||
? nodes
|
||||
: undefined
|
||||
: nodes
|
||||
? [nodes]
|
||||
: undefined;
|
||||
|
||||
// Compute locations in the source for the given nodes/positions.
|
||||
let _source = source;
|
||||
if (!_source && _nodes) {
|
||||
const node = _nodes[0];
|
||||
_source = node && node.loc && node.loc.source;
|
||||
}
|
||||
|
||||
let _positions = positions;
|
||||
if (!_positions && _nodes) {
|
||||
_positions = _nodes.reduce((list, node) => {
|
||||
if (node.loc) {
|
||||
list.push(node.loc.start);
|
||||
}
|
||||
return list;
|
||||
}, []);
|
||||
}
|
||||
if (_positions && _positions.length === 0) {
|
||||
_positions = undefined;
|
||||
}
|
||||
|
||||
let _locations;
|
||||
if (positions && source) {
|
||||
_locations = positions.map(pos => getLocation(source, pos));
|
||||
} else if (_nodes) {
|
||||
_locations = _nodes.reduce((list, node) => {
|
||||
if (node.loc) {
|
||||
list.push(getLocation(node.loc.source, node.loc.start));
|
||||
}
|
||||
return list;
|
||||
}, []);
|
||||
}
|
||||
|
||||
let _extensions = extensions;
|
||||
if (_extensions == null && originalError != null) {
|
||||
const originalExtensions = originalError.extensions;
|
||||
if (isObjectLike(originalExtensions)) {
|
||||
_extensions = originalExtensions;
|
||||
}
|
||||
}
|
||||
|
||||
Object.defineProperties(this, {
|
||||
message: {
|
||||
value: message,
|
||||
// By being enumerable, JSON.stringify will include `message` in the
|
||||
// resulting output. This ensures that the simplest possible GraphQL
|
||||
// service adheres to the spec.
|
||||
enumerable: true,
|
||||
writable: true,
|
||||
},
|
||||
locations: {
|
||||
// Coercing falsey values to undefined ensures they will not be included
|
||||
// in JSON.stringify() when not provided.
|
||||
value: _locations || undefined,
|
||||
// By being enumerable, JSON.stringify will include `locations` in the
|
||||
// resulting output. This ensures that the simplest possible GraphQL
|
||||
// service adheres to the spec.
|
||||
enumerable: Boolean(_locations),
|
||||
},
|
||||
path: {
|
||||
// Coercing falsey values to undefined ensures they will not be included
|
||||
// in JSON.stringify() when not provided.
|
||||
value: path || undefined,
|
||||
// By being enumerable, JSON.stringify will include `path` in the
|
||||
// resulting output. This ensures that the simplest possible GraphQL
|
||||
// service adheres to the spec.
|
||||
enumerable: Boolean(path),
|
||||
},
|
||||
nodes: {
|
||||
value: _nodes || undefined,
|
||||
},
|
||||
source: {
|
||||
value: _source || undefined,
|
||||
},
|
||||
positions: {
|
||||
value: _positions || undefined,
|
||||
},
|
||||
originalError: {
|
||||
value: originalError,
|
||||
},
|
||||
extensions: {
|
||||
// Coercing falsey values to undefined ensures they will not be included
|
||||
// in JSON.stringify() when not provided.
|
||||
value: _extensions || undefined,
|
||||
// By being enumerable, JSON.stringify will include `path` in the
|
||||
// resulting output. This ensures that the simplest possible GraphQL
|
||||
// service adheres to the spec.
|
||||
enumerable: Boolean(_extensions),
|
||||
},
|
||||
});
|
||||
|
||||
// Include (non-enumerable) stack trace.
|
||||
if (originalError && originalError.stack) {
|
||||
Object.defineProperty(this, 'stack', {
|
||||
value: originalError.stack,
|
||||
writable: true,
|
||||
configurable: true,
|
||||
});
|
||||
} else if (Error.captureStackTrace) {
|
||||
Error.captureStackTrace(this, GraphQLError);
|
||||
} else {
|
||||
Object.defineProperty(this, 'stack', {
|
||||
value: Error().stack,
|
||||
writable: true,
|
||||
configurable: true,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
(GraphQLError: any).prototype = Object.create(Error.prototype, {
|
||||
constructor: { value: GraphQLError },
|
||||
name: { value: 'GraphQLError' },
|
||||
toString: {
|
||||
value: function toString() {
|
||||
return printError(this);
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
/**
|
||||
* Prints a GraphQLError to a string, representing useful location information
|
||||
* about the error's position in the source.
|
||||
*/
|
||||
export function printError(error: GraphQLError): string {
|
||||
let output = error.message;
|
||||
|
||||
if (error.nodes) {
|
||||
for (const node of error.nodes) {
|
||||
if (node.loc) {
|
||||
output += '\n\n' + printLocation(node.loc);
|
||||
}
|
||||
}
|
||||
} else if (error.source && error.locations) {
|
||||
for (const location of error.locations) {
|
||||
output += '\n\n' + printSourceLocation(error.source, location);
|
||||
}
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
169
node_modules/graphql/error/GraphQLError.mjs
generated
vendored
Normal file
169
node_modules/graphql/error/GraphQLError.mjs
generated
vendored
Normal file
@@ -0,0 +1,169 @@
|
||||
import isObjectLike from '../jsutils/isObjectLike';
|
||||
import { getLocation } from '../language/location';
|
||||
import { printLocation, printSourceLocation } from '../language/printLocation';
|
||||
/**
|
||||
* A GraphQLError describes an Error found during the parse, validate, or
|
||||
* execute phases of performing a GraphQL operation. In addition to a message
|
||||
* and stack trace, it also includes information about the locations in a
|
||||
* GraphQL document and/or execution result that correspond to the Error.
|
||||
*/
|
||||
|
||||
export function GraphQLError( // eslint-disable-line no-redeclare
|
||||
message, nodes, source, positions, path, originalError, extensions) {
|
||||
// Compute list of blame nodes.
|
||||
var _nodes = Array.isArray(nodes) ? nodes.length !== 0 ? nodes : undefined : nodes ? [nodes] : undefined; // Compute locations in the source for the given nodes/positions.
|
||||
|
||||
|
||||
var _source = source;
|
||||
|
||||
if (!_source && _nodes) {
|
||||
var node = _nodes[0];
|
||||
_source = node && node.loc && node.loc.source;
|
||||
}
|
||||
|
||||
var _positions = positions;
|
||||
|
||||
if (!_positions && _nodes) {
|
||||
_positions = _nodes.reduce(function (list, node) {
|
||||
if (node.loc) {
|
||||
list.push(node.loc.start);
|
||||
}
|
||||
|
||||
return list;
|
||||
}, []);
|
||||
}
|
||||
|
||||
if (_positions && _positions.length === 0) {
|
||||
_positions = undefined;
|
||||
}
|
||||
|
||||
var _locations;
|
||||
|
||||
if (positions && source) {
|
||||
_locations = positions.map(function (pos) {
|
||||
return getLocation(source, pos);
|
||||
});
|
||||
} else if (_nodes) {
|
||||
_locations = _nodes.reduce(function (list, node) {
|
||||
if (node.loc) {
|
||||
list.push(getLocation(node.loc.source, node.loc.start));
|
||||
}
|
||||
|
||||
return list;
|
||||
}, []);
|
||||
}
|
||||
|
||||
var _extensions = extensions;
|
||||
|
||||
if (_extensions == null && originalError != null) {
|
||||
var originalExtensions = originalError.extensions;
|
||||
|
||||
if (isObjectLike(originalExtensions)) {
|
||||
_extensions = originalExtensions;
|
||||
}
|
||||
}
|
||||
|
||||
Object.defineProperties(this, {
|
||||
message: {
|
||||
value: message,
|
||||
// By being enumerable, JSON.stringify will include `message` in the
|
||||
// resulting output. This ensures that the simplest possible GraphQL
|
||||
// service adheres to the spec.
|
||||
enumerable: true,
|
||||
writable: true
|
||||
},
|
||||
locations: {
|
||||
// Coercing falsey values to undefined ensures they will not be included
|
||||
// in JSON.stringify() when not provided.
|
||||
value: _locations || undefined,
|
||||
// By being enumerable, JSON.stringify will include `locations` in the
|
||||
// resulting output. This ensures that the simplest possible GraphQL
|
||||
// service adheres to the spec.
|
||||
enumerable: Boolean(_locations)
|
||||
},
|
||||
path: {
|
||||
// Coercing falsey values to undefined ensures they will not be included
|
||||
// in JSON.stringify() when not provided.
|
||||
value: path || undefined,
|
||||
// By being enumerable, JSON.stringify will include `path` in the
|
||||
// resulting output. This ensures that the simplest possible GraphQL
|
||||
// service adheres to the spec.
|
||||
enumerable: Boolean(path)
|
||||
},
|
||||
nodes: {
|
||||
value: _nodes || undefined
|
||||
},
|
||||
source: {
|
||||
value: _source || undefined
|
||||
},
|
||||
positions: {
|
||||
value: _positions || undefined
|
||||
},
|
||||
originalError: {
|
||||
value: originalError
|
||||
},
|
||||
extensions: {
|
||||
// Coercing falsey values to undefined ensures they will not be included
|
||||
// in JSON.stringify() when not provided.
|
||||
value: _extensions || undefined,
|
||||
// By being enumerable, JSON.stringify will include `path` in the
|
||||
// resulting output. This ensures that the simplest possible GraphQL
|
||||
// service adheres to the spec.
|
||||
enumerable: Boolean(_extensions)
|
||||
}
|
||||
}); // Include (non-enumerable) stack trace.
|
||||
|
||||
if (originalError && originalError.stack) {
|
||||
Object.defineProperty(this, 'stack', {
|
||||
value: originalError.stack,
|
||||
writable: true,
|
||||
configurable: true
|
||||
});
|
||||
} else if (Error.captureStackTrace) {
|
||||
Error.captureStackTrace(this, GraphQLError);
|
||||
} else {
|
||||
Object.defineProperty(this, 'stack', {
|
||||
value: Error().stack,
|
||||
writable: true,
|
||||
configurable: true
|
||||
});
|
||||
}
|
||||
}
|
||||
GraphQLError.prototype = Object.create(Error.prototype, {
|
||||
constructor: {
|
||||
value: GraphQLError
|
||||
},
|
||||
name: {
|
||||
value: 'GraphQLError'
|
||||
},
|
||||
toString: {
|
||||
value: function toString() {
|
||||
return printError(this);
|
||||
}
|
||||
}
|
||||
});
|
||||
/**
|
||||
* Prints a GraphQLError to a string, representing useful location information
|
||||
* about the error's position in the source.
|
||||
*/
|
||||
|
||||
export function printError(error) {
|
||||
var output = error.message;
|
||||
|
||||
if (error.nodes) {
|
||||
for (var _i2 = 0, _error$nodes2 = error.nodes; _i2 < _error$nodes2.length; _i2++) {
|
||||
var node = _error$nodes2[_i2];
|
||||
|
||||
if (node.loc) {
|
||||
output += '\n\n' + printLocation(node.loc);
|
||||
}
|
||||
}
|
||||
} else if (error.source && error.locations) {
|
||||
for (var _i4 = 0, _error$locations2 = error.locations; _i4 < _error$locations2.length; _i4++) {
|
||||
var location = _error$locations2[_i4];
|
||||
output += '\n\n' + printSourceLocation(error.source, location);
|
||||
}
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
39
node_modules/graphql/error/formatError.d.ts
generated
vendored
Normal file
39
node_modules/graphql/error/formatError.d.ts
generated
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
import { SourceLocation } from '../language/location';
|
||||
import { GraphQLError } from './GraphQLError';
|
||||
|
||||
/**
|
||||
* Given a GraphQLError, format it according to the rules described by the
|
||||
* Response Format, Errors section of the GraphQL Specification.
|
||||
*/
|
||||
export function formatError(error: GraphQLError): GraphQLFormattedError;
|
||||
|
||||
/**
|
||||
* @see https://github.com/graphql/graphql-spec/blob/master/spec/Section%207%20--%20Response.md#errors
|
||||
*/
|
||||
export interface GraphQLFormattedError<
|
||||
TExtensions extends Record<string, any> = Record<string, any>
|
||||
> {
|
||||
/**
|
||||
* A short, human-readable summary of the problem that **SHOULD NOT** change
|
||||
* from occurrence to occurrence of the problem, except for purposes of
|
||||
* localization.
|
||||
*/
|
||||
readonly message: string;
|
||||
/**
|
||||
* If an error can be associated to a particular point in the requested
|
||||
* GraphQL document, it should contain a list of locations.
|
||||
*/
|
||||
readonly locations?: ReadonlyArray<SourceLocation>;
|
||||
/**
|
||||
* If an error can be associated to a particular field in the GraphQL result,
|
||||
* it _must_ contain an entry with the key `path` that details the path of
|
||||
* the response field which experienced the error. This allows clients to
|
||||
* identify whether a null result is intentional or caused by a runtime error.
|
||||
*/
|
||||
readonly path?: ReadonlyArray<string | number>;
|
||||
/**
|
||||
* Reserved for implementors to extend the protocol however they see fit,
|
||||
* and hence there are no additional restrictions on its contents.
|
||||
*/
|
||||
readonly extensions?: TExtensions;
|
||||
}
|
||||
35
node_modules/graphql/error/formatError.js
generated
vendored
Normal file
35
node_modules/graphql/error/formatError.js
generated
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.formatError = formatError;
|
||||
|
||||
var _devAssert = _interopRequireDefault(require("../jsutils/devAssert"));
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
/**
|
||||
* Given a GraphQLError, format it according to the rules described by the
|
||||
* Response Format, Errors section of the GraphQL Specification.
|
||||
*/
|
||||
function formatError(error) {
|
||||
error || (0, _devAssert.default)(0, 'Received null or undefined error.');
|
||||
var message = error.message || 'An unknown error occurred.';
|
||||
var locations = error.locations;
|
||||
var path = error.path;
|
||||
var extensions = error.extensions;
|
||||
return extensions ? {
|
||||
message: message,
|
||||
locations: locations,
|
||||
path: path,
|
||||
extensions: extensions
|
||||
} : {
|
||||
message: message,
|
||||
locations: locations,
|
||||
path: path
|
||||
};
|
||||
}
|
||||
/**
|
||||
* @see https://github.com/graphql/graphql-spec/blob/master/spec/Section%207%20--%20Response.md#errors
|
||||
*/
|
||||
52
node_modules/graphql/error/formatError.js.flow
generated
vendored
Normal file
52
node_modules/graphql/error/formatError.js.flow
generated
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
// @flow strict
|
||||
|
||||
import devAssert from '../jsutils/devAssert';
|
||||
|
||||
import { type SourceLocation } from '../language/location';
|
||||
|
||||
import { type GraphQLError } from './GraphQLError';
|
||||
|
||||
/**
|
||||
* Given a GraphQLError, format it according to the rules described by the
|
||||
* Response Format, Errors section of the GraphQL Specification.
|
||||
*/
|
||||
export function formatError(error: GraphQLError): GraphQLFormattedError {
|
||||
devAssert(error, 'Received null or undefined error.');
|
||||
const message = error.message || 'An unknown error occurred.';
|
||||
const locations = error.locations;
|
||||
const path = error.path;
|
||||
const extensions = error.extensions;
|
||||
|
||||
return extensions
|
||||
? { message, locations, path, extensions }
|
||||
: { message, locations, path };
|
||||
}
|
||||
|
||||
/**
|
||||
* @see https://github.com/graphql/graphql-spec/blob/master/spec/Section%207%20--%20Response.md#errors
|
||||
*/
|
||||
export type GraphQLFormattedError = {|
|
||||
/**
|
||||
* A short, human-readable summary of the problem that **SHOULD NOT** change
|
||||
* from occurrence to occurrence of the problem, except for purposes of
|
||||
* localization.
|
||||
*/
|
||||
+message: string,
|
||||
/**
|
||||
* If an error can be associated to a particular point in the requested
|
||||
* GraphQL document, it should contain a list of locations.
|
||||
*/
|
||||
+locations: $ReadOnlyArray<SourceLocation> | void,
|
||||
/**
|
||||
* If an error can be associated to a particular field in the GraphQL result,
|
||||
* it _must_ contain an entry with the key `path` that details the path of
|
||||
* the response field which experienced the error. This allows clients to
|
||||
* identify whether a null result is intentional or caused by a runtime error.
|
||||
*/
|
||||
+path: $ReadOnlyArray<string | number> | void,
|
||||
/**
|
||||
* Reserved for implementors to extend the protocol however they see fit,
|
||||
* and hence there are no additional restrictions on its contents.
|
||||
*/
|
||||
+extensions?: { [key: string]: mixed, ... },
|
||||
|};
|
||||
26
node_modules/graphql/error/formatError.mjs
generated
vendored
Normal file
26
node_modules/graphql/error/formatError.mjs
generated
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
import devAssert from '../jsutils/devAssert';
|
||||
|
||||
/**
|
||||
* Given a GraphQLError, format it according to the rules described by the
|
||||
* Response Format, Errors section of the GraphQL Specification.
|
||||
*/
|
||||
export function formatError(error) {
|
||||
error || devAssert(0, 'Received null or undefined error.');
|
||||
var message = error.message || 'An unknown error occurred.';
|
||||
var locations = error.locations;
|
||||
var path = error.path;
|
||||
var extensions = error.extensions;
|
||||
return extensions ? {
|
||||
message: message,
|
||||
locations: locations,
|
||||
path: path,
|
||||
extensions: extensions
|
||||
} : {
|
||||
message: message,
|
||||
locations: locations,
|
||||
path: path
|
||||
};
|
||||
}
|
||||
/**
|
||||
* @see https://github.com/graphql/graphql-spec/blob/master/spec/Section%207%20--%20Response.md#errors
|
||||
*/
|
||||
4
node_modules/graphql/error/index.d.ts
generated
vendored
Normal file
4
node_modules/graphql/error/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
export { GraphQLError, printError } from './GraphQLError';
|
||||
export { syntaxError } from './syntaxError';
|
||||
export { locatedError } from './locatedError';
|
||||
export { formatError, GraphQLFormattedError } from './formatError';
|
||||
43
node_modules/graphql/error/index.js
generated
vendored
Normal file
43
node_modules/graphql/error/index.js
generated
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "GraphQLError", {
|
||||
enumerable: true,
|
||||
get: function get() {
|
||||
return _GraphQLError.GraphQLError;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "printError", {
|
||||
enumerable: true,
|
||||
get: function get() {
|
||||
return _GraphQLError.printError;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "syntaxError", {
|
||||
enumerable: true,
|
||||
get: function get() {
|
||||
return _syntaxError.syntaxError;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "locatedError", {
|
||||
enumerable: true,
|
||||
get: function get() {
|
||||
return _locatedError.locatedError;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "formatError", {
|
||||
enumerable: true,
|
||||
get: function get() {
|
||||
return _formatError.formatError;
|
||||
}
|
||||
});
|
||||
|
||||
var _GraphQLError = require("./GraphQLError");
|
||||
|
||||
var _syntaxError = require("./syntaxError");
|
||||
|
||||
var _locatedError = require("./locatedError");
|
||||
|
||||
var _formatError = require("./formatError");
|
||||
10
node_modules/graphql/error/index.js.flow
generated
vendored
Normal file
10
node_modules/graphql/error/index.js.flow
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
// @flow strict
|
||||
|
||||
export { GraphQLError, printError } from './GraphQLError';
|
||||
|
||||
export { syntaxError } from './syntaxError';
|
||||
|
||||
export { locatedError } from './locatedError';
|
||||
|
||||
export { formatError } from './formatError';
|
||||
export type { GraphQLFormattedError } from './formatError';
|
||||
4
node_modules/graphql/error/index.mjs
generated
vendored
Normal file
4
node_modules/graphql/error/index.mjs
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
export { GraphQLError, printError } from './GraphQLError';
|
||||
export { syntaxError } from './syntaxError';
|
||||
export { locatedError } from './locatedError';
|
||||
export { formatError } from './formatError';
|
||||
13
node_modules/graphql/error/locatedError.d.ts
generated
vendored
Normal file
13
node_modules/graphql/error/locatedError.d.ts
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
import { ASTNode } from '../language/ast';
|
||||
import { GraphQLError } from './GraphQLError';
|
||||
|
||||
/**
|
||||
* 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(
|
||||
originalError: Error | GraphQLError,
|
||||
nodes: ReadonlyArray<ASTNode>,
|
||||
path: ReadonlyArray<string | number>,
|
||||
): GraphQLError;
|
||||
23
node_modules/graphql/error/locatedError.js
generated
vendored
Normal file
23
node_modules/graphql/error/locatedError.js
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.locatedError = locatedError;
|
||||
|
||||
var _GraphQLError = require("./GraphQLError");
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
function locatedError(originalError, nodes, path) {
|
||||
// Note: this uses a brand-check to support GraphQL errors originating from
|
||||
// other contexts.
|
||||
if (originalError && Array.isArray(originalError.path)) {
|
||||
return originalError;
|
||||
}
|
||||
|
||||
return new _GraphQLError.GraphQLError(originalError && originalError.message, originalError && originalError.nodes || nodes, originalError && originalError.source, originalError && originalError.positions, path, originalError);
|
||||
}
|
||||
31
node_modules/graphql/error/locatedError.js.flow
generated
vendored
Normal file
31
node_modules/graphql/error/locatedError.js.flow
generated
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
// @flow strict
|
||||
|
||||
import { type ASTNode } from '../language/ast';
|
||||
|
||||
import { GraphQLError } from './GraphQLError';
|
||||
|
||||
/**
|
||||
* 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(
|
||||
originalError: Error | GraphQLError,
|
||||
nodes: $ReadOnlyArray<ASTNode>,
|
||||
path: $ReadOnlyArray<string | number>,
|
||||
): GraphQLError {
|
||||
// Note: this uses a brand-check to support GraphQL errors originating from
|
||||
// other contexts.
|
||||
if (originalError && Array.isArray(originalError.path)) {
|
||||
return (originalError: any);
|
||||
}
|
||||
|
||||
return new GraphQLError(
|
||||
originalError && originalError.message,
|
||||
(originalError && (originalError: any).nodes) || nodes,
|
||||
originalError && (originalError: any).source,
|
||||
originalError && (originalError: any).positions,
|
||||
path,
|
||||
originalError,
|
||||
);
|
||||
}
|
||||
16
node_modules/graphql/error/locatedError.mjs
generated
vendored
Normal file
16
node_modules/graphql/error/locatedError.mjs
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
import { GraphQLError } from './GraphQLError';
|
||||
/**
|
||||
* 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(originalError, nodes, path) {
|
||||
// Note: this uses a brand-check to support GraphQL errors originating from
|
||||
// other contexts.
|
||||
if (originalError && Array.isArray(originalError.path)) {
|
||||
return originalError;
|
||||
}
|
||||
|
||||
return new GraphQLError(originalError && originalError.message, originalError && originalError.nodes || nodes, originalError && originalError.source, originalError && originalError.positions, path, originalError);
|
||||
}
|
||||
12
node_modules/graphql/error/syntaxError.d.ts
generated
vendored
Normal file
12
node_modules/graphql/error/syntaxError.d.ts
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
import { Source } from '../language/source';
|
||||
import { GraphQLError } from './GraphQLError';
|
||||
|
||||
/**
|
||||
* Produces a GraphQLError representing a syntax error, containing useful
|
||||
* descriptive information about the syntax error's position in the source.
|
||||
*/
|
||||
export function syntaxError(
|
||||
source: Source,
|
||||
position: number,
|
||||
description: string,
|
||||
): GraphQLError;
|
||||
16
node_modules/graphql/error/syntaxError.js
generated
vendored
Normal file
16
node_modules/graphql/error/syntaxError.js
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.syntaxError = syntaxError;
|
||||
|
||||
var _GraphQLError = require("./GraphQLError");
|
||||
|
||||
/**
|
||||
* Produces a GraphQLError representing a syntax error, containing useful
|
||||
* descriptive information about the syntax error's position in the source.
|
||||
*/
|
||||
function syntaxError(source, position, description) {
|
||||
return new _GraphQLError.GraphQLError("Syntax Error: ".concat(description), undefined, source, [position]);
|
||||
}
|
||||
19
node_modules/graphql/error/syntaxError.js.flow
generated
vendored
Normal file
19
node_modules/graphql/error/syntaxError.js.flow
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
// @flow strict
|
||||
|
||||
import { type Source } from '../language/source';
|
||||
|
||||
import { GraphQLError } from './GraphQLError';
|
||||
|
||||
/**
|
||||
* Produces a GraphQLError representing a syntax error, containing useful
|
||||
* descriptive information about the syntax error's position in the source.
|
||||
*/
|
||||
export function syntaxError(
|
||||
source: Source,
|
||||
position: number,
|
||||
description: string,
|
||||
): GraphQLError {
|
||||
return new GraphQLError(`Syntax Error: ${description}`, undefined, source, [
|
||||
position,
|
||||
]);
|
||||
}
|
||||
9
node_modules/graphql/error/syntaxError.mjs
generated
vendored
Normal file
9
node_modules/graphql/error/syntaxError.mjs
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
import { GraphQLError } from './GraphQLError';
|
||||
/**
|
||||
* Produces a GraphQLError representing a syntax error, containing useful
|
||||
* descriptive information about the syntax error's position in the source.
|
||||
*/
|
||||
|
||||
export function syntaxError(source, position, description) {
|
||||
return new GraphQLError("Syntax Error: ".concat(description), undefined, source, [position]);
|
||||
}
|
||||
Reference in New Issue
Block a user