graphql 15.4.0 → 15.5.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -0
- package/error/GraphQLError.js +3 -3
- package/error/GraphQLError.js.flow +1 -1
- package/error/GraphQLError.mjs +1 -1
- package/execution/execute.js +8 -9
- package/execution/execute.js.flow +8 -10
- package/execution/execute.mjs +8 -8
- package/jsutils/instanceOf.js +15 -9
- package/jsutils/instanceOf.js.flow +12 -5
- package/jsutils/instanceOf.mjs +13 -5
- package/jsutils/isAsyncIterable.js +1 -7
- package/jsutils/isAsyncIterable.js.flow +1 -5
- package/jsutils/isAsyncIterable.mjs +1 -7
- package/jsutils/naturalCompare.js +69 -0
- package/jsutils/naturalCompare.js.flow +59 -0
- package/jsutils/naturalCompare.mjs +61 -0
- package/jsutils/safeArrayFrom.js +73 -0
- package/jsutils/safeArrayFrom.js.flow +59 -0
- package/jsutils/safeArrayFrom.mjs +66 -0
- package/jsutils/suggestionList.js +5 -1
- package/jsutils/suggestionList.js.flow +3 -1
- package/jsutils/suggestionList.mjs +3 -1
- package/language/blockString.js.flow +2 -2
- package/language/parser.d.ts +456 -1
- package/language/source.js.flow +1 -1
- package/package.json +2 -3
- package/type/definition.js +1 -0
- package/type/definition.js.flow +58 -45
- package/type/definition.mjs +1 -0
- package/type/directives.js.flow +9 -7
- package/type/schema.js.flow +1 -1
- package/utilities/TypeInfo.js.flow +1 -1
- package/utilities/astFromValue.js +6 -8
- package/utilities/astFromValue.js.flow +6 -6
- package/utilities/astFromValue.mjs +6 -7
- package/utilities/buildClientSchema.js +2 -1
- package/utilities/buildClientSchema.js.flow +1 -0
- package/utilities/buildClientSchema.mjs +2 -1
- package/utilities/coerceInputValue.js +7 -8
- package/utilities/coerceInputValue.js.flow +11 -8
- package/utilities/coerceInputValue.mjs +7 -7
- package/utilities/findBreakingChanges.js +6 -2
- package/utilities/findBreakingChanges.js.flow +6 -2
- package/utilities/findBreakingChanges.mjs +5 -2
- package/utilities/getIntrospectionQuery.d.ts +6 -0
- package/utilities/getIntrospectionQuery.js +8 -2
- package/utilities/getIntrospectionQuery.js.flow +16 -3
- package/utilities/getIntrospectionQuery.mjs +8 -2
- package/utilities/introspectionFromSchema.js +3 -1
- package/utilities/introspectionFromSchema.js.flow +2 -0
- package/utilities/introspectionFromSchema.mjs +3 -1
- package/utilities/lexicographicSortSchema.js +3 -1
- package/utilities/lexicographicSortSchema.js.flow +3 -2
- package/utilities/lexicographicSortSchema.mjs +2 -1
- package/utilities/separateOperations.js +44 -40
- package/utilities/separateOperations.js.flow +46 -36
- package/utilities/separateOperations.mjs +44 -40
- package/validation/ValidationContext.js.flow +3 -3
- package/validation/rules/FieldsOnCorrectTypeRule.js +3 -1
- package/validation/rules/FieldsOnCorrectTypeRule.js.flow +2 -1
- package/validation/rules/FieldsOnCorrectTypeRule.mjs +2 -1
- package/validation/rules/UniqueDirectiveNamesRule.js +1 -1
- package/validation/rules/UniqueDirectiveNamesRule.mjs +1 -1
- package/validation/rules/UniqueTypeNamesRule.js +1 -1
- package/validation/rules/UniqueTypeNamesRule.mjs +1 -1
- package/validation/validate.js.flow +4 -4
- package/version.js +3 -3
- package/version.js.flow +3 -3
- package/version.mjs +3 -3
- package/jsutils/isCollection.js +0 -47
- package/jsutils/isCollection.js.flow +0 -38
- package/jsutils/isCollection.mjs +0 -40
package/README.md
CHANGED
|
@@ -115,6 +115,16 @@ directly on this branch:
|
|
|
115
115
|
npm install graphql@git://github.com/graphql/graphql-js.git#npm
|
|
116
116
|
```
|
|
117
117
|
|
|
118
|
+
### Experimental features
|
|
119
|
+
|
|
120
|
+
Each release of GraphQL.js will be accompanied by an experimental release containing support for the `@defer` and `@stream` directive proposal. We are hoping to get community feedback on these releases before the proposal is accepted into the GraphQL specification. You can use this experimental release of GraphQL.js by adding the following to your project's `package.json` file.
|
|
121
|
+
|
|
122
|
+
```
|
|
123
|
+
"graphql": "experimental-stream-defer"
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
Community feedback on this experimental release is much appreciated and can be provided on the [issue created for this purpose](https://github.com/graphql/graphql-js/issues/2848).
|
|
127
|
+
|
|
118
128
|
### Using in a Browser
|
|
119
129
|
|
|
120
130
|
GraphQL.js is a general-purpose library and can be used both in a Node server
|
package/error/GraphQLError.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
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); }
|
|
4
|
+
|
|
3
5
|
Object.defineProperty(exports, "__esModule", {
|
|
4
6
|
value: true
|
|
5
7
|
});
|
|
@@ -16,8 +18,6 @@ var _printLocation = require("../language/printLocation.js");
|
|
|
16
18
|
|
|
17
19
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
18
20
|
|
|
19
|
-
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); }
|
|
20
|
-
|
|
21
21
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
22
22
|
|
|
23
23
|
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); } }
|
|
@@ -219,7 +219,7 @@ var GraphQLError = /*#__PURE__*/function (_Error) {
|
|
|
219
219
|
}
|
|
220
220
|
}); // Include (non-enumerable) stack trace.
|
|
221
221
|
|
|
222
|
-
if (originalError
|
|
222
|
+
if (originalError !== null && originalError !== void 0 && originalError.stack) {
|
|
223
223
|
Object.defineProperty(_assertThisInitialized(_this), 'stack', {
|
|
224
224
|
value: originalError.stack,
|
|
225
225
|
writable: true,
|
|
@@ -84,7 +84,7 @@ export class GraphQLError extends Error {
|
|
|
84
84
|
path?: ?$ReadOnlyArray<string | number>,
|
|
85
85
|
originalError?: ?(Error & { +extensions?: mixed, ... }),
|
|
86
86
|
extensions?: ?{ [key: string]: mixed, ... },
|
|
87
|
-
)
|
|
87
|
+
) {
|
|
88
88
|
super(message);
|
|
89
89
|
|
|
90
90
|
// Compute list of blame nodes.
|
package/error/GraphQLError.mjs
CHANGED
|
@@ -208,7 +208,7 @@ export var GraphQLError = /*#__PURE__*/function (_Error) {
|
|
|
208
208
|
}
|
|
209
209
|
}); // Include (non-enumerable) stack trace.
|
|
210
210
|
|
|
211
|
-
if (originalError
|
|
211
|
+
if (originalError !== null && originalError !== void 0 && originalError.stack) {
|
|
212
212
|
Object.defineProperty(_assertThisInitialized(_this), 'stack', {
|
|
213
213
|
value: originalError.stack,
|
|
214
214
|
writable: true,
|
package/execution/execute.js
CHANGED
|
@@ -12,8 +12,6 @@ exports.buildResolveInfo = buildResolveInfo;
|
|
|
12
12
|
exports.getFieldDef = getFieldDef;
|
|
13
13
|
exports.defaultFieldResolver = exports.defaultTypeResolver = void 0;
|
|
14
14
|
|
|
15
|
-
var _arrayFrom = _interopRequireDefault(require("../polyfills/arrayFrom.js"));
|
|
16
|
-
|
|
17
15
|
var _inspect = _interopRequireDefault(require("../jsutils/inspect.js"));
|
|
18
16
|
|
|
19
17
|
var _memoize = _interopRequireDefault(require("../jsutils/memoize3.js"));
|
|
@@ -26,7 +24,7 @@ var _isPromise = _interopRequireDefault(require("../jsutils/isPromise.js"));
|
|
|
26
24
|
|
|
27
25
|
var _isObjectLike = _interopRequireDefault(require("../jsutils/isObjectLike.js"));
|
|
28
26
|
|
|
29
|
-
var
|
|
27
|
+
var _safeArrayFrom = _interopRequireDefault(require("../jsutils/safeArrayFrom.js"));
|
|
30
28
|
|
|
31
29
|
var _promiseReduce = _interopRequireDefault(require("../jsutils/promiseReduce.js"));
|
|
32
30
|
|
|
@@ -602,15 +600,11 @@ function completeValue(exeContext, returnType, fieldNodes, info, path, result) {
|
|
|
602
600
|
|
|
603
601
|
|
|
604
602
|
function completeListValue(exeContext, returnType, fieldNodes, info, path, result) {
|
|
605
|
-
|
|
606
|
-
throw new _GraphQLError.GraphQLError("Expected Iterable, but did not find one for field \"".concat(info.parentType.name, ".").concat(info.fieldName, "\"."));
|
|
607
|
-
} // This is specified as a simple map, however we're optimizing the path
|
|
603
|
+
// This is specified as a simple map, however we're optimizing the path
|
|
608
604
|
// where the list contains no Promises by avoiding creating another Promise.
|
|
609
|
-
|
|
610
|
-
|
|
611
605
|
var itemType = returnType.ofType;
|
|
612
606
|
var containsPromise = false;
|
|
613
|
-
var completedResults = (0,
|
|
607
|
+
var completedResults = (0, _safeArrayFrom.default)(result, function (item, index) {
|
|
614
608
|
// No need to modify the info object containing the path,
|
|
615
609
|
// since from here on it is not ever accessed by resolver functions.
|
|
616
610
|
var itemPath = (0, _Path.addPath)(path, index, undefined);
|
|
@@ -642,6 +636,11 @@ function completeListValue(exeContext, returnType, fieldNodes, info, path, resul
|
|
|
642
636
|
return handleFieldError(error, itemType, exeContext);
|
|
643
637
|
}
|
|
644
638
|
});
|
|
639
|
+
|
|
640
|
+
if (completedResults == null) {
|
|
641
|
+
throw new _GraphQLError.GraphQLError("Expected Iterable, but did not find one for field \"".concat(info.parentType.name, ".").concat(info.fieldName, "\"."));
|
|
642
|
+
}
|
|
643
|
+
|
|
645
644
|
return containsPromise ? Promise.all(completedResults) : completedResults;
|
|
646
645
|
}
|
|
647
646
|
/**
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
// @flow strict
|
|
2
|
-
import arrayFrom from '../polyfills/arrayFrom';
|
|
3
|
-
|
|
4
2
|
import type { Path } from '../jsutils/Path';
|
|
5
3
|
import type { ObjMap } from '../jsutils/ObjMap';
|
|
6
4
|
import type { PromiseOrValue } from '../jsutils/PromiseOrValue';
|
|
@@ -10,7 +8,7 @@ import invariant from '../jsutils/invariant';
|
|
|
10
8
|
import devAssert from '../jsutils/devAssert';
|
|
11
9
|
import isPromise from '../jsutils/isPromise';
|
|
12
10
|
import isObjectLike from '../jsutils/isObjectLike';
|
|
13
|
-
import
|
|
11
|
+
import safeArrayFrom from '../jsutils/safeArrayFrom';
|
|
14
12
|
import promiseReduce from '../jsutils/promiseReduce';
|
|
15
13
|
import promiseForObject from '../jsutils/promiseForObject';
|
|
16
14
|
import { addPath, pathToArray } from '../jsutils/Path';
|
|
@@ -868,17 +866,11 @@ function completeListValue(
|
|
|
868
866
|
path: Path,
|
|
869
867
|
result: mixed,
|
|
870
868
|
): PromiseOrValue<$ReadOnlyArray<mixed>> {
|
|
871
|
-
if (!isCollection(result)) {
|
|
872
|
-
throw new GraphQLError(
|
|
873
|
-
`Expected Iterable, but did not find one for field "${info.parentType.name}.${info.fieldName}".`,
|
|
874
|
-
);
|
|
875
|
-
}
|
|
876
|
-
|
|
877
869
|
// This is specified as a simple map, however we're optimizing the path
|
|
878
870
|
// where the list contains no Promises by avoiding creating another Promise.
|
|
879
871
|
const itemType = returnType.ofType;
|
|
880
872
|
let containsPromise = false;
|
|
881
|
-
const completedResults =
|
|
873
|
+
const completedResults = safeArrayFrom(result, (item, index) => {
|
|
882
874
|
// No need to modify the info object containing the path,
|
|
883
875
|
// since from here on it is not ever accessed by resolver functions.
|
|
884
876
|
const itemPath = addPath(path, index, undefined);
|
|
@@ -926,6 +918,12 @@ function completeListValue(
|
|
|
926
918
|
}
|
|
927
919
|
});
|
|
928
920
|
|
|
921
|
+
if (completedResults == null) {
|
|
922
|
+
throw new GraphQLError(
|
|
923
|
+
`Expected Iterable, but did not find one for field "${info.parentType.name}.${info.fieldName}".`,
|
|
924
|
+
);
|
|
925
|
+
}
|
|
926
|
+
|
|
929
927
|
return containsPromise ? Promise.all(completedResults) : completedResults;
|
|
930
928
|
}
|
|
931
929
|
|
package/execution/execute.mjs
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import arrayFrom from "../polyfills/arrayFrom.mjs";
|
|
2
1
|
import inspect from "../jsutils/inspect.mjs";
|
|
3
2
|
import memoize3 from "../jsutils/memoize3.mjs";
|
|
4
3
|
import invariant from "../jsutils/invariant.mjs";
|
|
5
4
|
import devAssert from "../jsutils/devAssert.mjs";
|
|
6
5
|
import isPromise from "../jsutils/isPromise.mjs";
|
|
7
6
|
import isObjectLike from "../jsutils/isObjectLike.mjs";
|
|
8
|
-
import
|
|
7
|
+
import safeArrayFrom from "../jsutils/safeArrayFrom.mjs";
|
|
9
8
|
import promiseReduce from "../jsutils/promiseReduce.mjs";
|
|
10
9
|
import promiseForObject from "../jsutils/promiseForObject.mjs";
|
|
11
10
|
import { addPath, pathToArray } from "../jsutils/Path.mjs";
|
|
@@ -588,15 +587,11 @@ function completeValue(exeContext, returnType, fieldNodes, info, path, result) {
|
|
|
588
587
|
|
|
589
588
|
|
|
590
589
|
function completeListValue(exeContext, returnType, fieldNodes, info, path, result) {
|
|
591
|
-
|
|
592
|
-
throw new GraphQLError("Expected Iterable, but did not find one for field \"".concat(info.parentType.name, ".").concat(info.fieldName, "\"."));
|
|
593
|
-
} // This is specified as a simple map, however we're optimizing the path
|
|
590
|
+
// This is specified as a simple map, however we're optimizing the path
|
|
594
591
|
// where the list contains no Promises by avoiding creating another Promise.
|
|
595
|
-
|
|
596
|
-
|
|
597
592
|
var itemType = returnType.ofType;
|
|
598
593
|
var containsPromise = false;
|
|
599
|
-
var completedResults =
|
|
594
|
+
var completedResults = safeArrayFrom(result, function (item, index) {
|
|
600
595
|
// No need to modify the info object containing the path,
|
|
601
596
|
// since from here on it is not ever accessed by resolver functions.
|
|
602
597
|
var itemPath = addPath(path, index, undefined);
|
|
@@ -628,6 +623,11 @@ function completeListValue(exeContext, returnType, fieldNodes, info, path, resul
|
|
|
628
623
|
return handleFieldError(error, itemType, exeContext);
|
|
629
624
|
}
|
|
630
625
|
});
|
|
626
|
+
|
|
627
|
+
if (completedResults == null) {
|
|
628
|
+
throw new GraphQLError("Expected Iterable, but did not find one for field \"".concat(info.parentType.name, ".").concat(info.fieldName, "\"."));
|
|
629
|
+
}
|
|
630
|
+
|
|
631
631
|
return containsPromise ? Promise.all(completedResults) : completedResults;
|
|
632
632
|
}
|
|
633
633
|
/**
|
package/jsutils/instanceOf.js
CHANGED
|
@@ -5,10 +5,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
var _inspect = _interopRequireDefault(require("./inspect.js"));
|
|
9
|
+
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
+
|
|
12
|
+
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); }
|
|
13
|
+
|
|
12
14
|
// See: https://expressjs.com/en/advanced/best-practice-performance.html#set-node_env-to-production
|
|
13
15
|
// See: https://webpack.js.org/guides/production/
|
|
14
16
|
var _default = process.env.NODE_ENV === 'production' ? // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2317')
|
|
@@ -21,12 +23,16 @@ function instanceOf(value, constructor) {
|
|
|
21
23
|
return true;
|
|
22
24
|
}
|
|
23
25
|
|
|
24
|
-
if (value) {
|
|
25
|
-
var
|
|
26
|
-
|
|
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;
|
|
27
32
|
|
|
28
|
-
if (className
|
|
29
|
-
|
|
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."));
|
|
30
36
|
}
|
|
31
37
|
}
|
|
32
38
|
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
// @flow strict
|
|
2
|
+
import inspect from './inspect';
|
|
3
|
+
|
|
2
4
|
/**
|
|
3
5
|
* A replacement for instanceof which includes an error warning when multi-realm
|
|
4
6
|
* constructors are detected.
|
|
@@ -21,12 +23,17 @@ export default process.env.NODE_ENV === 'production'
|
|
|
21
23
|
if (value instanceof constructor) {
|
|
22
24
|
return true;
|
|
23
25
|
}
|
|
24
|
-
if (value) {
|
|
25
|
-
const
|
|
26
|
-
const
|
|
27
|
-
|
|
26
|
+
if (typeof value === 'object' && value !== null) {
|
|
27
|
+
const className = constructor.prototype[Symbol.toStringTag];
|
|
28
|
+
const valueClassName =
|
|
29
|
+
// We still need to support constructor's name to detect conflicts with older versions of this library.
|
|
30
|
+
Symbol.toStringTag in value
|
|
31
|
+
? value[Symbol.toStringTag]
|
|
32
|
+
: value.constructor?.name;
|
|
33
|
+
if (className === valueClassName) {
|
|
34
|
+
const stringifiedValue = inspect(value);
|
|
28
35
|
throw new Error(
|
|
29
|
-
`Cannot use ${className} "${
|
|
36
|
+
`Cannot use ${className} "${stringifiedValue}" from another module or realm.
|
|
30
37
|
|
|
31
38
|
Ensure that there is only one instance of "graphql" in the node_modules
|
|
32
39
|
directory. If different versions of "graphql" are the dependencies of other
|
package/jsutils/instanceOf.mjs
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
|
+
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); }
|
|
2
|
+
|
|
3
|
+
import inspect from "./inspect.mjs";
|
|
1
4
|
/**
|
|
2
5
|
* A replacement for instanceof which includes an error warning when multi-realm
|
|
3
6
|
* constructors are detected.
|
|
4
7
|
*/
|
|
8
|
+
|
|
5
9
|
// See: https://expressjs.com/en/advanced/best-practice-performance.html#set-node_env-to-production
|
|
6
10
|
// See: https://webpack.js.org/guides/production/
|
|
7
11
|
export default process.env.NODE_ENV === 'production' ? // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2317')
|
|
@@ -14,12 +18,16 @@ function instanceOf(value, constructor) {
|
|
|
14
18
|
return true;
|
|
15
19
|
}
|
|
16
20
|
|
|
17
|
-
if (value) {
|
|
18
|
-
var
|
|
19
|
-
|
|
21
|
+
if (_typeof(value) === 'object' && value !== null) {
|
|
22
|
+
var _value$constructor;
|
|
23
|
+
|
|
24
|
+
var className = constructor.prototype[Symbol.toStringTag];
|
|
25
|
+
var valueClassName = // We still need to support constructor's name to detect conflicts with older versions of this library.
|
|
26
|
+
Symbol.toStringTag in value ? value[Symbol.toStringTag] : (_value$constructor = value.constructor) === null || _value$constructor === void 0 ? void 0 : _value$constructor.name;
|
|
20
27
|
|
|
21
|
-
if (className
|
|
22
|
-
|
|
28
|
+
if (className === valueClassName) {
|
|
29
|
+
var stringifiedValue = inspect(value);
|
|
30
|
+
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."));
|
|
23
31
|
}
|
|
24
32
|
}
|
|
25
33
|
|
|
@@ -7,13 +7,7 @@ exports.default = isAsyncIterable;
|
|
|
7
7
|
|
|
8
8
|
var _symbols = require("../polyfills/symbols.js");
|
|
9
9
|
|
|
10
|
-
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); }
|
|
11
|
-
|
|
12
10
|
// eslint-disable-next-line no-redeclare
|
|
13
11
|
function isAsyncIterable(maybeAsyncIterable) {
|
|
14
|
-
|
|
15
|
-
return false;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
return typeof maybeAsyncIterable[_symbols.SYMBOL_ASYNC_ITERATOR] === 'function';
|
|
12
|
+
return typeof (maybeAsyncIterable === null || maybeAsyncIterable === void 0 ? void 0 : maybeAsyncIterable[_symbols.SYMBOL_ASYNC_ITERATOR]) === 'function';
|
|
19
13
|
}
|
|
@@ -10,9 +10,5 @@ declare function isAsyncIterable(value: mixed): boolean %checks(value instanceof
|
|
|
10
10
|
|
|
11
11
|
// eslint-disable-next-line no-redeclare
|
|
12
12
|
export default function isAsyncIterable(maybeAsyncIterable) {
|
|
13
|
-
|
|
14
|
-
return false;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
return typeof maybeAsyncIterable[SYMBOL_ASYNC_ITERATOR] === 'function';
|
|
13
|
+
return typeof maybeAsyncIterable?.[SYMBOL_ASYNC_ITERATOR] === 'function';
|
|
18
14
|
}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
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); }
|
|
2
|
-
|
|
3
1
|
import { SYMBOL_ASYNC_ITERATOR } from "../polyfills/symbols.mjs";
|
|
4
2
|
/**
|
|
5
3
|
* Returns true if the provided object implements the AsyncIterator protocol via
|
|
@@ -8,9 +6,5 @@ import { SYMBOL_ASYNC_ITERATOR } from "../polyfills/symbols.mjs";
|
|
|
8
6
|
|
|
9
7
|
// eslint-disable-next-line no-redeclare
|
|
10
8
|
export default function isAsyncIterable(maybeAsyncIterable) {
|
|
11
|
-
|
|
12
|
-
return false;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
return typeof maybeAsyncIterable[SYMBOL_ASYNC_ITERATOR] === 'function';
|
|
9
|
+
return typeof (maybeAsyncIterable === null || maybeAsyncIterable === void 0 ? void 0 : maybeAsyncIterable[SYMBOL_ASYNC_ITERATOR]) === 'function';
|
|
16
10
|
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = naturalCompare;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Returns a number indicating whether a reference string comes before, or after,
|
|
10
|
+
* or is the same as the given string in natural sort order.
|
|
11
|
+
*
|
|
12
|
+
* See: https://en.wikipedia.org/wiki/Natural_sort_order
|
|
13
|
+
*
|
|
14
|
+
*/
|
|
15
|
+
function naturalCompare(aStr, bStr) {
|
|
16
|
+
var aIdx = 0;
|
|
17
|
+
var bIdx = 0;
|
|
18
|
+
|
|
19
|
+
while (aIdx < aStr.length && bIdx < bStr.length) {
|
|
20
|
+
var aChar = aStr.charCodeAt(aIdx);
|
|
21
|
+
var bChar = bStr.charCodeAt(bIdx);
|
|
22
|
+
|
|
23
|
+
if (isDigit(aChar) && isDigit(bChar)) {
|
|
24
|
+
var aNum = 0;
|
|
25
|
+
|
|
26
|
+
do {
|
|
27
|
+
++aIdx;
|
|
28
|
+
aNum = aNum * 10 + aChar - DIGIT_0;
|
|
29
|
+
aChar = aStr.charCodeAt(aIdx);
|
|
30
|
+
} while (isDigit(aChar) && aNum > 0);
|
|
31
|
+
|
|
32
|
+
var bNum = 0;
|
|
33
|
+
|
|
34
|
+
do {
|
|
35
|
+
++bIdx;
|
|
36
|
+
bNum = bNum * 10 + bChar - DIGIT_0;
|
|
37
|
+
bChar = bStr.charCodeAt(bIdx);
|
|
38
|
+
} while (isDigit(bChar) && bNum > 0);
|
|
39
|
+
|
|
40
|
+
if (aNum < bNum) {
|
|
41
|
+
return -1;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (aNum > bNum) {
|
|
45
|
+
return 1;
|
|
46
|
+
}
|
|
47
|
+
} else {
|
|
48
|
+
if (aChar < bChar) {
|
|
49
|
+
return -1;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (aChar > bChar) {
|
|
53
|
+
return 1;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
++aIdx;
|
|
57
|
+
++bIdx;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return aStr.length - bStr.length;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
var DIGIT_0 = 48;
|
|
65
|
+
var DIGIT_9 = 57;
|
|
66
|
+
|
|
67
|
+
function isDigit(code) {
|
|
68
|
+
return !isNaN(code) && DIGIT_0 <= code && code <= DIGIT_9;
|
|
69
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
// @flow strict
|
|
2
|
+
/**
|
|
3
|
+
* Returns a number indicating whether a reference string comes before, or after,
|
|
4
|
+
* or is the same as the given string in natural sort order.
|
|
5
|
+
*
|
|
6
|
+
* See: https://en.wikipedia.org/wiki/Natural_sort_order
|
|
7
|
+
*
|
|
8
|
+
*/
|
|
9
|
+
export default function naturalCompare(aStr: string, bStr: string): number {
|
|
10
|
+
let aIdx = 0;
|
|
11
|
+
let bIdx = 0;
|
|
12
|
+
|
|
13
|
+
while (aIdx < aStr.length && bIdx < bStr.length) {
|
|
14
|
+
let aChar = aStr.charCodeAt(aIdx);
|
|
15
|
+
let bChar = bStr.charCodeAt(bIdx);
|
|
16
|
+
|
|
17
|
+
if (isDigit(aChar) && isDigit(bChar)) {
|
|
18
|
+
let aNum = 0;
|
|
19
|
+
do {
|
|
20
|
+
++aIdx;
|
|
21
|
+
aNum = aNum * 10 + aChar - DIGIT_0;
|
|
22
|
+
aChar = aStr.charCodeAt(aIdx);
|
|
23
|
+
} while (isDigit(aChar) && aNum > 0);
|
|
24
|
+
|
|
25
|
+
let bNum = 0;
|
|
26
|
+
do {
|
|
27
|
+
++bIdx;
|
|
28
|
+
bNum = bNum * 10 + bChar - DIGIT_0;
|
|
29
|
+
bChar = bStr.charCodeAt(bIdx);
|
|
30
|
+
} while (isDigit(bChar) && bNum > 0);
|
|
31
|
+
|
|
32
|
+
if (aNum < bNum) {
|
|
33
|
+
return -1;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (aNum > bNum) {
|
|
37
|
+
return 1;
|
|
38
|
+
}
|
|
39
|
+
} else {
|
|
40
|
+
if (aChar < bChar) {
|
|
41
|
+
return -1;
|
|
42
|
+
}
|
|
43
|
+
if (aChar > bChar) {
|
|
44
|
+
return 1;
|
|
45
|
+
}
|
|
46
|
+
++aIdx;
|
|
47
|
+
++bIdx;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return aStr.length - bStr.length;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const DIGIT_0 = 48;
|
|
55
|
+
const DIGIT_9 = 57;
|
|
56
|
+
|
|
57
|
+
function isDigit(code: number): boolean {
|
|
58
|
+
return !isNaN(code) && DIGIT_0 <= code && code <= DIGIT_9;
|
|
59
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns a number indicating whether a reference string comes before, or after,
|
|
3
|
+
* or is the same as the given string in natural sort order.
|
|
4
|
+
*
|
|
5
|
+
* See: https://en.wikipedia.org/wiki/Natural_sort_order
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
export default function naturalCompare(aStr, bStr) {
|
|
9
|
+
var aIdx = 0;
|
|
10
|
+
var bIdx = 0;
|
|
11
|
+
|
|
12
|
+
while (aIdx < aStr.length && bIdx < bStr.length) {
|
|
13
|
+
var aChar = aStr.charCodeAt(aIdx);
|
|
14
|
+
var bChar = bStr.charCodeAt(bIdx);
|
|
15
|
+
|
|
16
|
+
if (isDigit(aChar) && isDigit(bChar)) {
|
|
17
|
+
var aNum = 0;
|
|
18
|
+
|
|
19
|
+
do {
|
|
20
|
+
++aIdx;
|
|
21
|
+
aNum = aNum * 10 + aChar - DIGIT_0;
|
|
22
|
+
aChar = aStr.charCodeAt(aIdx);
|
|
23
|
+
} while (isDigit(aChar) && aNum > 0);
|
|
24
|
+
|
|
25
|
+
var bNum = 0;
|
|
26
|
+
|
|
27
|
+
do {
|
|
28
|
+
++bIdx;
|
|
29
|
+
bNum = bNum * 10 + bChar - DIGIT_0;
|
|
30
|
+
bChar = bStr.charCodeAt(bIdx);
|
|
31
|
+
} while (isDigit(bChar) && bNum > 0);
|
|
32
|
+
|
|
33
|
+
if (aNum < bNum) {
|
|
34
|
+
return -1;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (aNum > bNum) {
|
|
38
|
+
return 1;
|
|
39
|
+
}
|
|
40
|
+
} else {
|
|
41
|
+
if (aChar < bChar) {
|
|
42
|
+
return -1;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (aChar > bChar) {
|
|
46
|
+
return 1;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
++aIdx;
|
|
50
|
+
++bIdx;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return aStr.length - bStr.length;
|
|
55
|
+
}
|
|
56
|
+
var DIGIT_0 = 48;
|
|
57
|
+
var DIGIT_9 = 57;
|
|
58
|
+
|
|
59
|
+
function isDigit(code) {
|
|
60
|
+
return !isNaN(code) && DIGIT_0 <= code && code <= DIGIT_9;
|
|
61
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = safeArrayFrom;
|
|
7
|
+
|
|
8
|
+
var _symbols = require("../polyfills/symbols.js");
|
|
9
|
+
|
|
10
|
+
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); }
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Safer version of `Array.from` that return `null` if value isn't convertible to array.
|
|
14
|
+
* Also protects against Array-like objects without items.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
*
|
|
18
|
+
* safeArrayFrom([ 1, 2, 3 ]) // [1, 2, 3]
|
|
19
|
+
* safeArrayFrom('ABC') // null
|
|
20
|
+
* safeArrayFrom({ length: 1 }) // null
|
|
21
|
+
* safeArrayFrom({ length: 1, 0: 'Alpha' }) // ['Alpha']
|
|
22
|
+
* safeArrayFrom({ key: 'value' }) // null
|
|
23
|
+
* safeArrayFrom(new Map()) // []
|
|
24
|
+
*
|
|
25
|
+
*/
|
|
26
|
+
function safeArrayFrom(collection) {
|
|
27
|
+
var mapFn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function (item) {
|
|
28
|
+
return item;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
if (collection == null || _typeof(collection) !== 'object') {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (Array.isArray(collection)) {
|
|
36
|
+
return collection.map(mapFn);
|
|
37
|
+
} // Is Iterable?
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
var iteratorMethod = collection[_symbols.SYMBOL_ITERATOR];
|
|
41
|
+
|
|
42
|
+
if (typeof iteratorMethod === 'function') {
|
|
43
|
+
// $FlowFixMe[incompatible-use]
|
|
44
|
+
var iterator = iteratorMethod.call(collection);
|
|
45
|
+
var result = [];
|
|
46
|
+
var step;
|
|
47
|
+
|
|
48
|
+
for (var i = 0; !(step = iterator.next()).done; ++i) {
|
|
49
|
+
result.push(mapFn(step.value, i));
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return result;
|
|
53
|
+
} // Is Array like?
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
var length = collection.length;
|
|
57
|
+
|
|
58
|
+
if (typeof length === 'number' && length >= 0 && length % 1 === 0) {
|
|
59
|
+
var _result = [];
|
|
60
|
+
|
|
61
|
+
for (var _i = 0; _i < length; ++_i) {
|
|
62
|
+
if (!Object.prototype.hasOwnProperty.call(collection, _i)) {
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
_result.push(mapFn(collection[String(_i)], _i));
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return _result;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return null;
|
|
73
|
+
}
|