@graphql-tools/utils 9.0.0-alpha-be1b2ebd.0 → 9.0.0-alpha-20221031181646-cd48ed2f
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/cjs/AccumulatorMap.js +21 -0
- package/cjs/AggregateError.js +25 -0
- package/cjs/Interfaces.js +31 -0
- package/cjs/Path.js +30 -0
- package/cjs/addTypes.js +62 -0
- package/cjs/astFromType.js +31 -0
- package/cjs/astFromValueUntyped.js +78 -0
- package/cjs/build-operation-for-field.js +351 -0
- package/cjs/collectFields.js +167 -0
- package/cjs/comments.js +380 -0
- package/cjs/directives.js +47 -0
- package/cjs/errors.js +22 -0
- package/cjs/executor.js +2 -0
- package/cjs/extractExtensionsFromSchema.js +63 -0
- package/cjs/fields.js +115 -0
- package/cjs/filterSchema.js +66 -0
- package/cjs/fixSchemaAst.js +26 -0
- package/cjs/forEachDefaultValue.js +29 -0
- package/cjs/forEachField.js +19 -0
- package/cjs/get-arguments-with-directives.js +33 -0
- package/cjs/get-directives.js +103 -0
- package/cjs/get-fields-with-directives.js +31 -0
- package/cjs/get-implementing-types.js +19 -0
- package/cjs/getArgumentValues.js +73 -0
- package/cjs/getObjectTypeFromTypeMap.js +13 -0
- package/cjs/getOperationASTFromRequest.js +16 -0
- package/cjs/getResolversFromSchema.js +73 -0
- package/cjs/getResponseKeyFromInfo.js +12 -0
- package/cjs/heal.js +178 -0
- package/cjs/helpers.js +76 -0
- package/cjs/implementsAbstractType.js +17 -0
- package/cjs/index.js +58 -0
- package/cjs/inspect.js +100 -0
- package/cjs/isAsyncIterable.js +10 -0
- package/cjs/isDocumentNode.js +8 -0
- package/cjs/jsutils.js +29 -0
- package/cjs/loaders.js +2 -0
- package/cjs/mapAsyncIterator.js +53 -0
- package/cjs/mapSchema.js +470 -0
- package/cjs/memoize.js +189 -0
- package/cjs/mergeDeep.js +45 -0
- package/cjs/observableToAsyncIterable.js +85 -0
- package/cjs/package.json +1 -0
- package/cjs/parse-graphql-json.js +44 -0
- package/cjs/parse-graphql-sdl.js +84 -0
- package/cjs/print-schema-with-directives.js +494 -0
- package/cjs/prune.js +158 -0
- package/cjs/renameType.js +152 -0
- package/cjs/rewire.js +160 -0
- package/cjs/rootTypes.js +40 -0
- package/cjs/selectionSets.js +9 -0
- package/cjs/stub.js +68 -0
- package/cjs/transformInputValue.js +55 -0
- package/cjs/types.js +27 -0
- package/cjs/updateArgument.js +54 -0
- package/cjs/validate-documents.js +41 -0
- package/cjs/valueMatchesCriteria.js +21 -0
- package/cjs/visitResult.js +229 -0
- package/cjs/withCancel.js +56 -0
- package/esm/AccumulatorMap.js +17 -0
- package/esm/AggregateError.js +21 -0
- package/esm/Interfaces.js +28 -0
- package/esm/Path.js +24 -0
- package/esm/addTypes.js +58 -0
- package/esm/astFromType.js +27 -0
- package/esm/astFromValueUntyped.js +74 -0
- package/esm/build-operation-for-field.js +347 -0
- package/esm/collectFields.js +159 -0
- package/esm/comments.js +367 -0
- package/esm/directives.js +44 -0
- package/esm/errors.js +17 -0
- package/esm/executor.js +1 -0
- package/esm/extractExtensionsFromSchema.js +59 -0
- package/esm/fields.js +108 -0
- package/esm/filterSchema.js +62 -0
- package/esm/fixSchemaAst.js +22 -0
- package/esm/forEachDefaultValue.js +25 -0
- package/esm/forEachField.js +15 -0
- package/esm/get-arguments-with-directives.js +29 -0
- package/esm/get-directives.js +96 -0
- package/esm/get-fields-with-directives.js +27 -0
- package/esm/get-implementing-types.js +15 -0
- package/esm/getArgumentValues.js +69 -0
- package/esm/getObjectTypeFromTypeMap.js +9 -0
- package/esm/getOperationASTFromRequest.js +12 -0
- package/esm/getResolversFromSchema.js +69 -0
- package/esm/getResponseKeyFromInfo.js +8 -0
- package/esm/heal.js +173 -0
- package/esm/helpers.js +65 -0
- package/esm/implementsAbstractType.js +13 -0
- package/esm/index.js +55 -0
- package/esm/inspect.js +96 -0
- package/esm/isAsyncIterable.js +6 -0
- package/esm/isDocumentNode.js +4 -0
- package/esm/jsutils.js +21 -0
- package/esm/loaders.js +1 -0
- package/esm/mapAsyncIterator.js +49 -0
- package/esm/mapSchema.js +465 -0
- package/esm/memoize.js +180 -0
- package/esm/mergeDeep.js +41 -0
- package/esm/observableToAsyncIterable.js +81 -0
- package/esm/parse-graphql-json.js +40 -0
- package/esm/parse-graphql-sdl.js +78 -0
- package/esm/print-schema-with-directives.js +472 -0
- package/esm/prune.js +154 -0
- package/esm/renameType.js +148 -0
- package/esm/rewire.js +156 -0
- package/esm/rootTypes.js +36 -0
- package/esm/selectionSets.js +5 -0
- package/esm/stub.js +61 -0
- package/esm/transformInputValue.js +48 -0
- package/esm/types.js +24 -0
- package/esm/updateArgument.js +49 -0
- package/esm/validate-documents.js +36 -0
- package/esm/valueMatchesCriteria.js +17 -0
- package/esm/visitResult.js +223 -0
- package/esm/withCancel.js +51 -0
- package/package.json +35 -13
- package/typings/AccumulatorMap.d.cts +7 -0
- package/typings/AccumulatorMap.d.ts +7 -0
- package/typings/AggregateError.d.cts +11 -0
- package/{AggregateError.d.ts → typings/AggregateError.d.ts} +1 -0
- package/typings/Interfaces.d.cts +252 -0
- package/{Interfaces.d.ts → typings/Interfaces.d.ts} +15 -5
- package/typings/Path.d.cts +18 -0
- package/typings/Path.d.ts +18 -0
- package/{addTypes.d.ts → typings/addTypes.d.cts} +0 -0
- package/typings/addTypes.d.ts +2 -0
- package/{astFromType.d.ts → typings/astFromType.d.cts} +0 -0
- package/typings/astFromType.d.ts +2 -0
- package/{astFromValueUntyped.d.ts → typings/astFromValueUntyped.d.cts} +0 -0
- package/typings/astFromValueUntyped.d.ts +17 -0
- package/{build-operation-for-field.d.ts → typings/build-operation-for-field.d.cts} +0 -0
- package/typings/build-operation-for-field.d.ts +18 -0
- package/typings/collectFields.d.cts +51 -0
- package/typings/collectFields.d.ts +51 -0
- package/{comments.d.ts → typings/comments.d.cts} +0 -0
- package/typings/comments.d.ts +30 -0
- package/typings/directives.d.cts +9 -0
- package/typings/directives.d.ts +9 -0
- package/typings/errors.d.cts +15 -0
- package/typings/errors.d.ts +15 -0
- package/typings/executor.d.cts +6 -0
- package/typings/executor.d.ts +6 -0
- package/typings/extractExtensionsFromSchema.d.cts +3 -0
- package/typings/extractExtensionsFromSchema.d.ts +3 -0
- package/{fields.d.ts → typings/fields.d.cts} +0 -0
- package/typings/fields.d.ts +5 -0
- package/typings/filterSchema.d.cts +12 -0
- package/{filterSchema.d.ts → typings/filterSchema.d.ts} +1 -1
- package/typings/fixSchemaAst.d.cts +3 -0
- package/{fixSchemaAst.d.ts → typings/fixSchemaAst.d.ts} +1 -1
- package/typings/forEachDefaultValue.d.cts +3 -0
- package/{forEachDefaultValue.d.ts → typings/forEachDefaultValue.d.ts} +1 -1
- package/typings/forEachField.d.cts +3 -0
- package/{forEachField.d.ts → typings/forEachField.d.ts} +1 -1
- package/typings/get-arguments-with-directives.d.cts +9 -0
- package/typings/get-arguments-with-directives.d.ts +9 -0
- package/{get-directives.d.ts → typings/get-directives.d.cts} +0 -0
- package/typings/get-directives.d.ts +11 -0
- package/typings/get-fields-with-directives.d.cts +10 -0
- package/{get-fields-with-directives.d.ts → typings/get-fields-with-directives.d.ts} +1 -7
- package/{get-implementing-types.d.ts → typings/get-implementing-types.d.cts} +0 -0
- package/typings/get-implementing-types.d.ts +2 -0
- package/{getArgumentValues.d.ts → typings/getArgumentValues.d.cts} +0 -0
- package/typings/getArgumentValues.d.ts +10 -0
- package/typings/getObjectTypeFromTypeMap.d.cts +3 -0
- package/{getObjectTypeFromTypeMap.d.ts → typings/getObjectTypeFromTypeMap.d.ts} +1 -1
- package/typings/getOperationASTFromRequest.d.cts +4 -0
- package/typings/getOperationASTFromRequest.d.ts +4 -0
- package/typings/getResolversFromSchema.d.cts +3 -0
- package/{getResolversFromSchema.d.ts → typings/getResolversFromSchema.d.ts} +2 -2
- package/{getResponseKeyFromInfo.d.ts → typings/getResponseKeyFromInfo.d.cts} +0 -0
- package/typings/getResponseKeyFromInfo.d.ts +7 -0
- package/{heal.d.ts → typings/heal.d.cts} +0 -0
- package/typings/heal.d.ts +3 -0
- package/{helpers.d.ts → typings/helpers.d.cts} +0 -0
- package/typings/helpers.d.ts +9 -0
- package/typings/implementsAbstractType.d.cts +3 -0
- package/{implementsAbstractType.d.ts → typings/implementsAbstractType.d.ts} +1 -1
- package/typings/index.d.cts +55 -0
- package/typings/index.d.ts +55 -0
- package/{inspect.d.ts → typings/inspect.d.cts} +0 -0
- package/typings/inspect.d.ts +4 -0
- package/typings/isAsyncIterable.d.cts +1 -0
- package/{isAsyncIterable.d.ts → typings/isAsyncIterable.d.ts} +1 -1
- package/{isDocumentNode.d.ts → typings/isDocumentNode.d.cts} +0 -0
- package/typings/isDocumentNode.d.ts +2 -0
- package/typings/jsutils.d.cts +8 -0
- package/typings/jsutils.d.ts +8 -0
- package/typings/loaders.d.cts +18 -0
- package/{loaders.d.ts → typings/loaders.d.ts} +1 -1
- package/{mapAsyncIterator.d.ts → typings/mapAsyncIterator.d.cts} +0 -0
- package/typings/mapAsyncIterator.d.ts +5 -0
- package/typings/mapSchema.d.cts +7 -0
- package/{mapSchema.d.ts → typings/mapSchema.d.ts} +1 -1
- package/typings/memoize.d.cts +6 -0
- package/{memoize.d.ts → typings/memoize.d.ts} +0 -2
- package/{mergeDeep.d.ts → typings/mergeDeep.d.cts} +0 -0
- package/typings/mergeDeep.d.ts +9 -0
- package/{observableToAsyncIterable.d.ts → typings/observableToAsyncIterable.d.cts} +0 -0
- package/typings/observableToAsyncIterable.d.ts +12 -0
- package/typings/parse-graphql-json.d.cts +4 -0
- package/{parse-graphql-json.d.ts → typings/parse-graphql-json.d.ts} +2 -2
- package/typings/parse-graphql-sdl.d.cts +13 -0
- package/{parse-graphql-sdl.d.ts → typings/parse-graphql-sdl.d.ts} +1 -1
- package/typings/print-schema-with-directives.d.cts +21 -0
- package/{print-schema-with-directives.d.ts → typings/print-schema-with-directives.d.ts} +2 -2
- package/typings/prune.d.cts +8 -0
- package/{prune.d.ts → typings/prune.d.ts} +1 -1
- package/{renameType.d.ts → typings/renameType.d.cts} +0 -0
- package/typings/renameType.d.ts +8 -0
- package/{rewire.d.ts → typings/rewire.d.cts} +0 -0
- package/typings/rewire.d.ts +5 -0
- package/typings/rootTypes.d.cts +5 -0
- package/{rootTypes.d.ts → typings/rootTypes.d.ts} +2 -2
- package/typings/selectionSets.d.cts +3 -0
- package/{selectionSets.d.ts → typings/selectionSets.d.ts} +1 -1
- package/{stub.d.ts → typings/stub.d.cts} +0 -0
- package/typings/stub.d.ts +9 -0
- package/typings/transformInputValue.d.cts +6 -0
- package/{transformInputValue.d.ts → typings/transformInputValue.d.ts} +1 -1
- package/typings/types.d.cts +119 -0
- package/typings/types.d.ts +119 -0
- package/{updateArgument.d.ts → typings/updateArgument.d.cts} +0 -0
- package/typings/updateArgument.d.ts +3 -0
- package/typings/validate-documents.d.cts +4 -0
- package/typings/validate-documents.d.ts +4 -0
- package/{valueMatchesCriteria.d.ts → typings/valueMatchesCriteria.d.cts} +0 -0
- package/typings/valueMatchesCriteria.d.ts +1 -0
- package/typings/visitResult.d.cts +15 -0
- package/{visitResult.d.ts → typings/visitResult.d.ts} +1 -1
- package/typings/withCancel.d.cts +3 -0
- package/typings/withCancel.d.ts +3 -0
- package/collectFields.d.ts +0 -5
- package/errors.d.ts +0 -2
- package/executor.d.ts +0 -7
- package/index.d.ts +0 -49
- package/index.js +0 -4345
- package/index.mjs +0 -4235
- package/types.d.ts +0 -49
- package/validate-documents.d.ts +0 -9
- package/withCancel.d.ts +0 -3
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AccumulatorMap = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* ES6 Map with additional `add` method to accumulate items.
|
|
6
|
+
*/
|
|
7
|
+
class AccumulatorMap extends Map {
|
|
8
|
+
get [Symbol.toStringTag]() {
|
|
9
|
+
return 'AccumulatorMap';
|
|
10
|
+
}
|
|
11
|
+
add(key, item) {
|
|
12
|
+
const group = this.get(key);
|
|
13
|
+
if (group === undefined) {
|
|
14
|
+
this.set(key, [item]);
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
group.push(item);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.AccumulatorMap = AccumulatorMap;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isAggregateError = exports.AggregateError = void 0;
|
|
4
|
+
let AggregateErrorImpl;
|
|
5
|
+
exports.AggregateError = AggregateErrorImpl;
|
|
6
|
+
if (typeof AggregateError === 'undefined') {
|
|
7
|
+
class AggregateErrorClass extends Error {
|
|
8
|
+
constructor(errors, message = '') {
|
|
9
|
+
super(message);
|
|
10
|
+
this.errors = errors;
|
|
11
|
+
this.name = 'AggregateError';
|
|
12
|
+
Error.captureStackTrace(this, AggregateErrorClass);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
exports.AggregateError = AggregateErrorImpl = function (errors, message) {
|
|
16
|
+
return new AggregateErrorClass(errors, message);
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
exports.AggregateError = AggregateErrorImpl = AggregateError;
|
|
21
|
+
}
|
|
22
|
+
function isAggregateError(error) {
|
|
23
|
+
return 'errors' in error && Array.isArray(error['errors']);
|
|
24
|
+
}
|
|
25
|
+
exports.isAggregateError = isAggregateError;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MapperKind = void 0;
|
|
4
|
+
var MapperKind;
|
|
5
|
+
(function (MapperKind) {
|
|
6
|
+
MapperKind["TYPE"] = "MapperKind.TYPE";
|
|
7
|
+
MapperKind["SCALAR_TYPE"] = "MapperKind.SCALAR_TYPE";
|
|
8
|
+
MapperKind["ENUM_TYPE"] = "MapperKind.ENUM_TYPE";
|
|
9
|
+
MapperKind["COMPOSITE_TYPE"] = "MapperKind.COMPOSITE_TYPE";
|
|
10
|
+
MapperKind["OBJECT_TYPE"] = "MapperKind.OBJECT_TYPE";
|
|
11
|
+
MapperKind["INPUT_OBJECT_TYPE"] = "MapperKind.INPUT_OBJECT_TYPE";
|
|
12
|
+
MapperKind["ABSTRACT_TYPE"] = "MapperKind.ABSTRACT_TYPE";
|
|
13
|
+
MapperKind["UNION_TYPE"] = "MapperKind.UNION_TYPE";
|
|
14
|
+
MapperKind["INTERFACE_TYPE"] = "MapperKind.INTERFACE_TYPE";
|
|
15
|
+
MapperKind["ROOT_OBJECT"] = "MapperKind.ROOT_OBJECT";
|
|
16
|
+
MapperKind["QUERY"] = "MapperKind.QUERY";
|
|
17
|
+
MapperKind["MUTATION"] = "MapperKind.MUTATION";
|
|
18
|
+
MapperKind["SUBSCRIPTION"] = "MapperKind.SUBSCRIPTION";
|
|
19
|
+
MapperKind["DIRECTIVE"] = "MapperKind.DIRECTIVE";
|
|
20
|
+
MapperKind["FIELD"] = "MapperKind.FIELD";
|
|
21
|
+
MapperKind["COMPOSITE_FIELD"] = "MapperKind.COMPOSITE_FIELD";
|
|
22
|
+
MapperKind["OBJECT_FIELD"] = "MapperKind.OBJECT_FIELD";
|
|
23
|
+
MapperKind["ROOT_FIELD"] = "MapperKind.ROOT_FIELD";
|
|
24
|
+
MapperKind["QUERY_ROOT_FIELD"] = "MapperKind.QUERY_ROOT_FIELD";
|
|
25
|
+
MapperKind["MUTATION_ROOT_FIELD"] = "MapperKind.MUTATION_ROOT_FIELD";
|
|
26
|
+
MapperKind["SUBSCRIPTION_ROOT_FIELD"] = "MapperKind.SUBSCRIPTION_ROOT_FIELD";
|
|
27
|
+
MapperKind["INTERFACE_FIELD"] = "MapperKind.INTERFACE_FIELD";
|
|
28
|
+
MapperKind["INPUT_OBJECT_FIELD"] = "MapperKind.INPUT_OBJECT_FIELD";
|
|
29
|
+
MapperKind["ARGUMENT"] = "MapperKind.ARGUMENT";
|
|
30
|
+
MapperKind["ENUM_VALUE"] = "MapperKind.ENUM_VALUE";
|
|
31
|
+
})(MapperKind = exports.MapperKind || (exports.MapperKind = {}));
|
package/cjs/Path.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.printPathArray = exports.pathToArray = exports.addPath = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Given a Path and a key, return a new Path containing the new key.
|
|
6
|
+
*/
|
|
7
|
+
function addPath(prev, key, typename) {
|
|
8
|
+
return { prev, key, typename };
|
|
9
|
+
}
|
|
10
|
+
exports.addPath = addPath;
|
|
11
|
+
/**
|
|
12
|
+
* Given a Path, return an Array of the path keys.
|
|
13
|
+
*/
|
|
14
|
+
function pathToArray(path) {
|
|
15
|
+
const flattened = [];
|
|
16
|
+
let curr = path;
|
|
17
|
+
while (curr) {
|
|
18
|
+
flattened.push(curr.key);
|
|
19
|
+
curr = curr.prev;
|
|
20
|
+
}
|
|
21
|
+
return flattened.reverse();
|
|
22
|
+
}
|
|
23
|
+
exports.pathToArray = pathToArray;
|
|
24
|
+
/**
|
|
25
|
+
* Build a string describing the path.
|
|
26
|
+
*/
|
|
27
|
+
function printPathArray(path) {
|
|
28
|
+
return path.map(key => (typeof key === 'number' ? '[' + key.toString() + ']' : '.' + key)).join('');
|
|
29
|
+
}
|
|
30
|
+
exports.printPathArray = printPathArray;
|
package/cjs/addTypes.js
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// addTypes uses toConfig to create a new schema with a new or replaced
|
|
3
|
+
// type or directive. Rewiring is employed so that the replaced type can be
|
|
4
|
+
// reconnected with the existing types.
|
|
5
|
+
//
|
|
6
|
+
// Rewiring is employed even for new types or directives as a convenience, so
|
|
7
|
+
// that type references within the new type or directive do not have to be to
|
|
8
|
+
// the identical objects within the original schema.
|
|
9
|
+
//
|
|
10
|
+
// In fact, the type references could even be stub types with entirely different
|
|
11
|
+
// fields, as long as the type references share the same name as the desired
|
|
12
|
+
// type within the original schema's type map.
|
|
13
|
+
//
|
|
14
|
+
// This makes it easy to perform simple schema operations (e.g. adding a new
|
|
15
|
+
// type with a fiew fields removed from an existing type) that could normally be
|
|
16
|
+
// performed by using toConfig directly, but is blocked if any intervening
|
|
17
|
+
// more advanced schema operations have caused the types to be recreated via
|
|
18
|
+
// rewiring.
|
|
19
|
+
//
|
|
20
|
+
// Type recreation happens, for example, with every use of mapSchema, as the
|
|
21
|
+
// types are always rewired. If fields are selected and removed using
|
|
22
|
+
// mapSchema, adding those fields to a new type can no longer be simply done
|
|
23
|
+
// by toConfig, as the types are not the identical JavaScript objects, and
|
|
24
|
+
// schema creation will fail with errors referencing multiple types with the
|
|
25
|
+
// same names.
|
|
26
|
+
//
|
|
27
|
+
// enhanceSchema can fill this gap by adding an additional round of rewiring.
|
|
28
|
+
//
|
|
29
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
|
+
exports.addTypes = void 0;
|
|
31
|
+
const graphql_1 = require("graphql");
|
|
32
|
+
const getObjectTypeFromTypeMap_js_1 = require("./getObjectTypeFromTypeMap.js");
|
|
33
|
+
const rewire_js_1 = require("./rewire.js");
|
|
34
|
+
function addTypes(schema, newTypesOrDirectives) {
|
|
35
|
+
const config = schema.toConfig();
|
|
36
|
+
const originalTypeMap = {};
|
|
37
|
+
for (const type of config.types) {
|
|
38
|
+
originalTypeMap[type.name] = type;
|
|
39
|
+
}
|
|
40
|
+
const originalDirectiveMap = {};
|
|
41
|
+
for (const directive of config.directives) {
|
|
42
|
+
originalDirectiveMap[directive.name] = directive;
|
|
43
|
+
}
|
|
44
|
+
for (const newTypeOrDirective of newTypesOrDirectives) {
|
|
45
|
+
if ((0, graphql_1.isNamedType)(newTypeOrDirective)) {
|
|
46
|
+
originalTypeMap[newTypeOrDirective.name] = newTypeOrDirective;
|
|
47
|
+
}
|
|
48
|
+
else if ((0, graphql_1.isDirective)(newTypeOrDirective)) {
|
|
49
|
+
originalDirectiveMap[newTypeOrDirective.name] = newTypeOrDirective;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
const { typeMap, directives } = (0, rewire_js_1.rewireTypes)(originalTypeMap, Object.values(originalDirectiveMap));
|
|
53
|
+
return new graphql_1.GraphQLSchema({
|
|
54
|
+
...config,
|
|
55
|
+
query: (0, getObjectTypeFromTypeMap_js_1.getObjectTypeFromTypeMap)(typeMap, schema.getQueryType()),
|
|
56
|
+
mutation: (0, getObjectTypeFromTypeMap_js_1.getObjectTypeFromTypeMap)(typeMap, schema.getMutationType()),
|
|
57
|
+
subscription: (0, getObjectTypeFromTypeMap_js_1.getObjectTypeFromTypeMap)(typeMap, schema.getSubscriptionType()),
|
|
58
|
+
types: Object.values(typeMap),
|
|
59
|
+
directives,
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
exports.addTypes = addTypes;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.astFromType = void 0;
|
|
4
|
+
const graphql_1 = require("graphql");
|
|
5
|
+
const inspect_js_1 = require("./inspect.js");
|
|
6
|
+
function astFromType(type) {
|
|
7
|
+
if ((0, graphql_1.isNonNullType)(type)) {
|
|
8
|
+
const innerType = astFromType(type.ofType);
|
|
9
|
+
if (innerType.kind === graphql_1.Kind.NON_NULL_TYPE) {
|
|
10
|
+
throw new Error(`Invalid type node ${(0, inspect_js_1.inspect)(type)}. Inner type of non-null type cannot be a non-null type.`);
|
|
11
|
+
}
|
|
12
|
+
return {
|
|
13
|
+
kind: graphql_1.Kind.NON_NULL_TYPE,
|
|
14
|
+
type: innerType,
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
else if ((0, graphql_1.isListType)(type)) {
|
|
18
|
+
return {
|
|
19
|
+
kind: graphql_1.Kind.LIST_TYPE,
|
|
20
|
+
type: astFromType(type.ofType),
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
return {
|
|
24
|
+
kind: graphql_1.Kind.NAMED_TYPE,
|
|
25
|
+
name: {
|
|
26
|
+
kind: graphql_1.Kind.NAME,
|
|
27
|
+
value: type.name,
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
exports.astFromType = astFromType;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.astFromValueUntyped = void 0;
|
|
4
|
+
const graphql_1 = require("graphql");
|
|
5
|
+
/**
|
|
6
|
+
* Produces a GraphQL Value AST given a JavaScript object.
|
|
7
|
+
* Function will match JavaScript/JSON values to GraphQL AST schema format
|
|
8
|
+
* by using the following mapping.
|
|
9
|
+
*
|
|
10
|
+
* | JSON Value | GraphQL Value |
|
|
11
|
+
* | ------------- | -------------------- |
|
|
12
|
+
* | Object | Input Object |
|
|
13
|
+
* | Array | List |
|
|
14
|
+
* | Boolean | Boolean |
|
|
15
|
+
* | String | String |
|
|
16
|
+
* | Number | Int / Float |
|
|
17
|
+
* | null | NullValue |
|
|
18
|
+
*
|
|
19
|
+
*/
|
|
20
|
+
function astFromValueUntyped(value) {
|
|
21
|
+
// only explicit null, not undefined, NaN
|
|
22
|
+
if (value === null) {
|
|
23
|
+
return { kind: graphql_1.Kind.NULL };
|
|
24
|
+
}
|
|
25
|
+
// undefined
|
|
26
|
+
if (value === undefined) {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
// Convert JavaScript array to GraphQL list. If the GraphQLType is a list, but
|
|
30
|
+
// the value is not an array, convert the value using the list's item type.
|
|
31
|
+
if (Array.isArray(value)) {
|
|
32
|
+
const valuesNodes = [];
|
|
33
|
+
for (const item of value) {
|
|
34
|
+
const itemNode = astFromValueUntyped(item);
|
|
35
|
+
if (itemNode != null) {
|
|
36
|
+
valuesNodes.push(itemNode);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return { kind: graphql_1.Kind.LIST, values: valuesNodes };
|
|
40
|
+
}
|
|
41
|
+
if (typeof value === 'object') {
|
|
42
|
+
const fieldNodes = [];
|
|
43
|
+
for (const fieldName in value) {
|
|
44
|
+
const fieldValue = value[fieldName];
|
|
45
|
+
const ast = astFromValueUntyped(fieldValue);
|
|
46
|
+
if (ast) {
|
|
47
|
+
fieldNodes.push({
|
|
48
|
+
kind: graphql_1.Kind.OBJECT_FIELD,
|
|
49
|
+
name: { kind: graphql_1.Kind.NAME, value: fieldName },
|
|
50
|
+
value: ast,
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return { kind: graphql_1.Kind.OBJECT, fields: fieldNodes };
|
|
55
|
+
}
|
|
56
|
+
// Others serialize based on their corresponding JavaScript scalar types.
|
|
57
|
+
if (typeof value === 'boolean') {
|
|
58
|
+
return { kind: graphql_1.Kind.BOOLEAN, value };
|
|
59
|
+
}
|
|
60
|
+
// JavaScript numbers can be Int or Float values.
|
|
61
|
+
if (typeof value === 'number' && isFinite(value)) {
|
|
62
|
+
const stringNum = String(value);
|
|
63
|
+
return integerStringRegExp.test(stringNum)
|
|
64
|
+
? { kind: graphql_1.Kind.INT, value: stringNum }
|
|
65
|
+
: { kind: graphql_1.Kind.FLOAT, value: stringNum };
|
|
66
|
+
}
|
|
67
|
+
if (typeof value === 'string') {
|
|
68
|
+
return { kind: graphql_1.Kind.STRING, value };
|
|
69
|
+
}
|
|
70
|
+
throw new TypeError(`Cannot convert value to AST: ${value}.`);
|
|
71
|
+
}
|
|
72
|
+
exports.astFromValueUntyped = astFromValueUntyped;
|
|
73
|
+
/**
|
|
74
|
+
* IntValue:
|
|
75
|
+
* - NegativeSign? 0
|
|
76
|
+
* - NegativeSign? NonZeroDigit ( Digit+ )?
|
|
77
|
+
*/
|
|
78
|
+
const integerStringRegExp = /^-?(?:0|[1-9][0-9]*)$/;
|
|
@@ -0,0 +1,351 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildOperationNodeForField = void 0;
|
|
4
|
+
const graphql_1 = require("graphql");
|
|
5
|
+
const rootTypes_js_1 = require("./rootTypes.js");
|
|
6
|
+
let operationVariables = [];
|
|
7
|
+
let fieldTypeMap = new Map();
|
|
8
|
+
function addOperationVariable(variable) {
|
|
9
|
+
operationVariables.push(variable);
|
|
10
|
+
}
|
|
11
|
+
function resetOperationVariables() {
|
|
12
|
+
operationVariables = [];
|
|
13
|
+
}
|
|
14
|
+
function resetFieldMap() {
|
|
15
|
+
fieldTypeMap = new Map();
|
|
16
|
+
}
|
|
17
|
+
function buildOperationNodeForField({ schema, kind, field, models, ignore = [], depthLimit, circularReferenceDepth, argNames, selectedFields = true, }) {
|
|
18
|
+
resetOperationVariables();
|
|
19
|
+
resetFieldMap();
|
|
20
|
+
const rootTypeNames = (0, rootTypes_js_1.getRootTypeNames)(schema);
|
|
21
|
+
const operationNode = buildOperationAndCollectVariables({
|
|
22
|
+
schema,
|
|
23
|
+
fieldName: field,
|
|
24
|
+
kind,
|
|
25
|
+
models: models || [],
|
|
26
|
+
ignore,
|
|
27
|
+
depthLimit: depthLimit || Infinity,
|
|
28
|
+
circularReferenceDepth: circularReferenceDepth || 1,
|
|
29
|
+
argNames,
|
|
30
|
+
selectedFields,
|
|
31
|
+
rootTypeNames,
|
|
32
|
+
});
|
|
33
|
+
// attach variables
|
|
34
|
+
operationNode.variableDefinitions = [...operationVariables];
|
|
35
|
+
resetOperationVariables();
|
|
36
|
+
resetFieldMap();
|
|
37
|
+
return operationNode;
|
|
38
|
+
}
|
|
39
|
+
exports.buildOperationNodeForField = buildOperationNodeForField;
|
|
40
|
+
function buildOperationAndCollectVariables({ schema, fieldName, kind, models, ignore, depthLimit, circularReferenceDepth, argNames, selectedFields, rootTypeNames, }) {
|
|
41
|
+
const type = (0, rootTypes_js_1.getDefinedRootType)(schema, kind);
|
|
42
|
+
const field = type.getFields()[fieldName];
|
|
43
|
+
const operationName = `${fieldName}_${kind}`;
|
|
44
|
+
if (field.args) {
|
|
45
|
+
for (const arg of field.args) {
|
|
46
|
+
const argName = arg.name;
|
|
47
|
+
if (!argNames || argNames.includes(argName)) {
|
|
48
|
+
addOperationVariable(resolveVariable(arg, argName));
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return {
|
|
53
|
+
kind: graphql_1.Kind.OPERATION_DEFINITION,
|
|
54
|
+
operation: kind,
|
|
55
|
+
name: {
|
|
56
|
+
kind: graphql_1.Kind.NAME,
|
|
57
|
+
value: operationName,
|
|
58
|
+
},
|
|
59
|
+
variableDefinitions: [],
|
|
60
|
+
selectionSet: {
|
|
61
|
+
kind: graphql_1.Kind.SELECTION_SET,
|
|
62
|
+
selections: [
|
|
63
|
+
resolveField({
|
|
64
|
+
type,
|
|
65
|
+
field,
|
|
66
|
+
models,
|
|
67
|
+
firstCall: true,
|
|
68
|
+
path: [],
|
|
69
|
+
ancestors: [],
|
|
70
|
+
ignore,
|
|
71
|
+
depthLimit,
|
|
72
|
+
circularReferenceDepth,
|
|
73
|
+
schema,
|
|
74
|
+
depth: 0,
|
|
75
|
+
argNames,
|
|
76
|
+
selectedFields,
|
|
77
|
+
rootTypeNames,
|
|
78
|
+
}),
|
|
79
|
+
],
|
|
80
|
+
},
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
function resolveSelectionSet({ parent, type, models, firstCall, path, ancestors, ignore, depthLimit, circularReferenceDepth, schema, depth, argNames, selectedFields, rootTypeNames, }) {
|
|
84
|
+
if (typeof selectedFields === 'boolean' && depth > depthLimit) {
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
if ((0, graphql_1.isUnionType)(type)) {
|
|
88
|
+
const types = type.getTypes();
|
|
89
|
+
return {
|
|
90
|
+
kind: graphql_1.Kind.SELECTION_SET,
|
|
91
|
+
selections: types
|
|
92
|
+
.filter(t => !hasCircularRef([...ancestors, t], {
|
|
93
|
+
depth: circularReferenceDepth,
|
|
94
|
+
}))
|
|
95
|
+
.map(t => {
|
|
96
|
+
return {
|
|
97
|
+
kind: graphql_1.Kind.INLINE_FRAGMENT,
|
|
98
|
+
typeCondition: {
|
|
99
|
+
kind: graphql_1.Kind.NAMED_TYPE,
|
|
100
|
+
name: {
|
|
101
|
+
kind: graphql_1.Kind.NAME,
|
|
102
|
+
value: t.name,
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
selectionSet: resolveSelectionSet({
|
|
106
|
+
parent: type,
|
|
107
|
+
type: t,
|
|
108
|
+
models,
|
|
109
|
+
path,
|
|
110
|
+
ancestors,
|
|
111
|
+
ignore,
|
|
112
|
+
depthLimit,
|
|
113
|
+
circularReferenceDepth,
|
|
114
|
+
schema,
|
|
115
|
+
depth,
|
|
116
|
+
argNames,
|
|
117
|
+
selectedFields,
|
|
118
|
+
rootTypeNames,
|
|
119
|
+
}),
|
|
120
|
+
};
|
|
121
|
+
})
|
|
122
|
+
.filter(fragmentNode => { var _a, _b; return ((_b = (_a = fragmentNode === null || fragmentNode === void 0 ? void 0 : fragmentNode.selectionSet) === null || _a === void 0 ? void 0 : _a.selections) === null || _b === void 0 ? void 0 : _b.length) > 0; }),
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
if ((0, graphql_1.isInterfaceType)(type)) {
|
|
126
|
+
const types = Object.values(schema.getTypeMap()).filter((t) => (0, graphql_1.isObjectType)(t) && t.getInterfaces().includes(type));
|
|
127
|
+
return {
|
|
128
|
+
kind: graphql_1.Kind.SELECTION_SET,
|
|
129
|
+
selections: types
|
|
130
|
+
.filter(t => !hasCircularRef([...ancestors, t], {
|
|
131
|
+
depth: circularReferenceDepth,
|
|
132
|
+
}))
|
|
133
|
+
.map(t => {
|
|
134
|
+
return {
|
|
135
|
+
kind: graphql_1.Kind.INLINE_FRAGMENT,
|
|
136
|
+
typeCondition: {
|
|
137
|
+
kind: graphql_1.Kind.NAMED_TYPE,
|
|
138
|
+
name: {
|
|
139
|
+
kind: graphql_1.Kind.NAME,
|
|
140
|
+
value: t.name,
|
|
141
|
+
},
|
|
142
|
+
},
|
|
143
|
+
selectionSet: resolveSelectionSet({
|
|
144
|
+
parent: type,
|
|
145
|
+
type: t,
|
|
146
|
+
models,
|
|
147
|
+
path,
|
|
148
|
+
ancestors,
|
|
149
|
+
ignore,
|
|
150
|
+
depthLimit,
|
|
151
|
+
circularReferenceDepth,
|
|
152
|
+
schema,
|
|
153
|
+
depth,
|
|
154
|
+
argNames,
|
|
155
|
+
selectedFields,
|
|
156
|
+
rootTypeNames,
|
|
157
|
+
}),
|
|
158
|
+
};
|
|
159
|
+
})
|
|
160
|
+
.filter(fragmentNode => { var _a, _b; return ((_b = (_a = fragmentNode === null || fragmentNode === void 0 ? void 0 : fragmentNode.selectionSet) === null || _a === void 0 ? void 0 : _a.selections) === null || _b === void 0 ? void 0 : _b.length) > 0; }),
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
if ((0, graphql_1.isObjectType)(type) && !rootTypeNames.has(type.name)) {
|
|
164
|
+
const isIgnored = ignore.includes(type.name) || ignore.includes(`${parent.name}.${path[path.length - 1]}`);
|
|
165
|
+
const isModel = models.includes(type.name);
|
|
166
|
+
if (!firstCall && isModel && !isIgnored) {
|
|
167
|
+
return {
|
|
168
|
+
kind: graphql_1.Kind.SELECTION_SET,
|
|
169
|
+
selections: [
|
|
170
|
+
{
|
|
171
|
+
kind: graphql_1.Kind.FIELD,
|
|
172
|
+
name: {
|
|
173
|
+
kind: graphql_1.Kind.NAME,
|
|
174
|
+
value: 'id',
|
|
175
|
+
},
|
|
176
|
+
},
|
|
177
|
+
],
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
const fields = type.getFields();
|
|
181
|
+
return {
|
|
182
|
+
kind: graphql_1.Kind.SELECTION_SET,
|
|
183
|
+
selections: Object.keys(fields)
|
|
184
|
+
.filter(fieldName => {
|
|
185
|
+
return !hasCircularRef([...ancestors, (0, graphql_1.getNamedType)(fields[fieldName].type)], {
|
|
186
|
+
depth: circularReferenceDepth,
|
|
187
|
+
});
|
|
188
|
+
})
|
|
189
|
+
.map(fieldName => {
|
|
190
|
+
const selectedSubFields = typeof selectedFields === 'object' ? selectedFields[fieldName] : true;
|
|
191
|
+
if (selectedSubFields) {
|
|
192
|
+
return resolveField({
|
|
193
|
+
type,
|
|
194
|
+
field: fields[fieldName],
|
|
195
|
+
models,
|
|
196
|
+
path: [...path, fieldName],
|
|
197
|
+
ancestors,
|
|
198
|
+
ignore,
|
|
199
|
+
depthLimit,
|
|
200
|
+
circularReferenceDepth,
|
|
201
|
+
schema,
|
|
202
|
+
depth,
|
|
203
|
+
argNames,
|
|
204
|
+
selectedFields: selectedSubFields,
|
|
205
|
+
rootTypeNames,
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
return null;
|
|
209
|
+
})
|
|
210
|
+
.filter((f) => {
|
|
211
|
+
var _a, _b;
|
|
212
|
+
if (f == null) {
|
|
213
|
+
return false;
|
|
214
|
+
}
|
|
215
|
+
else if ('selectionSet' in f) {
|
|
216
|
+
return !!((_b = (_a = f.selectionSet) === null || _a === void 0 ? void 0 : _a.selections) === null || _b === void 0 ? void 0 : _b.length);
|
|
217
|
+
}
|
|
218
|
+
return true;
|
|
219
|
+
}),
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
function resolveVariable(arg, name) {
|
|
224
|
+
function resolveVariableType(type) {
|
|
225
|
+
if ((0, graphql_1.isListType)(type)) {
|
|
226
|
+
return {
|
|
227
|
+
kind: graphql_1.Kind.LIST_TYPE,
|
|
228
|
+
type: resolveVariableType(type.ofType),
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
if ((0, graphql_1.isNonNullType)(type)) {
|
|
232
|
+
return {
|
|
233
|
+
kind: graphql_1.Kind.NON_NULL_TYPE,
|
|
234
|
+
// for v16 compatibility
|
|
235
|
+
type: resolveVariableType(type.ofType),
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
return {
|
|
239
|
+
kind: graphql_1.Kind.NAMED_TYPE,
|
|
240
|
+
name: {
|
|
241
|
+
kind: graphql_1.Kind.NAME,
|
|
242
|
+
value: type.name,
|
|
243
|
+
},
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
return {
|
|
247
|
+
kind: graphql_1.Kind.VARIABLE_DEFINITION,
|
|
248
|
+
variable: {
|
|
249
|
+
kind: graphql_1.Kind.VARIABLE,
|
|
250
|
+
name: {
|
|
251
|
+
kind: graphql_1.Kind.NAME,
|
|
252
|
+
value: name || arg.name,
|
|
253
|
+
},
|
|
254
|
+
},
|
|
255
|
+
type: resolveVariableType(arg.type),
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
function getArgumentName(name, path) {
|
|
259
|
+
return [...path, name].join('_');
|
|
260
|
+
}
|
|
261
|
+
function resolveField({ type, field, models, firstCall, path, ancestors, ignore, depthLimit, circularReferenceDepth, schema, depth, argNames, selectedFields, rootTypeNames, }) {
|
|
262
|
+
const namedType = (0, graphql_1.getNamedType)(field.type);
|
|
263
|
+
let args = [];
|
|
264
|
+
let removeField = false;
|
|
265
|
+
if (field.args && field.args.length) {
|
|
266
|
+
args = field.args
|
|
267
|
+
.map(arg => {
|
|
268
|
+
const argumentName = getArgumentName(arg.name, path);
|
|
269
|
+
if (argNames && !argNames.includes(argumentName)) {
|
|
270
|
+
if ((0, graphql_1.isNonNullType)(arg.type)) {
|
|
271
|
+
removeField = true;
|
|
272
|
+
}
|
|
273
|
+
return null;
|
|
274
|
+
}
|
|
275
|
+
if (!firstCall) {
|
|
276
|
+
addOperationVariable(resolveVariable(arg, argumentName));
|
|
277
|
+
}
|
|
278
|
+
return {
|
|
279
|
+
kind: graphql_1.Kind.ARGUMENT,
|
|
280
|
+
name: {
|
|
281
|
+
kind: graphql_1.Kind.NAME,
|
|
282
|
+
value: arg.name,
|
|
283
|
+
},
|
|
284
|
+
value: {
|
|
285
|
+
kind: graphql_1.Kind.VARIABLE,
|
|
286
|
+
name: {
|
|
287
|
+
kind: graphql_1.Kind.NAME,
|
|
288
|
+
value: getArgumentName(arg.name, path),
|
|
289
|
+
},
|
|
290
|
+
},
|
|
291
|
+
};
|
|
292
|
+
})
|
|
293
|
+
.filter(Boolean);
|
|
294
|
+
}
|
|
295
|
+
if (removeField) {
|
|
296
|
+
return null;
|
|
297
|
+
}
|
|
298
|
+
const fieldPath = [...path, field.name];
|
|
299
|
+
const fieldPathStr = fieldPath.join('.');
|
|
300
|
+
let fieldName = field.name;
|
|
301
|
+
if (fieldTypeMap.has(fieldPathStr) && fieldTypeMap.get(fieldPathStr) !== field.type.toString()) {
|
|
302
|
+
fieldName += field.type.toString().replace('!', 'NonNull');
|
|
303
|
+
}
|
|
304
|
+
fieldTypeMap.set(fieldPathStr, field.type.toString());
|
|
305
|
+
if (!(0, graphql_1.isScalarType)(namedType) && !(0, graphql_1.isEnumType)(namedType)) {
|
|
306
|
+
return {
|
|
307
|
+
kind: graphql_1.Kind.FIELD,
|
|
308
|
+
name: {
|
|
309
|
+
kind: graphql_1.Kind.NAME,
|
|
310
|
+
value: field.name,
|
|
311
|
+
},
|
|
312
|
+
...(fieldName !== field.name && { alias: { kind: graphql_1.Kind.NAME, value: fieldName } }),
|
|
313
|
+
selectionSet: resolveSelectionSet({
|
|
314
|
+
parent: type,
|
|
315
|
+
type: namedType,
|
|
316
|
+
models,
|
|
317
|
+
firstCall,
|
|
318
|
+
path: fieldPath,
|
|
319
|
+
ancestors: [...ancestors, type],
|
|
320
|
+
ignore,
|
|
321
|
+
depthLimit,
|
|
322
|
+
circularReferenceDepth,
|
|
323
|
+
schema,
|
|
324
|
+
depth: depth + 1,
|
|
325
|
+
argNames,
|
|
326
|
+
selectedFields,
|
|
327
|
+
rootTypeNames,
|
|
328
|
+
}) || undefined,
|
|
329
|
+
arguments: args,
|
|
330
|
+
};
|
|
331
|
+
}
|
|
332
|
+
return {
|
|
333
|
+
kind: graphql_1.Kind.FIELD,
|
|
334
|
+
name: {
|
|
335
|
+
kind: graphql_1.Kind.NAME,
|
|
336
|
+
value: field.name,
|
|
337
|
+
},
|
|
338
|
+
...(fieldName !== field.name && { alias: { kind: graphql_1.Kind.NAME, value: fieldName } }),
|
|
339
|
+
arguments: args,
|
|
340
|
+
};
|
|
341
|
+
}
|
|
342
|
+
function hasCircularRef(types, config = {
|
|
343
|
+
depth: 1,
|
|
344
|
+
}) {
|
|
345
|
+
const type = types[types.length - 1];
|
|
346
|
+
if ((0, graphql_1.isScalarType)(type)) {
|
|
347
|
+
return false;
|
|
348
|
+
}
|
|
349
|
+
const size = types.filter(t => t.name === type.name).length;
|
|
350
|
+
return size > config.depth;
|
|
351
|
+
}
|