UNPKG

pluralsh-absinthe-socket-apollo-link

Version:
1,447 lines (1,219 loc) 705 kB
(function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof define === 'function' && define.amd ? define(['exports'], factory) : (factory((global.PluralshAbsintheSocketApolloLink = {}))); }(this, (function (exports) { 'use strict'; function unwrapExports (x) { return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x.default : x; } function createCommonjsModule(fn, module) { return module = { exports: {} }, fn(module, module.exports), module.exports; } var _global = createCommonjsModule(function (module) { // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028 var global = module.exports = typeof window != 'undefined' && window.Math == Math ? window : typeof self != 'undefined' && self.Math == Math ? self // eslint-disable-next-line no-new-func : Function('return this')(); if (typeof __g == 'number') __g = global; // eslint-disable-line no-undef }); var _core = createCommonjsModule(function (module) { var core = module.exports = { version: '2.6.0' }; if (typeof __e == 'number') __e = core; // eslint-disable-line no-undef }); var _core_1 = _core.version; var _isObject = function (it) { return typeof it === 'object' ? it !== null : typeof it === 'function'; }; var _anObject = function (it) { if (!_isObject(it)) throw TypeError(it + ' is not an object!'); return it; }; var _fails = function (exec) { try { return !!exec(); } catch (e) { return true; } }; // Thank's IE8 for his funny defineProperty var _descriptors = !_fails(function () { return Object.defineProperty({}, 'a', { get: function () { return 7; } }).a != 7; }); var document = _global.document; // typeof document.createElement is 'object' in old IE var is = _isObject(document) && _isObject(document.createElement); var _domCreate = function (it) { return is ? document.createElement(it) : {}; }; var _ie8DomDefine = !_descriptors && !_fails(function () { return Object.defineProperty(_domCreate('div'), 'a', { get: function () { return 7; } }).a != 7; }); // 7.1.1 ToPrimitive(input [, PreferredType]) // instead of the ES6 spec version, we didn't implement @@toPrimitive case // and the second argument - flag - preferred type is a string var _toPrimitive = function (it, S) { if (!_isObject(it)) return it; var fn, val; if (S && typeof (fn = it.toString) == 'function' && !_isObject(val = fn.call(it))) return val; if (typeof (fn = it.valueOf) == 'function' && !_isObject(val = fn.call(it))) return val; if (!S && typeof (fn = it.toString) == 'function' && !_isObject(val = fn.call(it))) return val; throw TypeError("Can't convert object to primitive value"); }; var dP = Object.defineProperty; var f = _descriptors ? Object.defineProperty : function defineProperty(O, P, Attributes) { _anObject(O); P = _toPrimitive(P, true); _anObject(Attributes); if (_ie8DomDefine) try { return dP(O, P, Attributes); } catch (e) { /* empty */ } if ('get' in Attributes || 'set' in Attributes) throw TypeError('Accessors not supported!'); if ('value' in Attributes) O[P] = Attributes.value; return O; }; var _objectDp = { f: f }; var _propertyDesc = function (bitmap, value) { return { enumerable: !(bitmap & 1), configurable: !(bitmap & 2), writable: !(bitmap & 4), value: value }; }; var _hide = _descriptors ? function (object, key, value) { return _objectDp.f(object, key, _propertyDesc(1, value)); } : function (object, key, value) { object[key] = value; return object; }; var hasOwnProperty = {}.hasOwnProperty; var _has = function (it, key) { return hasOwnProperty.call(it, key); }; var id = 0; var px = Math.random(); var _uid = function (key) { return 'Symbol('.concat(key === undefined ? '' : key, ')_', (++id + px).toString(36)); }; var _redefine = createCommonjsModule(function (module) { var SRC = _uid('src'); var TO_STRING = 'toString'; var $toString = Function[TO_STRING]; var TPL = ('' + $toString).split(TO_STRING); _core.inspectSource = function (it) { return $toString.call(it); }; (module.exports = function (O, key, val, safe) { var isFunction = typeof val == 'function'; if (isFunction) _has(val, 'name') || _hide(val, 'name', key); if (O[key] === val) return; if (isFunction) _has(val, SRC) || _hide(val, SRC, O[key] ? '' + O[key] : TPL.join(String(key))); if (O === _global) { O[key] = val; } else if (!safe) { delete O[key]; _hide(O, key, val); } else if (O[key]) { O[key] = val; } else { _hide(O, key, val); } // add fake Function#toString for correct work wrapped methods / constructors with methods like LoDash isNative })(Function.prototype, TO_STRING, function toString() { return typeof this == 'function' && this[SRC] || $toString.call(this); }); }); var _aFunction = function (it) { if (typeof it != 'function') throw TypeError(it + ' is not a function!'); return it; }; // optional / simple context binding var _ctx = function (fn, that, length) { _aFunction(fn); if (that === undefined) return fn; switch (length) { case 1: return function (a) { return fn.call(that, a); }; case 2: return function (a, b) { return fn.call(that, a, b); }; case 3: return function (a, b, c) { return fn.call(that, a, b, c); }; } return function (/* ...args */) { return fn.apply(that, arguments); }; }; var PROTOTYPE = 'prototype'; var $export = function (type, name, source) { var IS_FORCED = type & $export.F; var IS_GLOBAL = type & $export.G; var IS_STATIC = type & $export.S; var IS_PROTO = type & $export.P; var IS_BIND = type & $export.B; var target = IS_GLOBAL ? _global : IS_STATIC ? _global[name] || (_global[name] = {}) : (_global[name] || {})[PROTOTYPE]; var exports = IS_GLOBAL ? _core : _core[name] || (_core[name] = {}); var expProto = exports[PROTOTYPE] || (exports[PROTOTYPE] = {}); var key, own, out, exp; if (IS_GLOBAL) source = name; for (key in source) { // contains in native own = !IS_FORCED && target && target[key] !== undefined; // export native or passed out = (own ? target : source)[key]; // bind timers to global for call from export context exp = IS_BIND && own ? _ctx(out, _global) : IS_PROTO && typeof out == 'function' ? _ctx(Function.call, out) : out; // extend global if (target) _redefine(target, key, out, type & $export.U); // export if (exports[key] != out) _hide(exports, key, exp); if (IS_PROTO && expProto[key] != out) expProto[key] = out; } }; _global.core = _core; // type bitmap $export.F = 1; // forced $export.G = 2; // global $export.S = 4; // static $export.P = 8; // proto $export.B = 16; // bind $export.W = 32; // wrap $export.U = 64; // safe $export.R = 128; // real proto method for `library` var _export = $export; // fast apply, http://jsperf.lnkit.com/fast-apply/5 var _invoke = function (fn, args, that) { var un = that === undefined; switch (args.length) { case 0: return un ? fn() : fn.call(that); case 1: return un ? fn(args[0]) : fn.call(that, args[0]); case 2: return un ? fn(args[0], args[1]) : fn.call(that, args[0], args[1]); case 3: return un ? fn(args[0], args[1], args[2]) : fn.call(that, args[0], args[1], args[2]); case 4: return un ? fn(args[0], args[1], args[2], args[3]) : fn.call(that, args[0], args[1], args[2], args[3]); } return fn.apply(that, args); }; var arraySlice = [].slice; var factories = {}; var construct = function (F, len, args) { if (!(len in factories)) { for (var n = [], i = 0; i < len; i++) n[i] = 'a[' + i + ']'; // eslint-disable-next-line no-new-func factories[len] = Function('F,a', 'return new F(' + n.join(',') + ')'); } return factories[len](F, args); }; var _bind = Function.bind || function bind(that /* , ...args */) { var fn = _aFunction(this); var partArgs = arraySlice.call(arguments, 1); var bound = function (/* args... */) { var args = partArgs.concat(arraySlice.call(arguments)); return this instanceof bound ? construct(fn, args.length, args) : _invoke(fn, args, that); }; if (_isObject(fn.prototype)) bound.prototype = fn.prototype; return bound; }; // 19.2.3.2 / 15.3.4.5 Function.prototype.bind(thisArg, args...) _export(_export.P, 'Function', { bind: _bind }); var newArrowCheck = createCommonjsModule(function (module) { function _newArrowCheck(innerThis, boundThis) { if (innerThis !== boundThis) { throw new TypeError("Cannot instantiate an arrow function"); } } module.exports = _newArrowCheck, module.exports.__esModule = true, module.exports["default"] = module.exports; }); var _newArrowCheck = unwrapExports(newArrowCheck); /*! ***************************************************************************** Copyright (c) Microsoft Corporation. Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ***************************************************************************** */ /* global Reflect, Promise */ var extendStatics = function(d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; return extendStatics(d, b); }; function __extends(d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); } var __assign = function() { __assign = Object.assign || function __assign(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; return __assign.apply(this, arguments); }; function __rest(s, e) { var t = {}; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]]; } return t; } function __spreadArray(to, from, pack) { if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { if (ar || !(i in from)) { if (!ar) ar = Array.prototype.slice.call(from, 0, i); ar[i] = from[i]; } } return to.concat(ar || Array.prototype.slice.call(from)); } var genericMessage = "Invariant Violation"; var _a = Object.setPrototypeOf, setPrototypeOf = _a === void 0 ? function (obj, proto) { obj.__proto__ = proto; return obj; } : _a; var InvariantError = /** @class */ (function (_super) { __extends(InvariantError, _super); function InvariantError(message) { if (message === void 0) { message = genericMessage; } var _this = _super.call(this, typeof message === "number" ? genericMessage + ": " + message + " (see https://github.com/apollographql/invariant-packages)" : message) || this; _this.framesToPop = 1; _this.name = genericMessage; setPrototypeOf(_this, InvariantError.prototype); return _this; } return InvariantError; }(Error)); function invariant(condition, message) { if (!condition) { throw new InvariantError(message); } } var verbosityLevels = ["debug", "log", "warn", "error", "silent"]; var verbosityLevel = verbosityLevels.indexOf("log"); function wrapConsoleMethod(name) { return function () { if (verbosityLevels.indexOf(name) >= verbosityLevel) { // Default to console.log if this host environment happens not to provide // all the console.* methods we need. var method = console[name] || console.log; return method.apply(console, arguments); } }; } (function (invariant) { invariant.debug = wrapConsoleMethod("debug"); invariant.log = wrapConsoleMethod("log"); invariant.warn = wrapConsoleMethod("warn"); invariant.error = wrapConsoleMethod("error"); })(invariant || (invariant = {})); function setVerbosity(level) { var old = verbosityLevels[verbosityLevel]; verbosityLevel = Math.max(0, verbosityLevels.indexOf(level)); return old; } function maybe(thunk) { try { return thunk(); } catch (_a) { } } var global$1 = (maybe(function () { return globalThis; }) || maybe(function () { return window; }) || maybe(function () { return self; }) || maybe(function () { return global; }) || maybe(function () { return maybe.constructor("return this")(); })); var __ = "__"; var GLOBAL_KEY = [__, __].join("DEV"); function getDEV() { try { return Boolean(__DEV__); } catch (_a) { Object.defineProperty(global$1, GLOBAL_KEY, { value: maybe(function () { return process.env.NODE_ENV; }) !== "production", enumerable: false, configurable: true, writable: true, }); return global$1[GLOBAL_KEY]; } } var DEV = getDEV(); function maybe$1(thunk) { try { return thunk() } catch (_) {} } var safeGlobal = ( maybe$1(function() { return globalThis }) || maybe$1(function() { return window }) || maybe$1(function() { return self }) || maybe$1(function() { return global }) || // We don't expect the Function constructor ever to be invoked at runtime, as // long as at least one of globalThis, window, self, or global is defined, so // we are under no obligation to make it easy for static analysis tools to // detect syntactic usage of the Function constructor. If you think you can // improve your static analysis to detect this obfuscation, think again. This // is an arms race you cannot win, at least not in JavaScript. maybe$1(function() { return maybe$1.constructor("return this")() }) ); var needToRemove = false; function install() { if (safeGlobal && !maybe$1(function() { return process.env.NODE_ENV }) && !maybe$1(function() { return process })) { Object.defineProperty(safeGlobal, "process", { value: { env: { // This default needs to be "production" instead of "development", to // avoid the problem https://github.com/graphql/graphql-js/pull/2894 // will eventually solve, once merged and released. NODE_ENV: "production", }, }, // Let anyone else change global.process as they see fit, but hide it from // Object.keys(global) enumeration. configurable: true, enumerable: false, writable: true, }); needToRemove = true; } } // Call install() at least once, when this module is imported. install(); function remove() { if (needToRemove) { delete safeGlobal.process; needToRemove = false; } } /** * Note: This file is autogenerated using "resources/gen-version.js" script and * automatically updated by "npm version" command. */ /** * An object containing the components of the GraphQL.js version string */ var versionInfo = Object.freeze({ major: 15, minor: 5, patch: 0, preReleaseTag: null }); /** * Returns true if the value acts like a Promise, i.e. has a "then" function, * otherwise returns false. */ 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); } /** * Return true if `value` is object-like. A value is object-like if it's not * `null` and has a `typeof` result of "object". */ function isObjectLike(value) { return _typeof(value) == 'object' && value !== null; } // In ES2015 (or a polyfilled) environment, this will be Symbol.iterator // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2317') var SYMBOL_ITERATOR = typeof Symbol === 'function' && Symbol.iterator != null ? Symbol.iterator : '@@iterator'; // In ES2017 (or a polyfilled) environment, this will be Symbol.asyncIterator var SYMBOL_TO_STRING_TAG = typeof Symbol === 'function' && Symbol.toStringTag != null ? Symbol.toStringTag : '@@toStringTag'; /** * Represents a location in a Source. */ /** * Takes a Source and a UTF-8 character offset, and returns the corresponding * line and column as a SourceLocation. */ function getLocation(source, position) { var lineRegexp = /\r\n|[\n\r]/g; var line = 1; var column = position + 1; var match; while ((match = lineRegexp.exec(source.body)) && match.index < position) { line += 1; column = position + 1 - (match.index + match[0].length); } return { line: line, column: column }; } /** * Render a helpful description of the location in the GraphQL Source document. */ function printLocation(location) { return printSourceLocation(location.source, getLocation(location.source, location.start)); } /** * Render a helpful description of the location in the GraphQL Source document. */ function printSourceLocation(source, sourceLocation) { var firstLineColumnOffset = source.locationOffset.column - 1; var body = whitespace(firstLineColumnOffset) + source.body; var lineIndex = sourceLocation.line - 1; var lineOffset = source.locationOffset.line - 1; var lineNum = sourceLocation.line + lineOffset; var columnOffset = sourceLocation.line === 1 ? firstLineColumnOffset : 0; var columnNum = sourceLocation.column + columnOffset; var locationStr = "".concat(source.name, ":").concat(lineNum, ":").concat(columnNum, "\n"); var lines = body.split(/\r\n|[\n\r]/g); var locationLine = lines[lineIndex]; // Special case for minified documents if (locationLine.length > 120) { var subLineIndex = Math.floor(columnNum / 80); var subLineColumnNum = columnNum % 80; var subLines = []; for (var i = 0; i < locationLine.length; i += 80) { subLines.push(locationLine.slice(i, i + 80)); } return locationStr + printPrefixedLines([["".concat(lineNum), subLines[0]]].concat(subLines.slice(1, subLineIndex + 1).map(function (subLine) { return ['', subLine]; }), [[' ', whitespace(subLineColumnNum - 1) + '^'], ['', subLines[subLineIndex + 1]]])); } return locationStr + printPrefixedLines([// Lines specified like this: ["prefix", "string"], ["".concat(lineNum - 1), lines[lineIndex - 1]], ["".concat(lineNum), locationLine], ['', whitespace(columnNum - 1) + '^'], ["".concat(lineNum + 1), lines[lineIndex + 1]]]); } function printPrefixedLines(lines) { var existingLines = lines.filter(function (_ref) { var _ = _ref[0], line = _ref[1]; return line !== undefined; }); var padLen = Math.max.apply(Math, existingLines.map(function (_ref2) { var prefix = _ref2[0]; return prefix.length; })); return existingLines.map(function (_ref3) { var prefix = _ref3[0], line = _ref3[1]; return leftPad(padLen, prefix) + (line ? ' | ' + line : ' |'); }).join('\n'); } function whitespace(len) { return Array(len + 1).join(' '); } function leftPad(len, str) { return whitespace(len - str.length) + str; } function _typeof$1(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof$1 = function _typeof(obj) { return typeof obj; }; } else { _typeof$1 = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof$1(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$1(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); /** * 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. */ /** * 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 _locations2, _source2, _positions2, _extensions2; var _this; _classCallCheck(this, GraphQLError); _this = _super.call(this, message); // 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 _nodes$0$loc; _source = (_nodes$0$loc = _nodes[0].loc) === null || _nodes$0$loc === void 0 ? void 0 : _nodes$0$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(_assertThisInitialized(_this), { name: { value: 'GraphQLError' }, 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 falsy values to undefined ensures they will not be included // in JSON.stringify() when not provided. value: (_locations2 = _locations) !== null && _locations2 !== void 0 ? _locations2 : 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: _locations != null }, path: { // Coercing falsy values to undefined ensures they will not be included // in JSON.stringify() when not provided. value: path !== null && path !== void 0 ? 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: path != null }, nodes: { value: _nodes !== null && _nodes !== void 0 ? _nodes : undefined }, source: { value: (_source2 = _source) !== null && _source2 !== void 0 ? _source2 : undefined }, positions: { value: (_positions2 = _positions) !== null && _positions2 !== void 0 ? _positions2 : undefined }, originalError: { value: originalError }, extensions: { // Coercing falsy values to undefined ensures they will not be included // in JSON.stringify() when not provided. value: (_extensions2 = _extensions) !== null && _extensions2 !== void 0 ? _extensions2 : 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: _extensions != null } }); // 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)); /** * 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' + 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; } /** * 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("Syntax Error: ".concat(description), undefined, source, [position]); } /** * The set of allowed kind values for AST nodes. */ var Kind = Object.freeze({ // Name NAME: 'Name', // Document DOCUMENT: 'Document', OPERATION_DEFINITION: 'OperationDefinition', VARIABLE_DEFINITION: 'VariableDefinition', SELECTION_SET: 'SelectionSet', FIELD: 'Field', ARGUMENT: 'Argument', // Fragments FRAGMENT_SPREAD: 'FragmentSpread', INLINE_FRAGMENT: 'InlineFragment', FRAGMENT_DEFINITION: 'FragmentDefinition', // Values VARIABLE: 'Variable', INT: 'IntValue', FLOAT: 'FloatValue', STRING: 'StringValue', BOOLEAN: 'BooleanValue', NULL: 'NullValue', ENUM: 'EnumValue', LIST: 'ListValue', OBJECT: 'ObjectValue', OBJECT_FIELD: 'ObjectField', // Directives DIRECTIVE: 'Directive', // Types NAMED_TYPE: 'NamedType', LIST_TYPE: 'ListType', NON_NULL_TYPE: 'NonNullType', // Type System Definitions SCHEMA_DEFINITION: 'SchemaDefinition', OPERATION_TYPE_DEFINITION: 'OperationTypeDefinition', // Type Definitions SCALAR_TYPE_DEFINITION: 'ScalarTypeDefinition', OBJECT_TYPE_DEFINITION: 'ObjectTypeDefinition', FIELD_DEFINITION: 'FieldDefinition', INPUT_VALUE_DEFINITION: 'InputValueDefinition', INTERFACE_TYPE_DEFINITION: 'InterfaceTypeDefinition', UNION_TYPE_DEFINITION: 'UnionTypeDefinition', ENUM_TYPE_DEFINITION: 'EnumTypeDefinition', ENUM_VALUE_DEFINITION: 'EnumValueDefinition', INPUT_OBJECT_TYPE_DEFINITION: 'InputObjectTypeDefinition', // Directive Definitions DIRECTIVE_DEFINITION: 'DirectiveDefinition', // Type System Extensions SCHEMA_EXTENSION: 'SchemaExtension', // Type Extensions SCALAR_TYPE_EXTENSION: 'ScalarTypeExtension', OBJECT_TYPE_EXTENSION: 'ObjectTypeExtension', INTERFACE_TYPE_EXTENSION: 'InterfaceTypeExtension', UNION_TYPE_EXTENSION: 'UnionTypeExtension', ENUM_TYPE_EXTENSION: 'EnumTypeExtension', INPUT_OBJECT_TYPE_EXTENSION: 'InputObjectTypeExtension' }); /** * The enum type representing the possible kind values of AST nodes. */ function invariant$2(condition, message) { var booleanCondition = Boolean(condition); // istanbul ignore else (See transformation done in './resources/inlineInvariant.js') if (!booleanCondition) { throw new Error(message != null ? message : 'Unexpected invariant triggered.'); } } // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2317') var nodejsCustomInspectSymbol = typeof Symbol === 'function' && typeof Symbol.for === 'function' ? Symbol.for('nodejs.util.inspect.custom') : undefined; /** * The `defineInspect()` function defines `inspect()` prototype method as alias of `toJSON` */ function defineInspect(classObject) { var fn = classObject.prototype.toJSON; typeof fn === 'function' || invariant$2(0); classObject.prototype.inspect = fn; // istanbul ignore else (See: 'https://github.com/graphql/graphql-js/issues/2317') if (nodejsCustomInspectSymbol) { classObject.prototype[nodejsCustomInspectSymbol] = fn; } } /** * Contains a range of UTF-8 character offsets and token references that * identify the region of the source from which the AST derived. */ var Location = /*#__PURE__*/function () { /** * The character offset at which this Node begins. */ /** * The character offset at which this Node ends. */ /** * The Token at which this Node begins. */ /** * The Token at which this Node ends. */ /** * The Source document the AST represents. */ function Location(startToken, endToken, source) { this.start = startToken.start; this.end = endToken.end; this.startToken = startToken; this.endToken = endToken; this.source = source; } var _proto = Location.prototype; _proto.toJSON = function toJSON() { return { start: this.start, end: this.end }; }; return Location; }(); // Print a simplified form when appearing in `inspect` and `util.inspect`. defineInspect(Location); /** * Represents a range of characters represented by a lexical token * within a Source. */ var Token = /*#__PURE__*/function () { /** * The kind of Token. */ /** * The character offset at which this Node begins. */ /** * The character offset at which this Node ends. */ /** * The 1-indexed line number on which this Token appears. */ /** * The 1-indexed column number at which this Token begins. */ /** * For non-punctuation tokens, represents the interpreted value of the token. */ /** * Tokens exist as nodes in a double-linked-list amongst all tokens * including ignored tokens. <SOF> is always the first node and <EOF> * the last. */ function Token(kind, start, end, line, column, prev, value) { this.kind = kind; this.start = start; this.end = end; this.line = line; this.column = column; this.value = value; this.prev = prev; this.next = null; } var _proto2 = Token.prototype; _proto2.toJSON = function toJSON() { return { kind: this.kind, value: this.value, line: this.line, column: this.column }; }; return Token; }(); // Print a simplified form when appearing in `inspect` and `util.inspect`. defineInspect(Token); /** * @internal */ function isNode(maybeNode) { return maybeNode != null && typeof maybeNode.kind === 'string'; } /** * The list of all possible AST node types. */ /** * An exported enum describing the different kinds of tokens that the * lexer emits. */ var TokenKind = Object.freeze({ SOF: '<SOF>', EOF: '<EOF>', BANG: '!', DOLLAR: '$', AMP: '&', PAREN_L: '(', PAREN_R: ')', SPREAD: '...', COLON: ':', EQUALS: '=', AT: '@', BRACKET_L: '[', BRACKET_R: ']', BRACE_L: '{', PIPE: '|', BRACE_R: '}', NAME: 'Name', INT: 'Int', FLOAT: 'Float', STRING: 'String', BLOCK_STRING: 'BlockString', COMMENT: 'Comment' }); /** * The enum type representing the token kinds values. */ function _typeof$2(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof$2 = function _typeof(obj) { return typeof obj; }; } else { _typeof$2 = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof$2(obj); } var MAX_ARRAY_LENGTH = 10; var MAX_RECURSIVE_DEPTH = 2; /** * Used to print values in error messages. */ function inspect(value) { return formatValue(value, []); } function formatValue(value, seenValues) { switch (_typeof$2(value)) { case 'string': return JSON.stringify(value); case 'function': return value.name ? "[function ".concat(value.name, "]") : '[function]'; case 'object': if (value === null) { return 'null'; } return formatObjectValue(value, seenValues); default: return String(value); } } function formatObjectValue(value, previouslySeenValues) { if (previouslySeenValues.indexOf(value) !== -1) { return '[Circular]'; } var seenValues = [].concat(previouslySeenValues, [value]); var customInspectFn = getCustomFn(value); if (customInspectFn !== undefined) { var customValue = customInspectFn.call(value); // check for infinite recursion if (customValue !== value) { return typeof customValue === 'string' ? customValue : formatValue(customValue, seenValues); } } else if (Array.isArray(value)) { return formatArray(value, seenValues); } return formatObject(value, seenValues); } function formatObject(object, seenValues) { var keys = Object.keys(object); if (keys.length === 0) { return '{}'; } if (seenValues.length > MAX_RECURSIVE_DEPTH) { return '[' + getObjectTag(object) + ']'; } var properties = keys.map(function (key) { var value = formatValue(object[key], seenValues); return key + ': ' + value; }); return '{ ' + properties.join(', ') + ' }'; } function formatArray(array, seenValues) { if (array.length === 0) { return '[]'; } if (seenValues.length > MAX_RECURSIVE_DEPTH) { return '[Array]'; } var len = Math.min(MAX_ARRAY_LENGTH, array.length); var remaining = array.length - len; var items = []; for (var i = 0; i < len; ++i) { items.push(formatValue(array[i], seenValues)); } if (remaining === 1) { items.push('... 1 more item'); } else if (remaining > 1) { items.push("... ".concat(remaining, " more items")); } return '[' + items.join(', ') + ']'; } function getCustomFn(object) { var customInspectFn = object[String(nodejsCustomInspectSymbol)]; if (typeof customInspectFn === 'function') { return customInspectFn; } if (typeof object.inspect === 'function') { return object.inspect; } } function getObjectTag(object) { var tag = Object.prototype.toString.call(object).replace(/^\[object /, '').replace(/]$/, ''); if (tag === 'Object' && typeof object.constructor === 'function') { var name = object.constructor.name; if (typeof name === 'string' && name !== '') { return name; } } return tag; } function devAssert(condition, message) { var booleanCondition = Boolean(condition); // istanbul ignore else (See transformation done in './resources/inlineInvariant.js') if (!booleanCondition) { throw new Error(message); } } /** * A replacement for instanceof which includes an error warning when multi-realm * constructors are detected. */ // See: https://expressjs.com/en/advanced/best-practice-performance.html#set-node_env-to-production // See: https://webpack.js.org/guides/production/ var instanceOf = process.env.NODE_ENV === 'production' ? // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2317') // eslint-disable-next-line no-shadow function instanceOf(value, constructor) { return value instanceof constructor; } : // eslint-disable-next-line no-shadow function instanceOf(value, constructor) { if (value instanceof constructor) { return true; } if (value) { var valueClass = value.constructor; var className = constructor.name; if (className && valueClass && valueClass.name === className) { throw new Error("Cannot use ".concat(className, " \"").concat(value, "\" from another module or realm.\n\nEnsure that there is only one instance of \"graphql\" in the node_modules\ndirectory. If different versions of \"graphql\" are the dependencies of other\nrelied on modules, use \"resolutions\" to ensure only one version is installed.\n\nhttps://yarnpkg.com/en/docs/selective-version-resolutions\n\nDuplicate \"graphql\" modules cannot be used at the same time since different\nversions may have different capabilities and behavior. The data from one\nversion used in the function from another could produce confusing and\nspurious results.")); } } return false; }; function _defineProperties$1(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$1(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties$1(Constructor.prototype, protoProps); if (staticProps) _defineProperties$1(Constructor, staticProps); return Constructor; } /** * A representation of source input to GraphQL. The `name` and `locationOffset` parameters are * optional, but they are useful for clients who store GraphQL documents in source files. * For example, if the GraphQL input starts at line 40 in a file named `Foo.graphql`, it might * be useful for `name` to be `"Foo.graphql"` and location to be `{ line: 40, column: 1 }`. * The `line` and `column` properties in `locationOffset` are 1-indexed. */ var Source = /*#__PURE__*/function () { function Source(body) { var name = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'GraphQL request'; var locationOffset = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : { line: 1, column: 1 }; typeof body === 'string' || devAssert(0, "Body must be a string. Received: ".concat(inspect(body), ".")); this.body = body; this.name = name; this.locationOffset = locationOffset; this.locationOffset.line > 0 || devAssert(0, 'line in locationOffset is 1-indexed and must be positive.'); this.locationOffset.column > 0 || devAssert(0, 'column in locationOffset is 1-indexed and must be positive.'); } // $FlowFixMe[unsupported-syntax] Flow doesn't support computed properties yet _createClass$1(Source, [{ key: SYMBOL_TO_STRING_TAG, get: function get() { return 'Source'; } }]); return Source; }(); /** * Test if the given value is a Source object. * * @internal */ // eslint-disable-next-line no-redeclare function isSource(source) { return instanceOf(source, Source); } /** * The set of allowed directive location values. */ var DirectiveLocation = Object.freeze({ // Request Definitions QUERY: 'QUERY', MUTATION: 'MUTATION', SUBSCRIPTION: 'SUBSCRIPTION', FIELD: 'FIELD', FRAGMENT_DEFINITION: 'FRAGMENT_DEFINITION', FRAGMENT_SPREAD: 'FRAGMENT_SPREAD', INLINE_FRAGMENT: 'INLINE_FRAGMENT', VARIABLE_DEFINITION: 'VARIABLE_DEFINITION', // Type System Definitions SCHEMA: 'SCHEMA', SCALAR: 'SCALAR', OBJECT: 'OBJECT', FIELD_DEFINITION: 'FIELD_DEFINITION', ARGUMENT_DEFINITION: 'ARGUMENT_DEFINITION', INTERFACE: 'INTERFACE', UNION: 'UNION', ENUM: 'ENUM', ENUM_VALUE: 'ENUM_VALUE', INPUT_OBJECT: 'INPUT_OBJECT', INPUT_FIELD_DEFINITION: 'INPUT_FIELD_DEFINITION' }); /** * The enum type representing the directive location values. */ /** * Produces the value of a block string from its parsed raw value, similar to * CoffeeScript's block string, Python's docstring trim or Ruby's strip_heredoc. * * This implements the GraphQL spec's BlockStringValue() static algorithm. * * @internal */ function dedentBlockStringValue(rawString) { // Expand a block string's raw value into independent lines. var lines = rawString.split(/\r\n|[\n\r]/g); // Remove common indentation from all lines but first. var commonIndent = getBlockStringIndentation(rawString); if (commonIndent !== 0) { for (var i = 1; i < lines.length; i++) { lines[i] = lines[i].slice(commonIndent); } } // Remove leading and trailing blank lines. var startLine = 0; while (startLine < lines.length && isBlank(lines[startLine])) { ++startLine; } var endLine = lines.length; while (endLine > startLine && isBlank(lines[endLine - 1])) { --endLine; } // Return a string of the lines joined with U+000A. return lines.slice(startLine, endLine).join('\n'); } function isBlank(str) { for (var i = 0; i < str.length; ++i) { if (str[i] !== ' ' && str[i] !== '\t') { return false; } } return true; } /** * @internal */ function getBlockStringIndentation(value) { var _commonIndent; var isFirstLine = true; var isEmptyLine = true; var indent = 0; var commonIndent = null; for (var i = 0; i < value.length; ++i) { switch (value.charCodeAt(i)) { case 13: // \r if (value.charCodeAt(i + 1) === 10) { ++i; // skip \r\n as one symbol } // falls through case 10: // \n isFirstLine = false; isEmptyLine = true; indent = 0; break; case 9: // \t case 32: // <space> ++indent; break; default: if (isEmptyLine && !isFirstLine && (commonIndent === null || indent < commonIndent)) { commonIndent = indent; } isEmptyLine = false; } } return (_commonIndent = commonIndent) !== null && _commonIndent !== void 0 ? _commonIndent : 0; } /** * Print a block string in the indented block form by adding a leading and * trailing blank line. However, if a block string starts with whitespace and is * a single-line, adding a leading blank line would strip that whitespace. * * @internal */ function pr