UNPKG

2.48 kBJavaScriptView Raw
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.default = void 0;
7
8var _inspect = _interopRequireDefault(require("./inspect.js"));
9
10function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
12function _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); }
13
14// See: https://expressjs.com/en/advanced/best-practice-performance.html#set-node_env-to-production
15// See: https://webpack.js.org/guides/production/
16var _default = process.env.NODE_ENV === 'production' ? // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2317')
17// eslint-disable-next-line no-shadow
18function instanceOf(value, constructor) {
19 return value instanceof constructor;
20} : // eslint-disable-next-line no-shadow
21function instanceOf(value, constructor) {
22 if (value instanceof constructor) {
23 return true;
24 }
25
26 if (_typeof(value) === 'object' && value !== null) {
27 var _value$constructor;
28
29 var className = constructor.prototype[Symbol.toStringTag];
30 var valueClassName = // We still need to support constructor's name to detect conflicts with older versions of this library.
31 Symbol.toStringTag in value ? value[Symbol.toStringTag] : (_value$constructor = value.constructor) === null || _value$constructor === void 0 ? void 0 : _value$constructor.name;
32
33 if (className === valueClassName) {
34 var stringifiedValue = (0, _inspect.default)(value);
35 throw new Error("Cannot use ".concat(className, " \"").concat(stringifiedValue, "\" 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."));
36 }
37 }
38
39 return false;
40};
41
42exports.default = _default;