@graphql-tools/utils 10.0.3 → 10.0.4-alpha-20230721235650-3957843a
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/Path.js +3 -1
- package/cjs/astFromValue.js +5 -3
- package/cjs/build-operation-for-field.js +5 -1
- package/cjs/collectFields.js +2 -2
- package/cjs/comments.js +28 -4
- package/cjs/extractExtensionsFromSchema.js +6 -2
- package/cjs/fields.js +1 -1
- package/cjs/filterSchema.js +3 -3
- package/cjs/get-directives.js +4 -1
- package/cjs/getArgumentValues.js +1 -1
- package/cjs/inspect.js +3 -1
- package/cjs/mapAsyncIterator.js +3 -1
- package/cjs/mapSchema.js +5 -2
- package/cjs/print-schema-with-directives.js +9 -5
- package/cjs/prune.js +5 -3
- package/cjs/transformInputValue.js +6 -2
- package/cjs/valueMatchesCriteria.js +2 -1
- package/cjs/visitResult.js +1 -1
- package/esm/Path.js +3 -1
- package/esm/addTypes.js +1 -1
- package/esm/astFromType.js +1 -1
- package/esm/astFromValue.js +6 -4
- package/esm/build-operation-for-field.js +6 -2
- package/esm/collectFields.js +3 -3
- package/esm/comments.js +29 -5
- package/esm/extractExtensionsFromSchema.js +6 -2
- package/esm/fields.js +3 -3
- package/esm/filterSchema.js +4 -4
- package/esm/forEachDefaultValue.js +1 -1
- package/esm/get-arguments-with-directives.js +1 -1
- package/esm/get-directives.js +4 -1
- package/esm/getArgumentValues.js +2 -2
- package/esm/getResolversFromSchema.js +1 -1
- package/esm/heal.js +1 -1
- package/esm/inspect.js +3 -1
- package/esm/mapAsyncIterator.js +3 -1
- package/esm/mapSchema.js +7 -4
- package/esm/parse-graphql-sdl.js +1 -1
- package/esm/print-schema-with-directives.js +10 -6
- package/esm/prune.js +6 -4
- package/esm/renameType.js +1 -1
- package/esm/rewire.js +1 -1
- package/esm/stub.js +1 -1
- package/esm/transformInputValue.js +7 -3
- package/esm/validate-documents.js +1 -1
- package/esm/valueMatchesCriteria.js +2 -1
- package/esm/visitResult.js +2 -2
- package/package.json +1 -1
- package/typings/Interfaces.d.cts +1 -1
- package/typings/Interfaces.d.ts +1 -1
- package/typings/addTypes.d.cts +1 -1
- package/typings/addTypes.d.ts +1 -1
- package/typings/collectFields.d.cts +1 -1
- package/typings/collectFields.d.ts +1 -1
- package/typings/comments.d.cts +1 -1
- package/typings/comments.d.ts +1 -1
- package/typings/executor.d.cts +1 -1
- package/typings/executor.d.ts +1 -1
- package/typings/fields.d.cts +1 -1
- package/typings/fields.d.ts +1 -1
- package/typings/filterSchema.d.cts +1 -1
- package/typings/filterSchema.d.ts +1 -1
- package/typings/fixSchemaAst.d.cts +1 -1
- package/typings/fixSchemaAst.d.ts +1 -1
- package/typings/get-arguments-with-directives.d.cts +1 -1
- package/typings/get-arguments-with-directives.d.ts +1 -1
- package/typings/get-directives.d.cts +2 -3
- package/typings/get-directives.d.ts +2 -3
- package/typings/getArgumentValues.d.cts +1 -1
- package/typings/getArgumentValues.d.ts +1 -1
- package/typings/implementsAbstractType.d.cts +1 -1
- package/typings/implementsAbstractType.d.ts +1 -1
- package/typings/loaders.d.cts +1 -1
- package/typings/loaders.d.ts +1 -1
- package/typings/mapSchema.d.cts +1 -1
- package/typings/mapSchema.d.ts +1 -1
- package/typings/parse-graphql-sdl.d.cts +1 -1
- package/typings/parse-graphql-sdl.d.ts +1 -1
- package/typings/print-schema-with-directives.d.cts +2 -2
- package/typings/print-schema-with-directives.d.ts +2 -2
- package/typings/renameType.d.cts +1 -1
- package/typings/renameType.d.ts +1 -1
- package/typings/stub.d.cts +1 -1
- package/typings/stub.d.ts +1 -1
- package/typings/updateArgument.d.cts +1 -1
- package/typings/updateArgument.d.ts +1 -1
- package/typings/validate-documents.d.cts +1 -1
- package/typings/validate-documents.d.ts +1 -1
- package/typings/visitResult.d.cts +1 -1
- package/typings/visitResult.d.ts +1 -1
package/cjs/Path.js
CHANGED
|
@@ -25,6 +25,8 @@ exports.pathToArray = pathToArray;
|
|
|
25
25
|
* Build a string describing the path.
|
|
26
26
|
*/
|
|
27
27
|
function printPathArray(path) {
|
|
28
|
-
return path
|
|
28
|
+
return path
|
|
29
|
+
.map(key => (typeof key === 'number' ? '[' + key.toString() + ']' : '.' + key))
|
|
30
|
+
.join('');
|
|
29
31
|
}
|
|
30
32
|
exports.printPathArray = printPathArray;
|
package/cjs/astFromValue.js
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.astFromValue = void 0;
|
|
4
4
|
const graphql_1 = require("graphql");
|
|
5
|
-
const jsutils_js_1 = require("./jsutils.js");
|
|
6
|
-
const inspect_js_1 = require("./inspect.js");
|
|
7
5
|
const astFromValueUntyped_js_1 = require("./astFromValueUntyped.js");
|
|
6
|
+
const inspect_js_1 = require("./inspect.js");
|
|
7
|
+
const jsutils_js_1 = require("./jsutils.js");
|
|
8
8
|
/**
|
|
9
9
|
* Produces a GraphQL Value AST given a JavaScript object.
|
|
10
10
|
* Function will match JavaScript/JSON values to GraphQL AST schema format
|
|
@@ -89,7 +89,9 @@ function astFromValue(value, type) {
|
|
|
89
89
|
return { kind: graphql_1.Kind.ENUM, value: serialized };
|
|
90
90
|
}
|
|
91
91
|
// ID types can use Int literals.
|
|
92
|
-
if (type.name === 'ID' &&
|
|
92
|
+
if (type.name === 'ID' &&
|
|
93
|
+
typeof serialized === 'string' &&
|
|
94
|
+
integerStringRegExp.test(serialized)) {
|
|
93
95
|
return { kind: graphql_1.Kind.INT, value: serialized };
|
|
94
96
|
}
|
|
95
97
|
return (0, astFromValueUntyped_js_1.astFromValueUntyped)(serialized);
|
|
@@ -298,7 +298,11 @@ function resolveField({ type, field, models, firstCall, path, ancestors, ignore,
|
|
|
298
298
|
const fieldPathStr = fieldPath.join('.');
|
|
299
299
|
let fieldName = field.name;
|
|
300
300
|
if (fieldTypeMap.has(fieldPathStr) && fieldTypeMap.get(fieldPathStr) !== field.type.toString()) {
|
|
301
|
-
fieldName += field.type
|
|
301
|
+
fieldName += field.type
|
|
302
|
+
.toString()
|
|
303
|
+
.replace('!', 'NonNull')
|
|
304
|
+
.replace('[', 'List')
|
|
305
|
+
.replace(']', '');
|
|
302
306
|
}
|
|
303
307
|
fieldTypeMap.set(fieldPathStr, field.type.toString());
|
|
304
308
|
if (!(0, graphql_1.isScalarType)(namedType) && !(0, graphql_1.isEnumType)(namedType)) {
|
package/cjs/collectFields.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.collectSubFields = exports.getDeferValues = exports.getFieldEntryKey = exports.doesFragmentConditionMatch = exports.shouldIncludeNode = exports.collectFields = void 0;
|
|
4
|
-
const memoize_js_1 = require("./memoize.js");
|
|
5
4
|
const graphql_1 = require("graphql");
|
|
6
|
-
const directives_js_1 = require("./directives.js");
|
|
7
5
|
const AccumulatorMap_js_1 = require("./AccumulatorMap.js");
|
|
6
|
+
const directives_js_1 = require("./directives.js");
|
|
7
|
+
const memoize_js_1 = require("./memoize.js");
|
|
8
8
|
function collectFieldsImpl(schema, fragments, variableValues, runtimeType, selectionSet, fields, patches, visitedFragmentNames) {
|
|
9
9
|
for (const selection of selectionSet.selections) {
|
|
10
10
|
switch (selection.kind) {
|
package/cjs/comments.js
CHANGED
|
@@ -208,7 +208,13 @@ const printDocASTReducer = {
|
|
|
208
208
|
leave: ({ name, directives }) => join(['scalar', name, join(directives, ' ')], ' '),
|
|
209
209
|
},
|
|
210
210
|
ObjectTypeDefinition: {
|
|
211
|
-
leave: ({ name, interfaces, directives, fields }) => join([
|
|
211
|
+
leave: ({ name, interfaces, directives, fields }) => join([
|
|
212
|
+
'type',
|
|
213
|
+
name,
|
|
214
|
+
wrap('implements ', join(interfaces, ' & ')),
|
|
215
|
+
join(directives, ' '),
|
|
216
|
+
block(fields),
|
|
217
|
+
], ' '),
|
|
212
218
|
},
|
|
213
219
|
FieldDefinition: {
|
|
214
220
|
leave: ({ name, arguments: args, type, directives }) => name +
|
|
@@ -223,7 +229,13 @@ const printDocASTReducer = {
|
|
|
223
229
|
leave: ({ name, type, defaultValue, directives }) => join([name + ': ' + type, wrap('= ', defaultValue), join(directives, ' ')], ' '),
|
|
224
230
|
},
|
|
225
231
|
InterfaceTypeDefinition: {
|
|
226
|
-
leave: ({ name, interfaces, directives, fields }) => join([
|
|
232
|
+
leave: ({ name, interfaces, directives, fields }) => join([
|
|
233
|
+
'interface',
|
|
234
|
+
name,
|
|
235
|
+
wrap('implements ', join(interfaces, ' & ')),
|
|
236
|
+
join(directives, ' '),
|
|
237
|
+
block(fields),
|
|
238
|
+
], ' '),
|
|
227
239
|
},
|
|
228
240
|
UnionTypeDefinition: {
|
|
229
241
|
leave: ({ name, directives, types }) => join(['union', name, join(directives, ' '), wrap('= ', join(types, ' | '))], ' '),
|
|
@@ -254,10 +266,22 @@ const printDocASTReducer = {
|
|
|
254
266
|
leave: ({ name, directives }) => join(['extend scalar', name, join(directives, ' ')], ' '),
|
|
255
267
|
},
|
|
256
268
|
ObjectTypeExtension: {
|
|
257
|
-
leave: ({ name, interfaces, directives, fields }) => join([
|
|
269
|
+
leave: ({ name, interfaces, directives, fields }) => join([
|
|
270
|
+
'extend type',
|
|
271
|
+
name,
|
|
272
|
+
wrap('implements ', join(interfaces, ' & ')),
|
|
273
|
+
join(directives, ' '),
|
|
274
|
+
block(fields),
|
|
275
|
+
], ' '),
|
|
258
276
|
},
|
|
259
277
|
InterfaceTypeExtension: {
|
|
260
|
-
leave: ({ name, interfaces, directives, fields }) => join([
|
|
278
|
+
leave: ({ name, interfaces, directives, fields }) => join([
|
|
279
|
+
'extend interface',
|
|
280
|
+
name,
|
|
281
|
+
wrap('implements ', join(interfaces, ' & ')),
|
|
282
|
+
join(directives, ' '),
|
|
283
|
+
block(fields),
|
|
284
|
+
], ' '),
|
|
261
285
|
},
|
|
262
286
|
UnionTypeExtension: {
|
|
263
287
|
leave: ({ name, directives, types }) => join(['extend union', name, join(directives, ' '), wrap('= ', join(types, ' | '))], ' '),
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.extractExtensionsFromSchema = void 0;
|
|
4
|
-
const mapSchema_js_1 = require("./mapSchema.js");
|
|
5
4
|
const Interfaces_js_1 = require("./Interfaces.js");
|
|
5
|
+
const mapSchema_js_1 = require("./mapSchema.js");
|
|
6
6
|
function extractExtensionsFromSchema(schema) {
|
|
7
7
|
const result = {
|
|
8
8
|
schemaExtensions: schema.extensions || {},
|
|
@@ -14,7 +14,11 @@ function extractExtensionsFromSchema(schema) {
|
|
|
14
14
|
return type;
|
|
15
15
|
},
|
|
16
16
|
[Interfaces_js_1.MapperKind.INTERFACE_TYPE]: type => {
|
|
17
|
-
result.types[type.name] = {
|
|
17
|
+
result.types[type.name] = {
|
|
18
|
+
fields: {},
|
|
19
|
+
type: 'interface',
|
|
20
|
+
extensions: type.extensions || {},
|
|
21
|
+
};
|
|
18
22
|
return type;
|
|
19
23
|
},
|
|
20
24
|
[Interfaces_js_1.MapperKind.FIELD]: (field, fieldName, typeName) => {
|
package/cjs/fields.js
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.modifyObjectFields = exports.selectObjectFields = exports.removeObjectFields = exports.appendObjectFields = void 0;
|
|
4
4
|
const graphql_1 = require("graphql");
|
|
5
|
+
const addTypes_js_1 = require("./addTypes.js");
|
|
5
6
|
const Interfaces_js_1 = require("./Interfaces.js");
|
|
6
7
|
const mapSchema_js_1 = require("./mapSchema.js");
|
|
7
|
-
const addTypes_js_1 = require("./addTypes.js");
|
|
8
8
|
function appendObjectFields(schema, typeName, additionalFields) {
|
|
9
9
|
if (schema.getType(typeName) == null) {
|
|
10
10
|
return (0, addTypes_js_1.addTypes)(schema, [
|
package/cjs/filterSchema.js
CHANGED
|
@@ -18,9 +18,9 @@ function filterSchema({ schema, typeFilter = () => true, fieldFilter = undefined
|
|
|
18
18
|
[Interfaces_js_1.MapperKind.INPUT_OBJECT_TYPE]: (type) => typeFilter(type.name, type)
|
|
19
19
|
? filterElementFields(graphql_1.GraphQLInputObjectType, type, inputObjectFieldFilter || fieldFilter)
|
|
20
20
|
: null,
|
|
21
|
-
[Interfaces_js_1.MapperKind.UNION_TYPE]: (type) =>
|
|
22
|
-
[Interfaces_js_1.MapperKind.ENUM_TYPE]: (type) =>
|
|
23
|
-
[Interfaces_js_1.MapperKind.SCALAR_TYPE]: (type) =>
|
|
21
|
+
[Interfaces_js_1.MapperKind.UNION_TYPE]: (type) => typeFilter(type.name, type) ? undefined : null,
|
|
22
|
+
[Interfaces_js_1.MapperKind.ENUM_TYPE]: (type) => typeFilter(type.name, type) ? undefined : null,
|
|
23
|
+
[Interfaces_js_1.MapperKind.SCALAR_TYPE]: (type) => typeFilter(type.name, type) ? undefined : null,
|
|
24
24
|
});
|
|
25
25
|
return filteredSchema;
|
|
26
26
|
}
|
package/cjs/get-directives.js
CHANGED
|
@@ -61,7 +61,10 @@ function getDirectives(schema, node, pathToDirectivesInExtensions = ['directives
|
|
|
61
61
|
for (const directiveNode of astNode.directives) {
|
|
62
62
|
const schemaDirective = schemaDirectiveMap[directiveNode.name.value];
|
|
63
63
|
if (schemaDirective) {
|
|
64
|
-
result.push({
|
|
64
|
+
result.push({
|
|
65
|
+
name: directiveNode.name.value,
|
|
66
|
+
args: (0, getArgumentValues_js_1.getArgumentValues)(schemaDirective, directiveNode),
|
|
67
|
+
});
|
|
65
68
|
}
|
|
66
69
|
}
|
|
67
70
|
}
|
package/cjs/getArgumentValues.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getArgumentValues = void 0;
|
|
4
|
-
const jsutils_js_1 = require("./jsutils.js");
|
|
5
4
|
const graphql_1 = require("graphql");
|
|
6
5
|
const errors_js_1 = require("./errors.js");
|
|
7
6
|
const inspect_js_1 = require("./inspect.js");
|
|
7
|
+
const jsutils_js_1 = require("./jsutils.js");
|
|
8
8
|
/**
|
|
9
9
|
* Prepares an object map of argument values given a list of argument
|
|
10
10
|
* definitions and list of argument AST nodes.
|
package/cjs/inspect.js
CHANGED
|
@@ -36,7 +36,9 @@ function formatObjectValue(value, previouslySeenValues) {
|
|
|
36
36
|
}
|
|
37
37
|
if (value instanceof Error) {
|
|
38
38
|
if (value.name === 'AggregateError') {
|
|
39
|
-
return formatError(value) +
|
|
39
|
+
return (formatError(value) +
|
|
40
|
+
'\n' +
|
|
41
|
+
formatArray(value.errors, previouslySeenValues));
|
|
40
42
|
}
|
|
41
43
|
return formatError(value);
|
|
42
44
|
}
|
package/cjs/mapAsyncIterator.js
CHANGED
|
@@ -16,7 +16,9 @@ function mapAsyncIterator(iterator, callback, rejectCallback) {
|
|
|
16
16
|
};
|
|
17
17
|
}
|
|
18
18
|
function mapResult(result) {
|
|
19
|
-
return result.done
|
|
19
|
+
return result.done
|
|
20
|
+
? result
|
|
21
|
+
: asyncMapValue(result.value, callback).then(iteratorResult, abruptClose);
|
|
20
22
|
}
|
|
21
23
|
let mapReject;
|
|
22
24
|
if (rejectCallback) {
|
package/cjs/mapSchema.js
CHANGED
|
@@ -127,7 +127,9 @@ function mapFields(originalTypeMap, schema, schemaMapper) {
|
|
|
127
127
|
for (const typeName in originalTypeMap) {
|
|
128
128
|
if (!typeName.startsWith('__')) {
|
|
129
129
|
const originalType = originalTypeMap[typeName];
|
|
130
|
-
if (!(0, graphql_1.isObjectType)(originalType) &&
|
|
130
|
+
if (!(0, graphql_1.isObjectType)(originalType) &&
|
|
131
|
+
!(0, graphql_1.isInterfaceType)(originalType) &&
|
|
132
|
+
!(0, graphql_1.isInputObjectType)(originalType)) {
|
|
131
133
|
newTypeMap[typeName] = originalType;
|
|
132
134
|
continue;
|
|
133
135
|
}
|
|
@@ -156,7 +158,8 @@ function mapFields(originalTypeMap, schema, schemaMapper) {
|
|
|
156
158
|
},
|
|
157
159
|
};
|
|
158
160
|
}
|
|
159
|
-
newFieldConfigMap[newFieldName] =
|
|
161
|
+
newFieldConfigMap[newFieldName] =
|
|
162
|
+
newFieldConfig === undefined ? originalFieldConfig : newFieldConfig;
|
|
160
163
|
}
|
|
161
164
|
else if (mappedField !== null) {
|
|
162
165
|
newFieldConfigMap[fieldName] = mappedField;
|
|
@@ -3,11 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.makeDirectiveNodes = exports.makeDirectiveNode = exports.makeDeprecatedDirective = exports.astFromEnumValue = exports.astFromInputField = exports.astFromField = exports.astFromScalarType = exports.astFromEnumType = exports.astFromInputObjectType = exports.astFromUnionType = exports.astFromInterfaceType = exports.astFromObjectType = exports.astFromArg = exports.getDeprecatableDirectiveNodes = exports.getDirectiveNodes = exports.astFromDirective = exports.astFromSchema = exports.printSchemaWithDirectives = exports.getDocumentNodeFromSchema = void 0;
|
|
4
4
|
const graphql_1 = require("graphql");
|
|
5
5
|
const astFromType_js_1 = require("./astFromType.js");
|
|
6
|
-
const
|
|
6
|
+
const astFromValue_js_1 = require("./astFromValue.js");
|
|
7
7
|
const astFromValueUntyped_js_1 = require("./astFromValueUntyped.js");
|
|
8
|
+
const get_directives_js_1 = require("./get-directives.js");
|
|
8
9
|
const helpers_js_1 = require("./helpers.js");
|
|
9
10
|
const rootTypes_js_1 = require("./rootTypes.js");
|
|
10
|
-
const astFromValue_js_1 = require("./astFromValue.js");
|
|
11
11
|
function getDocumentNodeFromSchema(schema, options = {}) {
|
|
12
12
|
const pathToDirectivesInExtensions = options.pathToDirectivesInExtensions;
|
|
13
13
|
const typesMap = schema.getTypeMap();
|
|
@@ -216,7 +216,9 @@ function astFromArg(arg, schema, pathToDirectivesInExtensions) {
|
|
|
216
216
|
},
|
|
217
217
|
type: (0, astFromType_js_1.astFromType)(arg.type),
|
|
218
218
|
// ConstXNode has been introduced in v16 but it is not compatible with XNode so we do `as any` for backwards compatibility
|
|
219
|
-
defaultValue: arg.defaultValue !== undefined
|
|
219
|
+
defaultValue: arg.defaultValue !== undefined
|
|
220
|
+
? (0, astFromValue_js_1.astFromValue)(arg.defaultValue, arg.type) ?? undefined
|
|
221
|
+
: undefined,
|
|
220
222
|
directives: getDeprecatableDirectiveNodes(arg, schema, pathToDirectivesInExtensions),
|
|
221
223
|
};
|
|
222
224
|
}
|
|
@@ -334,8 +336,10 @@ function astFromScalarType(type, schema, pathToDirectivesInExtensions) {
|
|
|
334
336
|
const directives = directivesInExtensions
|
|
335
337
|
? makeDirectiveNodes(schema, directivesInExtensions)
|
|
336
338
|
: type.astNode?.directives || [];
|
|
337
|
-
const specifiedByValue = (type['specifiedByUrl'] ||
|
|
338
|
-
|
|
339
|
+
const specifiedByValue = (type['specifiedByUrl'] ||
|
|
340
|
+
type['specifiedByURL']);
|
|
341
|
+
if (specifiedByValue &&
|
|
342
|
+
!directives.some(directiveNode => directiveNode.name.value === 'specifiedBy')) {
|
|
339
343
|
const specifiedByArgs = {
|
|
340
344
|
url: specifiedByValue,
|
|
341
345
|
};
|
package/cjs/prune.js
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.pruneSchema = void 0;
|
|
4
4
|
const graphql_1 = require("graphql");
|
|
5
|
-
const
|
|
5
|
+
const get_implementing_types_js_1 = require("./get-implementing-types.js");
|
|
6
6
|
const Interfaces_js_1 = require("./Interfaces.js");
|
|
7
|
+
const mapSchema_js_1 = require("./mapSchema.js");
|
|
7
8
|
const rootTypes_js_1 = require("./rootTypes.js");
|
|
8
|
-
const get_implementing_types_js_1 = require("./get-implementing-types.js");
|
|
9
9
|
/**
|
|
10
10
|
* Prunes the provided schema, removing unused and empty types
|
|
11
11
|
* @param schema The schema to prune
|
|
@@ -46,7 +46,9 @@ function pruneSchema(schema, options = {}) {
|
|
|
46
46
|
return type;
|
|
47
47
|
}
|
|
48
48
|
// skipEmptyUnionPruning: skip pruning empty unions
|
|
49
|
-
if ((0, graphql_1.isUnionType)(type) &&
|
|
49
|
+
if ((0, graphql_1.isUnionType)(type) &&
|
|
50
|
+
skipEmptyUnionPruning &&
|
|
51
|
+
!Object.keys(type.getTypes()).length) {
|
|
50
52
|
return type;
|
|
51
53
|
}
|
|
52
54
|
if ((0, graphql_1.isInputObjectType)(type) || (0, graphql_1.isInterfaceType)(type) || (0, graphql_1.isObjectType)(type)) {
|
|
@@ -9,7 +9,9 @@ function transformInputValue(type, value, inputLeafValueTransformer = null, inpu
|
|
|
9
9
|
}
|
|
10
10
|
const nullableType = (0, graphql_1.getNullableType)(type);
|
|
11
11
|
if ((0, graphql_1.isLeafType)(nullableType)) {
|
|
12
|
-
return inputLeafValueTransformer != null
|
|
12
|
+
return inputLeafValueTransformer != null
|
|
13
|
+
? inputLeafValueTransformer(nullableType, value)
|
|
14
|
+
: value;
|
|
13
15
|
}
|
|
14
16
|
else if ((0, graphql_1.isListType)(nullableType)) {
|
|
15
17
|
return (0, helpers_js_1.asArray)(value).map((listMember) => transformInputValue(nullableType.ofType, listMember, inputLeafValueTransformer, inputObjectValueTransformer));
|
|
@@ -23,7 +25,9 @@ function transformInputValue(type, value, inputLeafValueTransformer = null, inpu
|
|
|
23
25
|
newValue[key] = transformInputValue(field.type, value[key], inputLeafValueTransformer, inputObjectValueTransformer);
|
|
24
26
|
}
|
|
25
27
|
}
|
|
26
|
-
return inputObjectValueTransformer != null
|
|
28
|
+
return inputObjectValueTransformer != null
|
|
29
|
+
? inputObjectValueTransformer(nullableType, newValue)
|
|
30
|
+
: newValue;
|
|
27
31
|
}
|
|
28
32
|
// unreachable, no other possible return value
|
|
29
33
|
}
|
|
@@ -6,7 +6,8 @@ function valueMatchesCriteria(value, criteria) {
|
|
|
6
6
|
return value === criteria;
|
|
7
7
|
}
|
|
8
8
|
else if (Array.isArray(value)) {
|
|
9
|
-
return Array.isArray(criteria) &&
|
|
9
|
+
return (Array.isArray(criteria) &&
|
|
10
|
+
value.every((val, index) => valueMatchesCriteria(val, criteria[index])));
|
|
10
11
|
}
|
|
11
12
|
else if (typeof value === 'object') {
|
|
12
13
|
return (typeof criteria === 'object' &&
|
package/cjs/visitResult.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.visitResult = exports.visitErrors = exports.visitData = void 0;
|
|
4
|
-
const getOperationASTFromRequest_js_1 = require("./getOperationASTFromRequest.js");
|
|
5
4
|
const graphql_1 = require("graphql");
|
|
6
5
|
const collectFields_js_1 = require("./collectFields.js");
|
|
6
|
+
const getOperationASTFromRequest_js_1 = require("./getOperationASTFromRequest.js");
|
|
7
7
|
function visitData(data, enter, leave) {
|
|
8
8
|
if (Array.isArray(data)) {
|
|
9
9
|
return data.map(value => visitData(value, enter, leave));
|
package/esm/Path.js
CHANGED
|
@@ -20,5 +20,7 @@ export function pathToArray(path) {
|
|
|
20
20
|
* Build a string describing the path.
|
|
21
21
|
*/
|
|
22
22
|
export function printPathArray(path) {
|
|
23
|
-
return path
|
|
23
|
+
return path
|
|
24
|
+
.map(key => (typeof key === 'number' ? '[' + key.toString() + ']' : '.' + key))
|
|
25
|
+
.join('');
|
|
24
26
|
}
|
package/esm/addTypes.js
CHANGED
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
//
|
|
26
26
|
// enhanceSchema can fill this gap by adding an additional round of rewiring.
|
|
27
27
|
//
|
|
28
|
-
import { GraphQLSchema, isNamedType,
|
|
28
|
+
import { GraphQLSchema, isDirective, isNamedType, } from 'graphql';
|
|
29
29
|
import { getObjectTypeFromTypeMap } from './getObjectTypeFromTypeMap.js';
|
|
30
30
|
import { rewireTypes } from './rewire.js';
|
|
31
31
|
export function addTypes(schema, newTypesOrDirectives) {
|
package/esm/astFromType.js
CHANGED
package/esm/astFromValue.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { isIterableObject, isObjectLike } from './jsutils.js';
|
|
3
|
-
import { inspect } from './inspect.js';
|
|
1
|
+
import { isEnumType, isInputObjectType, isLeafType, isListType, isNonNullType, Kind, } from 'graphql';
|
|
4
2
|
import { astFromValueUntyped } from './astFromValueUntyped.js';
|
|
3
|
+
import { inspect } from './inspect.js';
|
|
4
|
+
import { isIterableObject, isObjectLike } from './jsutils.js';
|
|
5
5
|
/**
|
|
6
6
|
* Produces a GraphQL Value AST given a JavaScript object.
|
|
7
7
|
* Function will match JavaScript/JSON values to GraphQL AST schema format
|
|
@@ -86,7 +86,9 @@ export function astFromValue(value, type) {
|
|
|
86
86
|
return { kind: Kind.ENUM, value: serialized };
|
|
87
87
|
}
|
|
88
88
|
// ID types can use Int literals.
|
|
89
|
-
if (type.name === 'ID' &&
|
|
89
|
+
if (type.name === 'ID' &&
|
|
90
|
+
typeof serialized === 'string' &&
|
|
91
|
+
integerStringRegExp.test(serialized)) {
|
|
90
92
|
return { kind: Kind.INT, value: serialized };
|
|
91
93
|
}
|
|
92
94
|
return astFromValueUntyped(serialized);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getNamedType, isEnumType, isInterfaceType, isListType, isNonNullType, isObjectType, isScalarType, isUnionType, Kind, } from 'graphql';
|
|
2
2
|
import { getDefinedRootType, getRootTypeNames } from './rootTypes.js';
|
|
3
3
|
let operationVariables = [];
|
|
4
4
|
let fieldTypeMap = new Map();
|
|
@@ -294,7 +294,11 @@ function resolveField({ type, field, models, firstCall, path, ancestors, ignore,
|
|
|
294
294
|
const fieldPathStr = fieldPath.join('.');
|
|
295
295
|
let fieldName = field.name;
|
|
296
296
|
if (fieldTypeMap.has(fieldPathStr) && fieldTypeMap.get(fieldPathStr) !== field.type.toString()) {
|
|
297
|
-
fieldName += field.type
|
|
297
|
+
fieldName += field.type
|
|
298
|
+
.toString()
|
|
299
|
+
.replace('!', 'NonNull')
|
|
300
|
+
.replace('[', 'List')
|
|
301
|
+
.replace(']', '');
|
|
298
302
|
}
|
|
299
303
|
fieldTypeMap.set(fieldPathStr, field.type.toString());
|
|
300
304
|
if (!isScalarType(namedType) && !isEnumType(namedType)) {
|
package/esm/collectFields.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Kind, getDirectiveValues, GraphQLSkipDirective, GraphQLIncludeDirective, isAbstractType, typeFromAST, } from 'graphql';
|
|
3
|
-
import { GraphQLDeferDirective } from './directives.js';
|
|
1
|
+
import { getDirectiveValues, GraphQLIncludeDirective, GraphQLSkipDirective, isAbstractType, Kind, typeFromAST, } from 'graphql';
|
|
4
2
|
import { AccumulatorMap } from './AccumulatorMap.js';
|
|
3
|
+
import { GraphQLDeferDirective } from './directives.js';
|
|
4
|
+
import { memoize5 } from './memoize.js';
|
|
5
5
|
function collectFieldsImpl(schema, fragments, variableValues, runtimeType, selectionSet, fields, patches, visitedFragmentNames) {
|
|
6
6
|
for (const selection of selectionSet.selections) {
|
|
7
7
|
switch (selection.kind) {
|
package/esm/comments.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TokenKind, visit, } from 'graphql';
|
|
2
2
|
const MAX_LINE_LENGTH = 80;
|
|
3
3
|
let commentsRegistry = {};
|
|
4
4
|
export function resetComments() {
|
|
@@ -201,7 +201,13 @@ const printDocASTReducer = {
|
|
|
201
201
|
leave: ({ name, directives }) => join(['scalar', name, join(directives, ' ')], ' '),
|
|
202
202
|
},
|
|
203
203
|
ObjectTypeDefinition: {
|
|
204
|
-
leave: ({ name, interfaces, directives, fields }) => join([
|
|
204
|
+
leave: ({ name, interfaces, directives, fields }) => join([
|
|
205
|
+
'type',
|
|
206
|
+
name,
|
|
207
|
+
wrap('implements ', join(interfaces, ' & ')),
|
|
208
|
+
join(directives, ' '),
|
|
209
|
+
block(fields),
|
|
210
|
+
], ' '),
|
|
205
211
|
},
|
|
206
212
|
FieldDefinition: {
|
|
207
213
|
leave: ({ name, arguments: args, type, directives }) => name +
|
|
@@ -216,7 +222,13 @@ const printDocASTReducer = {
|
|
|
216
222
|
leave: ({ name, type, defaultValue, directives }) => join([name + ': ' + type, wrap('= ', defaultValue), join(directives, ' ')], ' '),
|
|
217
223
|
},
|
|
218
224
|
InterfaceTypeDefinition: {
|
|
219
|
-
leave: ({ name, interfaces, directives, fields }) => join([
|
|
225
|
+
leave: ({ name, interfaces, directives, fields }) => join([
|
|
226
|
+
'interface',
|
|
227
|
+
name,
|
|
228
|
+
wrap('implements ', join(interfaces, ' & ')),
|
|
229
|
+
join(directives, ' '),
|
|
230
|
+
block(fields),
|
|
231
|
+
], ' '),
|
|
220
232
|
},
|
|
221
233
|
UnionTypeDefinition: {
|
|
222
234
|
leave: ({ name, directives, types }) => join(['union', name, join(directives, ' '), wrap('= ', join(types, ' | '))], ' '),
|
|
@@ -247,10 +259,22 @@ const printDocASTReducer = {
|
|
|
247
259
|
leave: ({ name, directives }) => join(['extend scalar', name, join(directives, ' ')], ' '),
|
|
248
260
|
},
|
|
249
261
|
ObjectTypeExtension: {
|
|
250
|
-
leave: ({ name, interfaces, directives, fields }) => join([
|
|
262
|
+
leave: ({ name, interfaces, directives, fields }) => join([
|
|
263
|
+
'extend type',
|
|
264
|
+
name,
|
|
265
|
+
wrap('implements ', join(interfaces, ' & ')),
|
|
266
|
+
join(directives, ' '),
|
|
267
|
+
block(fields),
|
|
268
|
+
], ' '),
|
|
251
269
|
},
|
|
252
270
|
InterfaceTypeExtension: {
|
|
253
|
-
leave: ({ name, interfaces, directives, fields }) => join([
|
|
271
|
+
leave: ({ name, interfaces, directives, fields }) => join([
|
|
272
|
+
'extend interface',
|
|
273
|
+
name,
|
|
274
|
+
wrap('implements ', join(interfaces, ' & ')),
|
|
275
|
+
join(directives, ' '),
|
|
276
|
+
block(fields),
|
|
277
|
+
], ' '),
|
|
254
278
|
},
|
|
255
279
|
UnionTypeExtension: {
|
|
256
280
|
leave: ({ name, directives, types }) => join(['extend union', name, join(directives, ' '), wrap('= ', join(types, ' | '))], ' '),
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { mapSchema } from './mapSchema.js';
|
|
2
1
|
import { MapperKind } from './Interfaces.js';
|
|
2
|
+
import { mapSchema } from './mapSchema.js';
|
|
3
3
|
export function extractExtensionsFromSchema(schema) {
|
|
4
4
|
const result = {
|
|
5
5
|
schemaExtensions: schema.extensions || {},
|
|
@@ -11,7 +11,11 @@ export function extractExtensionsFromSchema(schema) {
|
|
|
11
11
|
return type;
|
|
12
12
|
},
|
|
13
13
|
[MapperKind.INTERFACE_TYPE]: type => {
|
|
14
|
-
result.types[type.name] = {
|
|
14
|
+
result.types[type.name] = {
|
|
15
|
+
fields: {},
|
|
16
|
+
type: 'interface',
|
|
17
|
+
extensions: type.extensions || {},
|
|
18
|
+
};
|
|
15
19
|
return type;
|
|
16
20
|
},
|
|
17
21
|
[MapperKind.FIELD]: (field, fieldName, typeName) => {
|
package/esm/fields.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { GraphQLObjectType } from 'graphql';
|
|
2
|
-
import { MapperKind } from './Interfaces.js';
|
|
3
|
-
import { mapSchema, correctASTNodes } from './mapSchema.js';
|
|
1
|
+
import { GraphQLObjectType, } from 'graphql';
|
|
4
2
|
import { addTypes } from './addTypes.js';
|
|
3
|
+
import { MapperKind } from './Interfaces.js';
|
|
4
|
+
import { correctASTNodes, mapSchema } from './mapSchema.js';
|
|
5
5
|
export function appendObjectFields(schema, typeName, additionalFields) {
|
|
6
6
|
if (schema.getType(typeName) == null) {
|
|
7
7
|
return addTypes(schema, [
|
package/esm/filterSchema.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { GraphQLInputObjectType, GraphQLInterfaceType, GraphQLObjectType, } from 'graphql';
|
|
2
|
-
import { MapperKind } from './Interfaces.js';
|
|
2
|
+
import { MapperKind, } from './Interfaces.js';
|
|
3
3
|
import { mapSchema } from './mapSchema.js';
|
|
4
4
|
export function filterSchema({ schema, typeFilter = () => true, fieldFilter = undefined, rootFieldFilter = undefined, objectFieldFilter = undefined, interfaceFieldFilter = undefined, inputObjectFieldFilter = undefined, argumentFilter = undefined, }) {
|
|
5
5
|
const filteredSchema = mapSchema(schema, {
|
|
@@ -15,9 +15,9 @@ export function filterSchema({ schema, typeFilter = () => true, fieldFilter = un
|
|
|
15
15
|
[MapperKind.INPUT_OBJECT_TYPE]: (type) => typeFilter(type.name, type)
|
|
16
16
|
? filterElementFields(GraphQLInputObjectType, type, inputObjectFieldFilter || fieldFilter)
|
|
17
17
|
: null,
|
|
18
|
-
[MapperKind.UNION_TYPE]: (type) =>
|
|
19
|
-
[MapperKind.ENUM_TYPE]: (type) =>
|
|
20
|
-
[MapperKind.SCALAR_TYPE]: (type) =>
|
|
18
|
+
[MapperKind.UNION_TYPE]: (type) => typeFilter(type.name, type) ? undefined : null,
|
|
19
|
+
[MapperKind.ENUM_TYPE]: (type) => typeFilter(type.name, type) ? undefined : null,
|
|
20
|
+
[MapperKind.SCALAR_TYPE]: (type) => typeFilter(type.name, type) ? undefined : null,
|
|
21
21
|
});
|
|
22
22
|
return filteredSchema;
|
|
23
23
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getNamedType,
|
|
1
|
+
import { getNamedType, isInputObjectType, isObjectType } from 'graphql';
|
|
2
2
|
export function forEachDefaultValue(schema, fn) {
|
|
3
3
|
const typeMap = schema.getTypeMap();
|
|
4
4
|
for (const typeName in typeMap) {
|
package/esm/get-directives.js
CHANGED
|
@@ -56,7 +56,10 @@ export function getDirectives(schema, node, pathToDirectivesInExtensions = ['dir
|
|
|
56
56
|
for (const directiveNode of astNode.directives) {
|
|
57
57
|
const schemaDirective = schemaDirectiveMap[directiveNode.name.value];
|
|
58
58
|
if (schemaDirective) {
|
|
59
|
-
result.push({
|
|
59
|
+
result.push({
|
|
60
|
+
name: directiveNode.name.value,
|
|
61
|
+
args: getArgumentValues(schemaDirective, directiveNode),
|
|
62
|
+
});
|
|
60
63
|
}
|
|
61
64
|
}
|
|
62
65
|
}
|
package/esm/getArgumentValues.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { valueFromAST, isNonNullType, Kind, print, } from 'graphql';
|
|
1
|
+
import { isNonNullType, Kind, print, valueFromAST, } from 'graphql';
|
|
3
2
|
import { createGraphQLError } from './errors.js';
|
|
4
3
|
import { inspect } from './inspect.js';
|
|
4
|
+
import { hasOwnProperty } from './jsutils.js';
|
|
5
5
|
/**
|
|
6
6
|
* Prepares an object map of argument values given a list of argument
|
|
7
7
|
* definitions and list of argument AST nodes.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { GraphQLScalarType,
|
|
1
|
+
import { GraphQLScalarType, isEnumType, isInterfaceType, isObjectType, isScalarType, isSpecifiedScalarType, isUnionType, } from 'graphql';
|
|
2
2
|
export function getResolversFromSchema(schema,
|
|
3
3
|
// Include default merged resolvers
|
|
4
4
|
includeDefaultMergedResolver) {
|
package/esm/heal.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { GraphQLList, GraphQLNonNull,
|
|
1
|
+
import { GraphQLList, GraphQLNonNull, isInputObjectType, isInterfaceType, isLeafType, isListType, isNamedType, isNonNullType, isObjectType, isUnionType, } from 'graphql';
|
|
2
2
|
// Update any references to named schema types that disagree with the named
|
|
3
3
|
// types found in schema.getTypeMap().
|
|
4
4
|
//
|
package/esm/inspect.js
CHANGED
|
@@ -32,7 +32,9 @@ function formatObjectValue(value, previouslySeenValues) {
|
|
|
32
32
|
}
|
|
33
33
|
if (value instanceof Error) {
|
|
34
34
|
if (value.name === 'AggregateError') {
|
|
35
|
-
return formatError(value) +
|
|
35
|
+
return (formatError(value) +
|
|
36
|
+
'\n' +
|
|
37
|
+
formatArray(value.errors, previouslySeenValues));
|
|
36
38
|
}
|
|
37
39
|
return formatError(value);
|
|
38
40
|
}
|
package/esm/mapAsyncIterator.js
CHANGED
|
@@ -13,7 +13,9 @@ export function mapAsyncIterator(iterator, callback, rejectCallback) {
|
|
|
13
13
|
};
|
|
14
14
|
}
|
|
15
15
|
function mapResult(result) {
|
|
16
|
-
return result.done
|
|
16
|
+
return result.done
|
|
17
|
+
? result
|
|
18
|
+
: asyncMapValue(result.value, callback).then(iteratorResult, abruptClose);
|
|
17
19
|
}
|
|
18
20
|
let mapReject;
|
|
19
21
|
if (rejectCallback) {
|