@graphql-tools/utils 8.5.4 → 8.6.1
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/index.js +109 -61
- package/index.mjs +107 -61
- package/package.json +3 -2
- package/withCancel.d.ts +3 -1
package/index.js
CHANGED
|
@@ -226,7 +226,7 @@ function getArgumentValues(def, node, variableValues = {}) {
|
|
|
226
226
|
let isNull = valueNode.kind === graphql.Kind.NULL;
|
|
227
227
|
if (valueNode.kind === graphql.Kind.VARIABLE) {
|
|
228
228
|
const variableName = valueNode.name.value;
|
|
229
|
-
if (variableValues == null ||
|
|
229
|
+
if (variableValues == null || variableMap[variableName] == null) {
|
|
230
230
|
if (defaultValue !== undefined) {
|
|
231
231
|
coercedValues[name] = defaultValue;
|
|
232
232
|
}
|
|
@@ -3207,57 +3207,54 @@ function addTypes(schema, newTypesOrDirectives) {
|
|
|
3207
3207
|
* @param options Additional options for removing unused types from the schema
|
|
3208
3208
|
*/
|
|
3209
3209
|
function pruneSchema(schema, options = {}) {
|
|
3210
|
-
const pruningContext =
|
|
3211
|
-
|
|
3212
|
-
|
|
3213
|
-
|
|
3214
|
-
|
|
3215
|
-
|
|
3216
|
-
|
|
3217
|
-
if (type && 'getInterfaces' in type) {
|
|
3218
|
-
for (const iface of type.getInterfaces()) {
|
|
3219
|
-
const implementations = getImplementations(pruningContext, iface);
|
|
3220
|
-
if (implementations == null) {
|
|
3221
|
-
pruningContext.implementations[iface.name] = Object.create(null);
|
|
3222
|
-
}
|
|
3223
|
-
pruningContext.implementations[iface.name][type.name] = true;
|
|
3224
|
-
}
|
|
3210
|
+
const pruningContext = createPruningContext(schema);
|
|
3211
|
+
visitTypes(pruningContext);
|
|
3212
|
+
const types = Object.values(schema.getTypeMap());
|
|
3213
|
+
const typesToPrune = new Set();
|
|
3214
|
+
for (const type of types) {
|
|
3215
|
+
if (type.name.startsWith('__')) {
|
|
3216
|
+
continue;
|
|
3225
3217
|
}
|
|
3226
|
-
|
|
3227
|
-
|
|
3228
|
-
|
|
3229
|
-
|
|
3230
|
-
|
|
3231
|
-
if (
|
|
3232
|
-
|
|
3218
|
+
// If we should NOT prune the type, return it immediately as unmodified
|
|
3219
|
+
if (options.skipPruning && options.skipPruning(type)) {
|
|
3220
|
+
continue;
|
|
3221
|
+
}
|
|
3222
|
+
if (graphql.isObjectType(type) || graphql.isInputObjectType(type)) {
|
|
3223
|
+
if ((!Object.keys(type.getFields()).length && !options.skipEmptyCompositeTypePruning) ||
|
|
3224
|
+
(pruningContext.unusedTypes[type.name] && !options.skipUnusedTypesPruning)) {
|
|
3225
|
+
typesToPrune.add(type.name);
|
|
3233
3226
|
}
|
|
3234
|
-
|
|
3235
|
-
|
|
3236
|
-
|
|
3237
|
-
|
|
3238
|
-
|
|
3227
|
+
}
|
|
3228
|
+
else if (graphql.isUnionType(type)) {
|
|
3229
|
+
if ((!type.getTypes().length && !options.skipEmptyUnionPruning) ||
|
|
3230
|
+
(pruningContext.unusedTypes[type.name] && !options.skipUnusedTypesPruning)) {
|
|
3231
|
+
typesToPrune.add(type.name);
|
|
3239
3232
|
}
|
|
3240
|
-
|
|
3241
|
-
|
|
3242
|
-
|
|
3243
|
-
|
|
3244
|
-
|
|
3233
|
+
}
|
|
3234
|
+
else if (graphql.isInterfaceType(type)) {
|
|
3235
|
+
const implementations = getImplementations(pruningContext, type);
|
|
3236
|
+
if ((!Object.keys(type.getFields()).length && !options.skipEmptyCompositeTypePruning) ||
|
|
3237
|
+
(implementations && !Object.keys(implementations).length && !options.skipUnimplementedInterfacesPruning) ||
|
|
3238
|
+
(pruningContext.unusedTypes[type.name] && !options.skipUnusedTypesPruning)) {
|
|
3239
|
+
typesToPrune.add(type.name);
|
|
3245
3240
|
}
|
|
3246
|
-
|
|
3247
|
-
|
|
3248
|
-
|
|
3249
|
-
|
|
3250
|
-
(pruningContext.unusedTypes[type.name] && !options.skipUnusedTypesPruning)) {
|
|
3251
|
-
return null;
|
|
3252
|
-
}
|
|
3241
|
+
}
|
|
3242
|
+
else {
|
|
3243
|
+
if (pruningContext.unusedTypes[type.name] && !options.skipUnusedTypesPruning) {
|
|
3244
|
+
typesToPrune.add(type.name);
|
|
3253
3245
|
}
|
|
3254
|
-
|
|
3255
|
-
|
|
3256
|
-
|
|
3257
|
-
|
|
3246
|
+
}
|
|
3247
|
+
}
|
|
3248
|
+
// TODO: consider not returning a new schema if there was nothing to prune. This would be a breaking change.
|
|
3249
|
+
const prunedSchema = mapSchema(schema, {
|
|
3250
|
+
[exports.MapperKind.TYPE]: (type) => {
|
|
3251
|
+
if (typesToPrune.has(type.name)) {
|
|
3252
|
+
return null;
|
|
3258
3253
|
}
|
|
3259
3254
|
},
|
|
3260
3255
|
});
|
|
3256
|
+
// if we pruned something, we need to prune again in case there are now objects without fields
|
|
3257
|
+
return typesToPrune.size ? pruneSchema(prunedSchema, options) : prunedSchema;
|
|
3261
3258
|
}
|
|
3262
3259
|
function visitOutputType(visitedTypes, pruningContext, type) {
|
|
3263
3260
|
if (visitedTypes[type.name]) {
|
|
@@ -3297,6 +3294,29 @@ function visitOutputType(visitedTypes, pruningContext, type) {
|
|
|
3297
3294
|
}
|
|
3298
3295
|
}
|
|
3299
3296
|
}
|
|
3297
|
+
/**
|
|
3298
|
+
* Initialize a pruneContext given a schema.
|
|
3299
|
+
*/
|
|
3300
|
+
function createPruningContext(schema) {
|
|
3301
|
+
const pruningContext = {
|
|
3302
|
+
schema,
|
|
3303
|
+
unusedTypes: Object.create(null),
|
|
3304
|
+
implementations: Object.create(null),
|
|
3305
|
+
};
|
|
3306
|
+
for (const typeName in schema.getTypeMap()) {
|
|
3307
|
+
const type = schema.getType(typeName);
|
|
3308
|
+
if (type && 'getInterfaces' in type) {
|
|
3309
|
+
for (const iface of type.getInterfaces()) {
|
|
3310
|
+
const implementations = getImplementations(pruningContext, iface);
|
|
3311
|
+
if (implementations == null) {
|
|
3312
|
+
pruningContext.implementations[iface.name] = Object.create(null);
|
|
3313
|
+
}
|
|
3314
|
+
pruningContext.implementations[iface.name][type.name] = true;
|
|
3315
|
+
}
|
|
3316
|
+
}
|
|
3317
|
+
}
|
|
3318
|
+
return pruningContext;
|
|
3319
|
+
}
|
|
3300
3320
|
/**
|
|
3301
3321
|
* Get the implementations of an interface. May return undefined.
|
|
3302
3322
|
*/
|
|
@@ -3318,7 +3338,8 @@ function visitInputType(visitedTypes, pruningContext, type) {
|
|
|
3318
3338
|
}
|
|
3319
3339
|
}
|
|
3320
3340
|
}
|
|
3321
|
-
function visitTypes(pruningContext
|
|
3341
|
+
function visitTypes(pruningContext) {
|
|
3342
|
+
const schema = pruningContext.schema;
|
|
3322
3343
|
for (const typeName in schema.getTypeMap()) {
|
|
3323
3344
|
if (!typeName.startsWith('__')) {
|
|
3324
3345
|
pruningContext.unusedTypes[typeName] = true;
|
|
@@ -4175,27 +4196,52 @@ function isDocumentNode(object) {
|
|
|
4175
4196
|
return object && typeof object === 'object' && 'kind' in object && object.kind === graphql.Kind.DOCUMENT;
|
|
4176
4197
|
}
|
|
4177
4198
|
|
|
4178
|
-
async function
|
|
4199
|
+
async function defaultAsyncIteratorReturn(value) {
|
|
4179
4200
|
return { value, done: true };
|
|
4180
4201
|
}
|
|
4181
|
-
function
|
|
4202
|
+
const proxyMethodFactory = memoize2(function proxyMethodFactory(target, targetMethod) {
|
|
4203
|
+
return function proxyMethod(...args) {
|
|
4204
|
+
return Reflect.apply(targetMethod, target, args);
|
|
4205
|
+
};
|
|
4206
|
+
});
|
|
4207
|
+
function getAsyncIteratorWithCancel(asyncIterator, onCancel) {
|
|
4208
|
+
return new Proxy(asyncIterator, {
|
|
4209
|
+
has(asyncIterator, prop) {
|
|
4210
|
+
if (prop === 'return') {
|
|
4211
|
+
return true;
|
|
4212
|
+
}
|
|
4213
|
+
return Reflect.has(asyncIterator, prop);
|
|
4214
|
+
},
|
|
4215
|
+
get(asyncIterator, prop, receiver) {
|
|
4216
|
+
const existingPropValue = Reflect.get(asyncIterator, prop, receiver);
|
|
4217
|
+
if (prop === 'return') {
|
|
4218
|
+
const existingReturn = existingPropValue || defaultAsyncIteratorReturn;
|
|
4219
|
+
return async function returnWithCancel(value) {
|
|
4220
|
+
const returnValue = await onCancel(value);
|
|
4221
|
+
return Reflect.apply(existingReturn, asyncIterator, [returnValue]);
|
|
4222
|
+
};
|
|
4223
|
+
}
|
|
4224
|
+
else if (typeof existingPropValue === 'function') {
|
|
4225
|
+
return proxyMethodFactory(asyncIterator, existingPropValue);
|
|
4226
|
+
}
|
|
4227
|
+
return existingPropValue;
|
|
4228
|
+
},
|
|
4229
|
+
});
|
|
4230
|
+
}
|
|
4231
|
+
function getAsyncIterableWithCancel(asyncIterable, onCancel) {
|
|
4182
4232
|
return new Proxy(asyncIterable, {
|
|
4183
|
-
get(asyncIterable, prop) {
|
|
4233
|
+
get(asyncIterable, prop, receiver) {
|
|
4234
|
+
const existingPropValue = Reflect.get(asyncIterable, prop, receiver);
|
|
4184
4235
|
if (Symbol.asyncIterator === prop) {
|
|
4185
|
-
return function
|
|
4186
|
-
const asyncIterator = asyncIterable[
|
|
4187
|
-
|
|
4188
|
-
asyncIterator.return = defaultReturn;
|
|
4189
|
-
}
|
|
4190
|
-
const savedReturn = asyncIterator.return.bind(asyncIterator);
|
|
4191
|
-
asyncIterator.return = async function extendedReturn(value) {
|
|
4192
|
-
const returnValue = await onCancel(value);
|
|
4193
|
-
return savedReturn(returnValue);
|
|
4194
|
-
};
|
|
4195
|
-
return asyncIterator;
|
|
4236
|
+
return function asyncIteratorFactory() {
|
|
4237
|
+
const asyncIterator = Reflect.apply(existingPropValue, asyncIterable, []);
|
|
4238
|
+
return getAsyncIteratorWithCancel(asyncIterator, onCancel);
|
|
4196
4239
|
};
|
|
4197
4240
|
}
|
|
4198
|
-
|
|
4241
|
+
else if (typeof existingPropValue === 'function') {
|
|
4242
|
+
return proxyMethodFactory(asyncIterable, existingPropValue);
|
|
4243
|
+
}
|
|
4244
|
+
return existingPropValue;
|
|
4199
4245
|
},
|
|
4200
4246
|
});
|
|
4201
4247
|
}
|
|
@@ -4256,6 +4302,8 @@ exports.fixSchemaAst = fixSchemaAst;
|
|
|
4256
4302
|
exports.forEachDefaultValue = forEachDefaultValue;
|
|
4257
4303
|
exports.forEachField = forEachField;
|
|
4258
4304
|
exports.getArgumentValues = getArgumentValues;
|
|
4305
|
+
exports.getAsyncIterableWithCancel = getAsyncIterableWithCancel;
|
|
4306
|
+
exports.getAsyncIteratorWithCancel = getAsyncIteratorWithCancel;
|
|
4259
4307
|
exports.getBlockStringIndentation = getBlockStringIndentation;
|
|
4260
4308
|
exports.getBuiltInForStub = getBuiltInForStub;
|
|
4261
4309
|
exports.getComment = getComment;
|
|
@@ -4330,4 +4378,4 @@ exports.valueMatchesCriteria = valueMatchesCriteria;
|
|
|
4330
4378
|
exports.visitData = visitData;
|
|
4331
4379
|
exports.visitErrors = visitErrors;
|
|
4332
4380
|
exports.visitResult = visitResult;
|
|
4333
|
-
exports.withCancel =
|
|
4381
|
+
exports.withCancel = getAsyncIterableWithCancel;
|
package/index.mjs
CHANGED
|
@@ -223,7 +223,7 @@ function getArgumentValues(def, node, variableValues = {}) {
|
|
|
223
223
|
let isNull = valueNode.kind === Kind.NULL;
|
|
224
224
|
if (valueNode.kind === Kind.VARIABLE) {
|
|
225
225
|
const variableName = valueNode.name.value;
|
|
226
|
-
if (variableValues == null ||
|
|
226
|
+
if (variableValues == null || variableMap[variableName] == null) {
|
|
227
227
|
if (defaultValue !== undefined) {
|
|
228
228
|
coercedValues[name] = defaultValue;
|
|
229
229
|
}
|
|
@@ -3205,57 +3205,54 @@ function addTypes(schema, newTypesOrDirectives) {
|
|
|
3205
3205
|
* @param options Additional options for removing unused types from the schema
|
|
3206
3206
|
*/
|
|
3207
3207
|
function pruneSchema(schema, options = {}) {
|
|
3208
|
-
const pruningContext =
|
|
3209
|
-
|
|
3210
|
-
|
|
3211
|
-
|
|
3212
|
-
|
|
3213
|
-
|
|
3214
|
-
|
|
3215
|
-
if (type && 'getInterfaces' in type) {
|
|
3216
|
-
for (const iface of type.getInterfaces()) {
|
|
3217
|
-
const implementations = getImplementations(pruningContext, iface);
|
|
3218
|
-
if (implementations == null) {
|
|
3219
|
-
pruningContext.implementations[iface.name] = Object.create(null);
|
|
3220
|
-
}
|
|
3221
|
-
pruningContext.implementations[iface.name][type.name] = true;
|
|
3222
|
-
}
|
|
3208
|
+
const pruningContext = createPruningContext(schema);
|
|
3209
|
+
visitTypes(pruningContext);
|
|
3210
|
+
const types = Object.values(schema.getTypeMap());
|
|
3211
|
+
const typesToPrune = new Set();
|
|
3212
|
+
for (const type of types) {
|
|
3213
|
+
if (type.name.startsWith('__')) {
|
|
3214
|
+
continue;
|
|
3223
3215
|
}
|
|
3224
|
-
|
|
3225
|
-
|
|
3226
|
-
|
|
3227
|
-
|
|
3228
|
-
|
|
3229
|
-
if (
|
|
3230
|
-
|
|
3216
|
+
// If we should NOT prune the type, return it immediately as unmodified
|
|
3217
|
+
if (options.skipPruning && options.skipPruning(type)) {
|
|
3218
|
+
continue;
|
|
3219
|
+
}
|
|
3220
|
+
if (isObjectType(type) || isInputObjectType(type)) {
|
|
3221
|
+
if ((!Object.keys(type.getFields()).length && !options.skipEmptyCompositeTypePruning) ||
|
|
3222
|
+
(pruningContext.unusedTypes[type.name] && !options.skipUnusedTypesPruning)) {
|
|
3223
|
+
typesToPrune.add(type.name);
|
|
3231
3224
|
}
|
|
3232
|
-
|
|
3233
|
-
|
|
3234
|
-
|
|
3235
|
-
|
|
3236
|
-
|
|
3225
|
+
}
|
|
3226
|
+
else if (isUnionType(type)) {
|
|
3227
|
+
if ((!type.getTypes().length && !options.skipEmptyUnionPruning) ||
|
|
3228
|
+
(pruningContext.unusedTypes[type.name] && !options.skipUnusedTypesPruning)) {
|
|
3229
|
+
typesToPrune.add(type.name);
|
|
3237
3230
|
}
|
|
3238
|
-
|
|
3239
|
-
|
|
3240
|
-
|
|
3241
|
-
|
|
3242
|
-
|
|
3231
|
+
}
|
|
3232
|
+
else if (isInterfaceType(type)) {
|
|
3233
|
+
const implementations = getImplementations(pruningContext, type);
|
|
3234
|
+
if ((!Object.keys(type.getFields()).length && !options.skipEmptyCompositeTypePruning) ||
|
|
3235
|
+
(implementations && !Object.keys(implementations).length && !options.skipUnimplementedInterfacesPruning) ||
|
|
3236
|
+
(pruningContext.unusedTypes[type.name] && !options.skipUnusedTypesPruning)) {
|
|
3237
|
+
typesToPrune.add(type.name);
|
|
3243
3238
|
}
|
|
3244
|
-
|
|
3245
|
-
|
|
3246
|
-
|
|
3247
|
-
|
|
3248
|
-
(pruningContext.unusedTypes[type.name] && !options.skipUnusedTypesPruning)) {
|
|
3249
|
-
return null;
|
|
3250
|
-
}
|
|
3239
|
+
}
|
|
3240
|
+
else {
|
|
3241
|
+
if (pruningContext.unusedTypes[type.name] && !options.skipUnusedTypesPruning) {
|
|
3242
|
+
typesToPrune.add(type.name);
|
|
3251
3243
|
}
|
|
3252
|
-
|
|
3253
|
-
|
|
3254
|
-
|
|
3255
|
-
|
|
3244
|
+
}
|
|
3245
|
+
}
|
|
3246
|
+
// TODO: consider not returning a new schema if there was nothing to prune. This would be a breaking change.
|
|
3247
|
+
const prunedSchema = mapSchema(schema, {
|
|
3248
|
+
[MapperKind.TYPE]: (type) => {
|
|
3249
|
+
if (typesToPrune.has(type.name)) {
|
|
3250
|
+
return null;
|
|
3256
3251
|
}
|
|
3257
3252
|
},
|
|
3258
3253
|
});
|
|
3254
|
+
// if we pruned something, we need to prune again in case there are now objects without fields
|
|
3255
|
+
return typesToPrune.size ? pruneSchema(prunedSchema, options) : prunedSchema;
|
|
3259
3256
|
}
|
|
3260
3257
|
function visitOutputType(visitedTypes, pruningContext, type) {
|
|
3261
3258
|
if (visitedTypes[type.name]) {
|
|
@@ -3295,6 +3292,29 @@ function visitOutputType(visitedTypes, pruningContext, type) {
|
|
|
3295
3292
|
}
|
|
3296
3293
|
}
|
|
3297
3294
|
}
|
|
3295
|
+
/**
|
|
3296
|
+
* Initialize a pruneContext given a schema.
|
|
3297
|
+
*/
|
|
3298
|
+
function createPruningContext(schema) {
|
|
3299
|
+
const pruningContext = {
|
|
3300
|
+
schema,
|
|
3301
|
+
unusedTypes: Object.create(null),
|
|
3302
|
+
implementations: Object.create(null),
|
|
3303
|
+
};
|
|
3304
|
+
for (const typeName in schema.getTypeMap()) {
|
|
3305
|
+
const type = schema.getType(typeName);
|
|
3306
|
+
if (type && 'getInterfaces' in type) {
|
|
3307
|
+
for (const iface of type.getInterfaces()) {
|
|
3308
|
+
const implementations = getImplementations(pruningContext, iface);
|
|
3309
|
+
if (implementations == null) {
|
|
3310
|
+
pruningContext.implementations[iface.name] = Object.create(null);
|
|
3311
|
+
}
|
|
3312
|
+
pruningContext.implementations[iface.name][type.name] = true;
|
|
3313
|
+
}
|
|
3314
|
+
}
|
|
3315
|
+
}
|
|
3316
|
+
return pruningContext;
|
|
3317
|
+
}
|
|
3298
3318
|
/**
|
|
3299
3319
|
* Get the implementations of an interface. May return undefined.
|
|
3300
3320
|
*/
|
|
@@ -3316,7 +3336,8 @@ function visitInputType(visitedTypes, pruningContext, type) {
|
|
|
3316
3336
|
}
|
|
3317
3337
|
}
|
|
3318
3338
|
}
|
|
3319
|
-
function visitTypes(pruningContext
|
|
3339
|
+
function visitTypes(pruningContext) {
|
|
3340
|
+
const schema = pruningContext.schema;
|
|
3320
3341
|
for (const typeName in schema.getTypeMap()) {
|
|
3321
3342
|
if (!typeName.startsWith('__')) {
|
|
3322
3343
|
pruningContext.unusedTypes[typeName] = true;
|
|
@@ -4173,27 +4194,52 @@ function isDocumentNode(object) {
|
|
|
4173
4194
|
return object && typeof object === 'object' && 'kind' in object && object.kind === Kind.DOCUMENT;
|
|
4174
4195
|
}
|
|
4175
4196
|
|
|
4176
|
-
async function
|
|
4197
|
+
async function defaultAsyncIteratorReturn(value) {
|
|
4177
4198
|
return { value, done: true };
|
|
4178
4199
|
}
|
|
4179
|
-
function
|
|
4200
|
+
const proxyMethodFactory = memoize2(function proxyMethodFactory(target, targetMethod) {
|
|
4201
|
+
return function proxyMethod(...args) {
|
|
4202
|
+
return Reflect.apply(targetMethod, target, args);
|
|
4203
|
+
};
|
|
4204
|
+
});
|
|
4205
|
+
function getAsyncIteratorWithCancel(asyncIterator, onCancel) {
|
|
4206
|
+
return new Proxy(asyncIterator, {
|
|
4207
|
+
has(asyncIterator, prop) {
|
|
4208
|
+
if (prop === 'return') {
|
|
4209
|
+
return true;
|
|
4210
|
+
}
|
|
4211
|
+
return Reflect.has(asyncIterator, prop);
|
|
4212
|
+
},
|
|
4213
|
+
get(asyncIterator, prop, receiver) {
|
|
4214
|
+
const existingPropValue = Reflect.get(asyncIterator, prop, receiver);
|
|
4215
|
+
if (prop === 'return') {
|
|
4216
|
+
const existingReturn = existingPropValue || defaultAsyncIteratorReturn;
|
|
4217
|
+
return async function returnWithCancel(value) {
|
|
4218
|
+
const returnValue = await onCancel(value);
|
|
4219
|
+
return Reflect.apply(existingReturn, asyncIterator, [returnValue]);
|
|
4220
|
+
};
|
|
4221
|
+
}
|
|
4222
|
+
else if (typeof existingPropValue === 'function') {
|
|
4223
|
+
return proxyMethodFactory(asyncIterator, existingPropValue);
|
|
4224
|
+
}
|
|
4225
|
+
return existingPropValue;
|
|
4226
|
+
},
|
|
4227
|
+
});
|
|
4228
|
+
}
|
|
4229
|
+
function getAsyncIterableWithCancel(asyncIterable, onCancel) {
|
|
4180
4230
|
return new Proxy(asyncIterable, {
|
|
4181
|
-
get(asyncIterable, prop) {
|
|
4231
|
+
get(asyncIterable, prop, receiver) {
|
|
4232
|
+
const existingPropValue = Reflect.get(asyncIterable, prop, receiver);
|
|
4182
4233
|
if (Symbol.asyncIterator === prop) {
|
|
4183
|
-
return function
|
|
4184
|
-
const asyncIterator = asyncIterable[
|
|
4185
|
-
|
|
4186
|
-
asyncIterator.return = defaultReturn;
|
|
4187
|
-
}
|
|
4188
|
-
const savedReturn = asyncIterator.return.bind(asyncIterator);
|
|
4189
|
-
asyncIterator.return = async function extendedReturn(value) {
|
|
4190
|
-
const returnValue = await onCancel(value);
|
|
4191
|
-
return savedReturn(returnValue);
|
|
4192
|
-
};
|
|
4193
|
-
return asyncIterator;
|
|
4234
|
+
return function asyncIteratorFactory() {
|
|
4235
|
+
const asyncIterator = Reflect.apply(existingPropValue, asyncIterable, []);
|
|
4236
|
+
return getAsyncIteratorWithCancel(asyncIterator, onCancel);
|
|
4194
4237
|
};
|
|
4195
4238
|
}
|
|
4196
|
-
|
|
4239
|
+
else if (typeof existingPropValue === 'function') {
|
|
4240
|
+
return proxyMethodFactory(asyncIterable, existingPropValue);
|
|
4241
|
+
}
|
|
4242
|
+
return existingPropValue;
|
|
4197
4243
|
},
|
|
4198
4244
|
});
|
|
4199
4245
|
}
|
|
@@ -4219,4 +4265,4 @@ function fixSchemaAst(schema, options) {
|
|
|
4219
4265
|
return schema;
|
|
4220
4266
|
}
|
|
4221
4267
|
|
|
4222
|
-
export { AggregateErrorImpl as AggregateError, MapperKind, addTypes, appendObjectFields, asArray, assertSome, astFromArg, astFromDirective, astFromEnumType, astFromEnumValue, astFromField, astFromInputField, astFromInputObjectType, astFromInterfaceType, astFromObjectType, astFromScalarType, astFromSchema, astFromUnionType, astFromValueUntyped, buildOperationNodeForField, checkValidationErrors, collectComment, collectFields, collectSubFields, compareNodes, compareStrings, correctASTNodes, createDefaultRules, createNamedStub, createStub, createVariableNameGenerator, dedentBlockStringValue, filterSchema, fixSchemaAst, forEachDefaultValue, forEachField, getArgumentValues, getBlockStringIndentation, getBuiltInForStub, getComment, getDefinedRootType, getDeprecatableDirectiveNodes, getDescription, getDirective, getDirectiveInExtensions, getDirectiveNodes, getDirectives, getDirectivesInExtensions, getDocumentNodeFromSchema, getFieldsWithDirectives, getImplementingTypes, getLeadingCommentBlock, getOperationASTFromDocument, getOperationASTFromRequest, getResolversFromSchema, getResponseKeyFromInfo, getRootTypeMap, getRootTypeNames, getRootTypes, healSchema, healTypes, implementsAbstractType, inspect, isAggregateError, isAsyncIterable, isDescribable, isDocumentNode, isDocumentString, isNamedStub, isSome, isValidPath, makeDeprecatedDirective, makeDirectiveNode, makeDirectiveNodes, mapAsyncIterator, mapSchema, memoize1, memoize2, memoize2of4, memoize3, memoize4, memoize5, mergeDeep, modifyObjectFields, nodeToString, observableToAsyncIterable, parseGraphQLJSON, parseGraphQLSDL, parseInputValue, parseInputValueLiteral, parseSelectionSet, printComment, printSchemaWithDirectives, printWithComments, pruneSchema, pushComment, relocatedError, removeObjectFields, renameType, resetComments, rewireTypes, selectObjectFields, serializeInputValue, transformCommentsToDescriptions, transformInputValue, updateArgument, validateGraphQlDocuments, valueMatchesCriteria, visitData, visitErrors, visitResult, withCancel };
|
|
4268
|
+
export { AggregateErrorImpl as AggregateError, MapperKind, addTypes, appendObjectFields, asArray, assertSome, astFromArg, astFromDirective, astFromEnumType, astFromEnumValue, astFromField, astFromInputField, astFromInputObjectType, astFromInterfaceType, astFromObjectType, astFromScalarType, astFromSchema, astFromUnionType, astFromValueUntyped, buildOperationNodeForField, checkValidationErrors, collectComment, collectFields, collectSubFields, compareNodes, compareStrings, correctASTNodes, createDefaultRules, createNamedStub, createStub, createVariableNameGenerator, dedentBlockStringValue, filterSchema, fixSchemaAst, forEachDefaultValue, forEachField, getArgumentValues, getAsyncIterableWithCancel, getAsyncIteratorWithCancel, getBlockStringIndentation, getBuiltInForStub, getComment, getDefinedRootType, getDeprecatableDirectiveNodes, getDescription, getDirective, getDirectiveInExtensions, getDirectiveNodes, getDirectives, getDirectivesInExtensions, getDocumentNodeFromSchema, getFieldsWithDirectives, getImplementingTypes, getLeadingCommentBlock, getOperationASTFromDocument, getOperationASTFromRequest, getResolversFromSchema, getResponseKeyFromInfo, getRootTypeMap, getRootTypeNames, getRootTypes, healSchema, healTypes, implementsAbstractType, inspect, isAggregateError, isAsyncIterable, isDescribable, isDocumentNode, isDocumentString, isNamedStub, isSome, isValidPath, makeDeprecatedDirective, makeDirectiveNode, makeDirectiveNodes, mapAsyncIterator, mapSchema, memoize1, memoize2, memoize2of4, memoize3, memoize4, memoize5, mergeDeep, modifyObjectFields, nodeToString, observableToAsyncIterable, parseGraphQLJSON, parseGraphQLSDL, parseInputValue, parseInputValueLiteral, parseSelectionSet, printComment, printSchemaWithDirectives, printWithComments, pruneSchema, pushComment, relocatedError, removeObjectFields, renameType, resetComments, rewireTypes, selectObjectFields, serializeInputValue, transformCommentsToDescriptions, transformInputValue, updateArgument, validateGraphQlDocuments, valueMatchesCriteria, visitData, visitErrors, visitResult, getAsyncIterableWithCancel as withCancel };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-tools/utils",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.6.1",
|
|
4
4
|
"description": "Common package containing utils and types for GraphQL tools",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"peerDependencies": {
|
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
"./*": {
|
|
31
31
|
"require": "./*.js",
|
|
32
32
|
"import": "./*.mjs"
|
|
33
|
-
}
|
|
33
|
+
},
|
|
34
|
+
"./package.json": "./package.json"
|
|
34
35
|
}
|
|
35
36
|
}
|
package/withCancel.d.ts
CHANGED
|
@@ -1 +1,3 @@
|
|
|
1
|
-
export declare function
|
|
1
|
+
export declare function getAsyncIteratorWithCancel<T, TReturn = any>(asyncIterator: AsyncIterator<T>, onCancel: (value?: TReturn) => void | Promise<void>): AsyncIterator<T>;
|
|
2
|
+
export declare function getAsyncIterableWithCancel<T, TAsyncIterable extends AsyncIterable<T>, TReturn = any>(asyncIterable: TAsyncIterable, onCancel: (value?: TReturn) => void | Promise<void>): TAsyncIterable;
|
|
3
|
+
export { getAsyncIterableWithCancel as withCancel };
|