diff options
author | Minteck <contact@minteck.org> | 2023-01-10 14:54:04 +0100 |
---|---|---|
committer | Minteck <contact@minteck.org> | 2023-01-10 14:54:04 +0100 |
commit | 99c1d9af689e5325f3cf535c4007b3aeb8325229 (patch) | |
tree | e663b3c2ebdbd67c818ac0c5147f0ce1d2463cda /school/node_modules/graphql/error | |
parent | 9871b03912fc28ad38b4037ebf26a78aa937baba (diff) | |
download | pluralconnect-99c1d9af689e5325f3cf535c4007b3aeb8325229.tar.gz pluralconnect-99c1d9af689e5325f3cf535c4007b3aeb8325229.tar.bz2 pluralconnect-99c1d9af689e5325f3cf535c4007b3aeb8325229.zip |
Update - This is an automated commit
Diffstat (limited to 'school/node_modules/graphql/error')
20 files changed, 1153 insertions, 0 deletions
diff --git a/school/node_modules/graphql/error/GraphQLError.d.ts b/school/node_modules/graphql/error/GraphQLError.d.ts new file mode 100644 index 0000000..95f39ba --- /dev/null +++ b/school/node_modules/graphql/error/GraphQLError.d.ts @@ -0,0 +1,91 @@ +import { Maybe } from '../jsutils/Maybe'; + +import { ASTNode } from '../language/ast'; +import { Source } from '../language/source'; +import { SourceLocation } from '../language/location'; + +/** + * Custom extensions + * + * @remarks + * Use a unique identifier name for your extension, for example the name of + * your library or project. Do not use a shortened identifier as this increases + * the risk of conflicts. We recommend you add at most one extension field, + * an object which can contain all the values you need. + */ +export interface GraphQLErrorExtensions { + [attributeName: string]: any; +} + +/** + * 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?: Maybe<ReadonlyArray<ASTNode> | ASTNode>, + source?: Maybe<Source>, + positions?: Maybe<ReadonlyArray<number>>, + path?: Maybe<ReadonlyArray<string | number>>, + originalError?: Maybe<Error>, + extensions?: Maybe<GraphQLErrorExtensions>, + ); + + /** + * 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: Error | undefined | null; + + /** + * Extension fields to add to the formatted error. + */ + readonly extensions: { [key: string]: any }; +} + +/** + * Prints a GraphQLError to a string, representing useful location information + * about the error's position in the source. + */ +export function printError(error: GraphQLError): string; diff --git a/school/node_modules/graphql/error/GraphQLError.js b/school/node_modules/graphql/error/GraphQLError.js new file mode 100644 index 0000000..e4c6b8d --- /dev/null +++ b/school/node_modules/graphql/error/GraphQLError.js @@ -0,0 +1,252 @@ +"use strict"; + +function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.printError = printError; +exports.GraphQLError = void 0; + +var _isObjectLike = _interopRequireDefault(require("../jsutils/isObjectLike.js")); + +var _symbols = require("../polyfills/symbols.js"); + +var _location = require("../language/location.js"); + +var _printLocation = require("../language/printLocation.js"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _wrapNativeSuper(Class) { var _cache = typeof Map === "function" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== "function") { throw new TypeError("Super expression must either be null or a function"); } if (typeof _cache !== "undefined") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); } + +function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct; } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); } + +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } + +function _isNativeFunction(fn) { return Function.toString.call(fn).indexOf("[native code]") !== -1; } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +/** + * 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. + */ +var GraphQLError = /*#__PURE__*/function (_Error) { + _inherits(GraphQLError, _Error); + + var _super = _createSuper(GraphQLError); + + /** + * 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(). + */ + + /** + * 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(). + */ + + /** + * An array of GraphQL AST Nodes corresponding to this error. + */ + + /** + * 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. + */ + + /** + * An array of character offsets within the source GraphQL document + * which correspond to this error. + */ + + /** + * The original error thrown from a field resolver during execution. + */ + + /** + * Extension fields to add to the formatted error. + */ + function GraphQLError(message, nodes, source, positions, path, originalError, extensions) { + var _nodeLocations, _nodeLocations2, _nodeLocations3; + + var _this; + + _classCallCheck(this, GraphQLError); + + _this = _super.call(this, message); + _this.name = 'GraphQLError'; + _this.originalError = originalError !== null && originalError !== void 0 ? originalError : undefined; // Compute list of blame nodes. + + _this.nodes = undefinedIfEmpty(Array.isArray(nodes) ? nodes : nodes ? [nodes] : undefined); + var nodeLocations = []; + + for (var _i2 = 0, _ref3 = (_this$nodes = _this.nodes) !== null && _this$nodes !== void 0 ? _this$nodes : []; _i2 < _ref3.length; _i2++) { + var _this$nodes; + + var _ref4 = _ref3[_i2]; + var loc = _ref4.loc; + + if (loc != null) { + nodeLocations.push(loc); + } + } + + nodeLocations = undefinedIfEmpty(nodeLocations); // Compute locations in the source for the given nodes/positions. + + _this.source = source !== null && source !== void 0 ? source : (_nodeLocations = nodeLocations) === null || _nodeLocations === void 0 ? void 0 : _nodeLocations[0].source; + _this.positions = positions !== null && positions !== void 0 ? positions : (_nodeLocations2 = nodeLocations) === null || _nodeLocations2 === void 0 ? void 0 : _nodeLocations2.map(function (loc) { + return loc.start; + }); + _this.locations = positions && source ? positions.map(function (pos) { + return (0, _location.getLocation)(source, pos); + }) : (_nodeLocations3 = nodeLocations) === null || _nodeLocations3 === void 0 ? void 0 : _nodeLocations3.map(function (loc) { + return (0, _location.getLocation)(loc.source, loc.start); + }); + _this.path = path !== null && path !== void 0 ? path : undefined; + var originalExtensions = originalError === null || originalError === void 0 ? void 0 : originalError.extensions; + + if (extensions == null && (0, _isObjectLike.default)(originalExtensions)) { + _this.extensions = _objectSpread({}, originalExtensions); + } else { + _this.extensions = extensions !== null && extensions !== void 0 ? extensions : {}; + } // By being enumerable, JSON.stringify will include bellow properties in the resulting output. + // This ensures that the simplest possible GraphQL service adheres to the spec. + + + Object.defineProperties(_assertThisInitialized(_this), { + message: { + enumerable: true + }, + locations: { + enumerable: _this.locations != null + }, + path: { + enumerable: _this.path != null + }, + extensions: { + enumerable: _this.extensions != null && Object.keys(_this.extensions).length > 0 + }, + name: { + enumerable: false + }, + nodes: { + enumerable: false + }, + source: { + enumerable: false + }, + positions: { + enumerable: false + }, + originalError: { + enumerable: false + } + }); // Include (non-enumerable) stack trace. + + if (originalError !== null && originalError !== void 0 && originalError.stack) { + Object.defineProperty(_assertThisInitialized(_this), 'stack', { + value: originalError.stack, + writable: true, + configurable: true + }); + return _possibleConstructorReturn(_this); + } // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2317') + + + if (Error.captureStackTrace) { + Error.captureStackTrace(_assertThisInitialized(_this), GraphQLError); + } else { + Object.defineProperty(_assertThisInitialized(_this), 'stack', { + value: Error().stack, + writable: true, + configurable: true + }); + } + + return _this; + } + + _createClass(GraphQLError, [{ + key: "toString", + value: function toString() { + return printError(this); + } // FIXME: workaround to not break chai comparisons, should be remove in v16 + // $FlowFixMe[unsupported-syntax] Flow doesn't support computed properties yet + + }, { + key: _symbols.SYMBOL_TO_STRING_TAG, + get: function get() { + return 'Object'; + } + }]); + + return GraphQLError; +}( /*#__PURE__*/_wrapNativeSuper(Error)); + +exports.GraphQLError = GraphQLError; + +function undefinedIfEmpty(array) { + return array === undefined || array.length === 0 ? undefined : array; +} +/** + * 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 _i4 = 0, _error$nodes2 = error.nodes; _i4 < _error$nodes2.length; _i4++) { + var node = _error$nodes2[_i4]; + + if (node.loc) { + output += '\n\n' + (0, _printLocation.printLocation)(node.loc); + } + } + } else if (error.source && error.locations) { + for (var _i6 = 0, _error$locations2 = error.locations; _i6 < _error$locations2.length; _i6++) { + var location = _error$locations2[_i6]; + output += '\n\n' + (0, _printLocation.printSourceLocation)(error.source, location); + } + } + + return output; +} diff --git a/school/node_modules/graphql/error/GraphQLError.js.flow b/school/node_modules/graphql/error/GraphQLError.js.flow new file mode 100644 index 0000000..3d23ca5 --- /dev/null +++ b/school/node_modules/graphql/error/GraphQLError.js.flow @@ -0,0 +1,194 @@ +// @flow strict +import isObjectLike from '../jsutils/isObjectLike'; +import { SYMBOL_TO_STRING_TAG } from '../polyfills/symbols'; + +import type { ASTNode } from '../language/ast'; +import type { Source } from '../language/source'; +import type { SourceLocation } from '../language/location'; +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 class GraphQLError extends Error { + /** + * 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 | void | null; + + /** + * Extension fields to add to the formatted error. + */ + +extensions: { [key: string]: mixed, ... }; + + constructor( + message: string, + nodes?: $ReadOnlyArray<ASTNode> | ASTNode | void | null, + source?: ?Source, + positions?: ?$ReadOnlyArray<number>, + path?: ?$ReadOnlyArray<string | number>, + originalError?: ?(Error & { +extensions?: mixed, ... }), + extensions?: ?{ [key: string]: mixed, ... }, + ) { + super(message); + + this.name = 'GraphQLError'; + this.originalError = originalError ?? undefined; + + // Compute list of blame nodes. + this.nodes = undefinedIfEmpty( + Array.isArray(nodes) ? nodes : nodes ? [nodes] : undefined, + ); + + let nodeLocations = []; + for (const { loc } of this.nodes ?? []) { + if (loc != null) { + nodeLocations.push(loc); + } + } + nodeLocations = undefinedIfEmpty(nodeLocations); + + // Compute locations in the source for the given nodes/positions. + this.source = source ?? nodeLocations?.[0].source; + + this.positions = positions ?? nodeLocations?.map((loc) => loc.start); + + this.locations = + positions && source + ? positions.map((pos) => getLocation(source, pos)) + : nodeLocations?.map((loc) => getLocation(loc.source, loc.start)); + + this.path = path ?? undefined; + + const originalExtensions = originalError?.extensions; + + if (extensions == null && isObjectLike(originalExtensions)) { + this.extensions = { ...originalExtensions }; + } else { + this.extensions = extensions ?? {}; + } + + // By being enumerable, JSON.stringify will include bellow properties in the resulting output. + // This ensures that the simplest possible GraphQL service adheres to the spec. + Object.defineProperties((this: any), { + message: { enumerable: true }, + locations: { + enumerable: this.locations != null, + }, + path: { + enumerable: this.path != null, + }, + extensions: { + enumerable: + this.extensions != null && Object.keys(this.extensions).length > 0, + }, + name: { enumerable: false }, + nodes: { enumerable: false }, + source: { enumerable: false }, + positions: { enumerable: false }, + originalError: { enumerable: false }, + }); + + // Include (non-enumerable) stack trace. + if (originalError?.stack) { + Object.defineProperty(this, 'stack', { + value: originalError.stack, + writable: true, + configurable: true, + }); + return; + } + + // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2317') + if (Error.captureStackTrace) { + Error.captureStackTrace(this, GraphQLError); + } else { + Object.defineProperty(this, 'stack', { + value: Error().stack, + writable: true, + configurable: true, + }); + } + } + + toString(): string { + return printError(this); + } + + // FIXME: workaround to not break chai comparisons, should be remove in v16 + // $FlowFixMe[unsupported-syntax] Flow doesn't support computed properties yet + get [SYMBOL_TO_STRING_TAG](): string { + return 'Object'; + } +} + +function undefinedIfEmpty<T>( + array: $ReadOnlyArray<T> | void, +): $ReadOnlyArray<T> | void { + return array === undefined || array.length === 0 ? undefined : array; +} + +/** + * 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; +} diff --git a/school/node_modules/graphql/error/GraphQLError.mjs b/school/node_modules/graphql/error/GraphQLError.mjs new file mode 100644 index 0000000..34a30cc --- /dev/null +++ b/school/node_modules/graphql/error/GraphQLError.mjs @@ -0,0 +1,237 @@ +function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _wrapNativeSuper(Class) { var _cache = typeof Map === "function" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== "function") { throw new TypeError("Super expression must either be null or a function"); } if (typeof _cache !== "undefined") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); } + +function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct; } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); } + +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } + +function _isNativeFunction(fn) { return Function.toString.call(fn).indexOf("[native code]") !== -1; } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +import isObjectLike from "../jsutils/isObjectLike.mjs"; +import { SYMBOL_TO_STRING_TAG } from "../polyfills/symbols.mjs"; +import { getLocation } from "../language/location.mjs"; +import { printLocation, printSourceLocation } from "../language/printLocation.mjs"; +/** + * 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 var GraphQLError = /*#__PURE__*/function (_Error) { + _inherits(GraphQLError, _Error); + + var _super = _createSuper(GraphQLError); + + /** + * 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(). + */ + + /** + * 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(). + */ + + /** + * An array of GraphQL AST Nodes corresponding to this error. + */ + + /** + * 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. + */ + + /** + * An array of character offsets within the source GraphQL document + * which correspond to this error. + */ + + /** + * The original error thrown from a field resolver during execution. + */ + + /** + * Extension fields to add to the formatted error. + */ + function GraphQLError(message, nodes, source, positions, path, originalError, extensions) { + var _nodeLocations, _nodeLocations2, _nodeLocations3; + + var _this; + + _classCallCheck(this, GraphQLError); + + _this = _super.call(this, message); + _this.name = 'GraphQLError'; + _this.originalError = originalError !== null && originalError !== void 0 ? originalError : undefined; // Compute list of blame nodes. + + _this.nodes = undefinedIfEmpty(Array.isArray(nodes) ? nodes : nodes ? [nodes] : undefined); + var nodeLocations = []; + + for (var _i2 = 0, _ref3 = (_this$nodes = _this.nodes) !== null && _this$nodes !== void 0 ? _this$nodes : []; _i2 < _ref3.length; _i2++) { + var _this$nodes; + + var _ref4 = _ref3[_i2]; + var loc = _ref4.loc; + + if (loc != null) { + nodeLocations.push(loc); + } + } + + nodeLocations = undefinedIfEmpty(nodeLocations); // Compute locations in the source for the given nodes/positions. + + _this.source = source !== null && source !== void 0 ? source : (_nodeLocations = nodeLocations) === null || _nodeLocations === void 0 ? void 0 : _nodeLocations[0].source; + _this.positions = positions !== null && positions !== void 0 ? positions : (_nodeLocations2 = nodeLocations) === null || _nodeLocations2 === void 0 ? void 0 : _nodeLocations2.map(function (loc) { + return loc.start; + }); + _this.locations = positions && source ? positions.map(function (pos) { + return getLocation(source, pos); + }) : (_nodeLocations3 = nodeLocations) === null || _nodeLocations3 === void 0 ? void 0 : _nodeLocations3.map(function (loc) { + return getLocation(loc.source, loc.start); + }); + _this.path = path !== null && path !== void 0 ? path : undefined; + var originalExtensions = originalError === null || originalError === void 0 ? void 0 : originalError.extensions; + + if (extensions == null && isObjectLike(originalExtensions)) { + _this.extensions = _objectSpread({}, originalExtensions); + } else { + _this.extensions = extensions !== null && extensions !== void 0 ? extensions : {}; + } // By being enumerable, JSON.stringify will include bellow properties in the resulting output. + // This ensures that the simplest possible GraphQL service adheres to the spec. + + + Object.defineProperties(_assertThisInitialized(_this), { + message: { + enumerable: true + }, + locations: { + enumerable: _this.locations != null + }, + path: { + enumerable: _this.path != null + }, + extensions: { + enumerable: _this.extensions != null && Object.keys(_this.extensions).length > 0 + }, + name: { + enumerable: false + }, + nodes: { + enumerable: false + }, + source: { + enumerable: false + }, + positions: { + enumerable: false + }, + originalError: { + enumerable: false + } + }); // Include (non-enumerable) stack trace. + + if (originalError !== null && originalError !== void 0 && originalError.stack) { + Object.defineProperty(_assertThisInitialized(_this), 'stack', { + value: originalError.stack, + writable: true, + configurable: true + }); + return _possibleConstructorReturn(_this); + } // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2317') + + + if (Error.captureStackTrace) { + Error.captureStackTrace(_assertThisInitialized(_this), GraphQLError); + } else { + Object.defineProperty(_assertThisInitialized(_this), 'stack', { + value: Error().stack, + writable: true, + configurable: true + }); + } + + return _this; + } + + _createClass(GraphQLError, [{ + key: "toString", + value: function toString() { + return printError(this); + } // FIXME: workaround to not break chai comparisons, should be remove in v16 + // $FlowFixMe[unsupported-syntax] Flow doesn't support computed properties yet + + }, { + key: SYMBOL_TO_STRING_TAG, + get: function get() { + return 'Object'; + } + }]); + + return GraphQLError; +}( /*#__PURE__*/_wrapNativeSuper(Error)); + +function undefinedIfEmpty(array) { + return array === undefined || array.length === 0 ? undefined : array; +} +/** + * 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 _i4 = 0, _error$nodes2 = error.nodes; _i4 < _error$nodes2.length; _i4++) { + var node = _error$nodes2[_i4]; + + if (node.loc) { + output += '\n\n' + printLocation(node.loc); + } + } + } else if (error.source && error.locations) { + for (var _i6 = 0, _error$locations2 = error.locations; _i6 < _error$locations2.length; _i6++) { + var location = _error$locations2[_i6]; + output += '\n\n' + printSourceLocation(error.source, location); + } + } + + return output; +} diff --git a/school/node_modules/graphql/error/formatError.d.ts b/school/node_modules/graphql/error/formatError.d.ts new file mode 100644 index 0000000..fb3451b --- /dev/null +++ b/school/node_modules/graphql/error/formatError.d.ts @@ -0,0 +1,40 @@ +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; +} diff --git a/school/node_modules/graphql/error/formatError.js b/school/node_modules/graphql/error/formatError.js new file mode 100644 index 0000000..1e620fc --- /dev/null +++ b/school/node_modules/graphql/error/formatError.js @@ -0,0 +1,37 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.formatError = formatError; + +var _devAssert = _interopRequireDefault(require("../jsutils/devAssert.js")); + +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) { + var _error$message; + + error || (0, _devAssert.default)(0, 'Received null or undefined error.'); + var message = (_error$message = error.message) !== null && _error$message !== void 0 ? _error$message : 'An unknown error occurred.'; + var locations = error.locations; + var path = error.path; + var extensions = error.extensions; + return extensions && Object.keys(extensions).length > 0 ? { + 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 + */ diff --git a/school/node_modules/graphql/error/formatError.js.flow b/school/node_modules/graphql/error/formatError.js.flow new file mode 100644 index 0000000..0ca934b --- /dev/null +++ b/school/node_modules/graphql/error/formatError.js.flow @@ -0,0 +1,51 @@ +// @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 && Object.keys(extensions).length > 0 + ? { 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, ... }, +|}; diff --git a/school/node_modules/graphql/error/formatError.mjs b/school/node_modules/graphql/error/formatError.mjs new file mode 100644 index 0000000..0da3f5e --- /dev/null +++ b/school/node_modules/graphql/error/formatError.mjs @@ -0,0 +1,28 @@ +import devAssert from "../jsutils/devAssert.mjs"; + +/** + * Given a GraphQLError, format it according to the rules described by the + * Response Format, Errors section of the GraphQL Specification. + */ +export function formatError(error) { + var _error$message; + + error || devAssert(0, 'Received null or undefined error.'); + var message = (_error$message = error.message) !== null && _error$message !== void 0 ? _error$message : 'An unknown error occurred.'; + var locations = error.locations; + var path = error.path; + var extensions = error.extensions; + return extensions && Object.keys(extensions).length > 0 ? { + 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 + */ diff --git a/school/node_modules/graphql/error/index.d.ts b/school/node_modules/graphql/error/index.d.ts new file mode 100644 index 0000000..38f7b7e --- /dev/null +++ b/school/node_modules/graphql/error/index.d.ts @@ -0,0 +1,8 @@ +export { + GraphQLError, + GraphQLErrorExtensions, + printError, +} from './GraphQLError'; +export { syntaxError } from './syntaxError'; +export { locatedError } from './locatedError'; +export { formatError, GraphQLFormattedError } from './formatError'; diff --git a/school/node_modules/graphql/error/index.js b/school/node_modules/graphql/error/index.js new file mode 100644 index 0000000..ee164b8 --- /dev/null +++ b/school/node_modules/graphql/error/index.js @@ -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.js"); + +var _syntaxError = require("./syntaxError.js"); + +var _locatedError = require("./locatedError.js"); + +var _formatError = require("./formatError.js"); diff --git a/school/node_modules/graphql/error/index.js.flow b/school/node_modules/graphql/error/index.js.flow new file mode 100644 index 0000000..eeaa96e --- /dev/null +++ b/school/node_modules/graphql/error/index.js.flow @@ -0,0 +1,9 @@ +// @flow strict +export { GraphQLError, printError } from './GraphQLError'; + +export { syntaxError } from './syntaxError'; + +export { locatedError } from './locatedError'; + +export { formatError } from './formatError'; +export type { GraphQLFormattedError } from './formatError'; diff --git a/school/node_modules/graphql/error/index.mjs b/school/node_modules/graphql/error/index.mjs new file mode 100644 index 0000000..5ac29d1 --- /dev/null +++ b/school/node_modules/graphql/error/index.mjs @@ -0,0 +1,4 @@ +export { GraphQLError, printError } from "./GraphQLError.mjs"; +export { syntaxError } from "./syntaxError.mjs"; +export { locatedError } from "./locatedError.mjs"; +export { formatError } from "./formatError.mjs"; diff --git a/school/node_modules/graphql/error/locatedError.d.ts b/school/node_modules/graphql/error/locatedError.d.ts new file mode 100644 index 0000000..8693757 --- /dev/null +++ b/school/node_modules/graphql/error/locatedError.d.ts @@ -0,0 +1,16 @@ +import { Maybe } from '../jsutils/Maybe'; + +import { ASTNode } from '../language/ast'; + +import { GraphQLError } from './GraphQLError'; + +/** + * Given an arbitrary value, 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( + rawOriginalError: any, + nodes: ASTNode | ReadonlyArray<ASTNode> | undefined, + path?: Maybe<ReadonlyArray<string | number>>, +): GraphQLError; diff --git a/school/node_modules/graphql/error/locatedError.js b/school/node_modules/graphql/error/locatedError.js new file mode 100644 index 0000000..658c439 --- /dev/null +++ b/school/node_modules/graphql/error/locatedError.js @@ -0,0 +1,30 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.locatedError = locatedError; + +var _inspect = _interopRequireDefault(require("../jsutils/inspect.js")); + +var _GraphQLError = require("./GraphQLError.js"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/** + * Given an arbitrary value, 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(rawOriginalError, nodes, path) { + var _nodes; + + // Sometimes a non-error is thrown, wrap it as an Error instance to ensure a consistent Error interface. + var originalError = rawOriginalError instanceof Error ? rawOriginalError : new Error('Unexpected error value: ' + (0, _inspect.default)(rawOriginalError)); // Note: this uses a brand-check to support GraphQL errors originating from other contexts. + + if (Array.isArray(originalError.path)) { + return originalError; + } + + return new _GraphQLError.GraphQLError(originalError.message, (_nodes = originalError.nodes) !== null && _nodes !== void 0 ? _nodes : nodes, originalError.source, originalError.positions, path, originalError); +} diff --git a/school/node_modules/graphql/error/locatedError.js.flow b/school/node_modules/graphql/error/locatedError.js.flow new file mode 100644 index 0000000..3ef40c8 --- /dev/null +++ b/school/node_modules/graphql/error/locatedError.js.flow @@ -0,0 +1,37 @@ +// @flow strict +import inspect from '../jsutils/inspect'; + +import type { ASTNode } from '../language/ast'; + +import { GraphQLError } from './GraphQLError'; + +/** + * Given an arbitrary value, 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( + rawOriginalError: mixed, + nodes: ASTNode | $ReadOnlyArray<ASTNode> | void | null, + path?: ?$ReadOnlyArray<string | number>, +): GraphQLError { + // Sometimes a non-error is thrown, wrap it as an Error instance to ensure a consistent Error interface. + const originalError: Error | GraphQLError = + rawOriginalError instanceof Error + ? rawOriginalError + : new Error('Unexpected error value: ' + inspect(rawOriginalError)); + + // Note: this uses a brand-check to support GraphQL errors originating from other contexts. + if (Array.isArray(originalError.path)) { + return (originalError: any); + } + + return new GraphQLError( + originalError.message, + (originalError: any).nodes ?? nodes, + (originalError: any).source, + (originalError: any).positions, + path, + originalError, + ); +} diff --git a/school/node_modules/graphql/error/locatedError.mjs b/school/node_modules/graphql/error/locatedError.mjs new file mode 100644 index 0000000..48f4d54 --- /dev/null +++ b/school/node_modules/graphql/error/locatedError.mjs @@ -0,0 +1,20 @@ +import inspect from "../jsutils/inspect.mjs"; +import { GraphQLError } from "./GraphQLError.mjs"; +/** + * Given an arbitrary value, 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(rawOriginalError, nodes, path) { + var _nodes; + + // Sometimes a non-error is thrown, wrap it as an Error instance to ensure a consistent Error interface. + var originalError = rawOriginalError instanceof Error ? rawOriginalError : new Error('Unexpected error value: ' + inspect(rawOriginalError)); // Note: this uses a brand-check to support GraphQL errors originating from other contexts. + + if (Array.isArray(originalError.path)) { + return originalError; + } + + return new GraphQLError(originalError.message, (_nodes = originalError.nodes) !== null && _nodes !== void 0 ? _nodes : nodes, originalError.source, originalError.positions, path, originalError); +} diff --git a/school/node_modules/graphql/error/syntaxError.d.ts b/school/node_modules/graphql/error/syntaxError.d.ts new file mode 100644 index 0000000..1c5413c --- /dev/null +++ b/school/node_modules/graphql/error/syntaxError.d.ts @@ -0,0 +1,13 @@ +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; diff --git a/school/node_modules/graphql/error/syntaxError.js b/school/node_modules/graphql/error/syntaxError.js new file mode 100644 index 0000000..4804584 --- /dev/null +++ b/school/node_modules/graphql/error/syntaxError.js @@ -0,0 +1,16 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.syntaxError = syntaxError; + +var _GraphQLError = require("./GraphQLError.js"); + +/** + * 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]); +} diff --git a/school/node_modules/graphql/error/syntaxError.js.flow b/school/node_modules/graphql/error/syntaxError.js.flow new file mode 100644 index 0000000..cdddcc3 --- /dev/null +++ b/school/node_modules/graphql/error/syntaxError.js.flow @@ -0,0 +1,18 @@ +// @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, + ]); +} diff --git a/school/node_modules/graphql/error/syntaxError.mjs b/school/node_modules/graphql/error/syntaxError.mjs new file mode 100644 index 0000000..33aae5a --- /dev/null +++ b/school/node_modules/graphql/error/syntaxError.mjs @@ -0,0 +1,9 @@ +import { GraphQLError } from "./GraphQLError.mjs"; +/** + * 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]); +} |