@graphql-tools/stitch 9.4.13 → 9.4.14-alpha-43377dcf7f0183163bf8260e8da347376d2bb23a
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/CHANGELOG.md +6 -0
- package/dist/index.cjs +53 -33
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +54 -34
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @graphql-tools/stitch
|
|
2
2
|
|
|
3
|
+
## 9.4.14-alpha-43377dcf7f0183163bf8260e8da347376d2bb23a
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#443](https://github.com/graphql-hive/gateway/pull/443) [`43377dc`](https://github.com/graphql-hive/gateway/commit/43377dcf7f0183163bf8260e8da347376d2bb23a) Thanks [@ardatan](https://github.com/ardatan)! - Respect fragments while calculating the selection score
|
|
8
|
+
|
|
3
9
|
## 9.4.13
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
package/dist/index.cjs
CHANGED
|
@@ -222,7 +222,7 @@ function memoize5of7(fn) {
|
|
|
222
222
|
return newValue;
|
|
223
223
|
}
|
|
224
224
|
const cachedValue = cache5.get(a5);
|
|
225
|
-
if (cachedValue ===
|
|
225
|
+
if (cachedValue === undefined) {
|
|
226
226
|
const newValue = fn(a1, a2, a3, a4, a5, a6, a7);
|
|
227
227
|
cache5.set(a5, newValue);
|
|
228
228
|
return newValue;
|
|
@@ -231,7 +231,7 @@ function memoize5of7(fn) {
|
|
|
231
231
|
};
|
|
232
232
|
}
|
|
233
233
|
|
|
234
|
-
function calculateDelegationStage(mergedTypeInfo, sourceSubschemas, targetSubschemas, fieldNodes) {
|
|
234
|
+
function calculateDelegationStage(mergedTypeInfo, sourceSubschemas, targetSubschemas, fieldNodes, fragments) {
|
|
235
235
|
const { selectionSets, fieldSelectionSets, uniqueFields, nonUniqueFields } = mergedTypeInfo;
|
|
236
236
|
const proxiableSubschemas = [];
|
|
237
237
|
const nonProxiableSubschemas = [];
|
|
@@ -350,7 +350,10 @@ function calculateDelegationStage(mergedTypeInfo, sourceSubschemas, targetSubsch
|
|
|
350
350
|
return true;
|
|
351
351
|
}
|
|
352
352
|
);
|
|
353
|
-
const currentScore = calculateSelectionScore(
|
|
353
|
+
const currentScore = calculateSelectionScore(
|
|
354
|
+
unavailableFields,
|
|
355
|
+
fragments
|
|
356
|
+
);
|
|
354
357
|
if (currentScore < bestScore) {
|
|
355
358
|
bestScore = currentScore;
|
|
356
359
|
bestUniqueSubschema = nonUniqueSubschema;
|
|
@@ -373,25 +376,40 @@ function calculateDelegationStage(mergedTypeInfo, sourceSubschemas, targetSubsch
|
|
|
373
376
|
unproxiableFieldNodes
|
|
374
377
|
};
|
|
375
378
|
}
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
379
|
+
const calculateSelectionScore = utils.memoize2(
|
|
380
|
+
function calculateSelectionScore2(selections, fragments) {
|
|
381
|
+
let score = 0;
|
|
382
|
+
for (const selectionNode of selections) {
|
|
383
|
+
switch (selectionNode.kind) {
|
|
384
|
+
case graphql.Kind.FIELD:
|
|
385
|
+
score++;
|
|
386
|
+
if (selectionNode.selectionSet?.selections) {
|
|
387
|
+
score += calculateSelectionScore2(
|
|
388
|
+
selectionNode.selectionSet.selections,
|
|
389
|
+
fragments
|
|
390
|
+
);
|
|
391
|
+
}
|
|
392
|
+
break;
|
|
393
|
+
case graphql.Kind.INLINE_FRAGMENT:
|
|
394
|
+
score += calculateSelectionScore2(
|
|
395
|
+
selectionNode.selectionSet.selections,
|
|
396
|
+
fragments
|
|
385
397
|
);
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
398
|
+
break;
|
|
399
|
+
case graphql.Kind.FRAGMENT_SPREAD:
|
|
400
|
+
const fragment = fragments?.[selectionNode.name.value];
|
|
401
|
+
if (fragment) {
|
|
402
|
+
score += calculateSelectionScore2(
|
|
403
|
+
fragment.selectionSet.selections,
|
|
404
|
+
fragments
|
|
405
|
+
);
|
|
406
|
+
}
|
|
407
|
+
break;
|
|
408
|
+
}
|
|
391
409
|
}
|
|
410
|
+
return score;
|
|
392
411
|
}
|
|
393
|
-
|
|
394
|
-
}
|
|
412
|
+
);
|
|
395
413
|
function getStitchingInfo(schema) {
|
|
396
414
|
const stitchingInfo = schema.extensions?.["stitchingInfo"];
|
|
397
415
|
if (!stitchingInfo) {
|
|
@@ -429,7 +447,8 @@ function createDelegationPlanBuilder(mergedTypeInfo) {
|
|
|
429
447
|
mergedTypeInfo,
|
|
430
448
|
sourceSubschemas,
|
|
431
449
|
targetSubschemas,
|
|
432
|
-
fieldsNotInSubschema
|
|
450
|
+
fieldsNotInSubschema,
|
|
451
|
+
fragments
|
|
433
452
|
);
|
|
434
453
|
let { delegationMap } = delegationStage;
|
|
435
454
|
while (delegationMap.size) {
|
|
@@ -447,7 +466,8 @@ function createDelegationPlanBuilder(mergedTypeInfo) {
|
|
|
447
466
|
mergedTypeInfo,
|
|
448
467
|
sourceSubschemas,
|
|
449
468
|
nonProxiableSubschemas,
|
|
450
|
-
unproxiableFieldNodes
|
|
469
|
+
unproxiableFieldNodes,
|
|
470
|
+
fragments
|
|
451
471
|
);
|
|
452
472
|
delegationMap = delegationStage.delegationMap;
|
|
453
473
|
}
|
|
@@ -641,7 +661,7 @@ function createMergedTypeResolver(mergedTypeResolverOptions, mergedType) {
|
|
|
641
661
|
});
|
|
642
662
|
};
|
|
643
663
|
}
|
|
644
|
-
return
|
|
664
|
+
return undefined;
|
|
645
665
|
}
|
|
646
666
|
|
|
647
667
|
function createStitchingInfo(subschemaMap, typeCandidates, mergeTypes) {
|
|
@@ -729,7 +749,7 @@ function createMergedTypes(typeCandidates, mergeTypes) {
|
|
|
729
749
|
const rawFieldSelectionSet = mergedTypeConfig2.fields[fieldName].selectionSet;
|
|
730
750
|
parsedFieldSelectionSets[fieldName] = rawFieldSelectionSet ? utils.parseSelectionSet(rawFieldSelectionSet, {
|
|
731
751
|
noLocation: true
|
|
732
|
-
}) :
|
|
752
|
+
}) : undefined;
|
|
733
753
|
}
|
|
734
754
|
if (mergedTypeConfig2.fields[fieldName]?.provides) {
|
|
735
755
|
let providedSelectionsForSubschema = providedSelectionsByField.get(subschema);
|
|
@@ -890,7 +910,7 @@ function completeStitchingInfo(stitchingInfo, resolvers, schema) {
|
|
|
890
910
|
}
|
|
891
911
|
for (const typeName in resolvers) {
|
|
892
912
|
const type = schema.getType(typeName);
|
|
893
|
-
if (type ===
|
|
913
|
+
if (type === undefined || graphql.isLeafType(type) || graphql.isInputObjectType(type) || graphql.isUnionType(type)) {
|
|
894
914
|
continue;
|
|
895
915
|
}
|
|
896
916
|
const resolver = resolvers[typeName];
|
|
@@ -972,12 +992,12 @@ function updateSelectionSetMap(map, typeName, fieldName, selectionSet, includeTy
|
|
|
972
992
|
}
|
|
973
993
|
function updateArrayMap(map, typeName, fieldName, value, initialValue) {
|
|
974
994
|
if (map[typeName] == null) {
|
|
975
|
-
const initialItems = initialValue ===
|
|
995
|
+
const initialItems = initialValue === undefined ? [value] : [initialValue, value];
|
|
976
996
|
map[typeName] = {
|
|
977
997
|
[fieldName]: initialItems
|
|
978
998
|
};
|
|
979
999
|
} else if (map[typeName][fieldName] == null) {
|
|
980
|
-
const initialItems = initialValue ===
|
|
1000
|
+
const initialItems = initialValue === undefined ? [value] : [initialValue, value];
|
|
981
1001
|
map[typeName][fieldName] = initialItems;
|
|
982
1002
|
} else {
|
|
983
1003
|
map[typeName][fieldName].push(value);
|
|
@@ -1067,7 +1087,7 @@ function isolateComputedFieldsTransformer(subschemaConfig) {
|
|
|
1067
1087
|
...isolatedSchemaTypes[typeName]?.fields ?? {},
|
|
1068
1088
|
...isolatedFields
|
|
1069
1089
|
},
|
|
1070
|
-
canonical:
|
|
1090
|
+
canonical: undefined
|
|
1071
1091
|
};
|
|
1072
1092
|
for (const fieldName in isolatedFields) {
|
|
1073
1093
|
const returnType = graphql.getNamedType(
|
|
@@ -1207,8 +1227,8 @@ function _createCompositeFieldFilter(schema) {
|
|
|
1207
1227
|
}
|
|
1208
1228
|
}
|
|
1209
1229
|
return new wrap.TransformCompositeFields(
|
|
1210
|
-
(typeName, fieldName) => filteredFields[typeName]?.[fieldName] ?
|
|
1211
|
-
(typeName, fieldName) => filteredFields[typeName]?.[fieldName] ?
|
|
1230
|
+
(typeName, fieldName) => filteredFields[typeName]?.[fieldName] ? undefined : null,
|
|
1231
|
+
(typeName, fieldName) => filteredFields[typeName]?.[fieldName] ? undefined : null
|
|
1212
1232
|
);
|
|
1213
1233
|
}
|
|
1214
1234
|
function isIsolatedField(typeName, fieldName, isolatedSchemaTypes) {
|
|
@@ -1284,7 +1304,7 @@ function filterBaseSubschema(subschemaConfig, isolatedSchemaTypes) {
|
|
|
1284
1304
|
...subschemaConfig,
|
|
1285
1305
|
merge: subschemaConfig.merge ? {
|
|
1286
1306
|
...subschemaConfig.merge
|
|
1287
|
-
} :
|
|
1307
|
+
} : undefined,
|
|
1288
1308
|
transforms: (subschemaConfig.transforms ?? []).concat([
|
|
1289
1309
|
_createCompositeFieldFilter(filteredSchema),
|
|
1290
1310
|
new wrap.FilterTypes((type) => {
|
|
@@ -2415,7 +2435,7 @@ function canonicalFieldNamesForType(candidates) {
|
|
|
2415
2435
|
|
|
2416
2436
|
function mergeDirectives(directives) {
|
|
2417
2437
|
if (directives.size === 0) {
|
|
2418
|
-
return
|
|
2438
|
+
return undefined;
|
|
2419
2439
|
}
|
|
2420
2440
|
if (directives.size === 1) {
|
|
2421
2441
|
const directive = directives.values().next().value;
|
|
@@ -2449,7 +2469,7 @@ function mergeDirectives(directives) {
|
|
|
2449
2469
|
locations: Array.from(locations),
|
|
2450
2470
|
args,
|
|
2451
2471
|
isRepeatable,
|
|
2452
|
-
extensions: extensionsSet.size > 0 ? utils.mergeDeep([...extensionsSet]) :
|
|
2472
|
+
extensions: extensionsSet.size > 0 ? utils.mergeDeep([...extensionsSet]) : undefined
|
|
2453
2473
|
});
|
|
2454
2474
|
}
|
|
2455
2475
|
|
|
@@ -2564,7 +2584,7 @@ function makeValues(nodes) {
|
|
|
2564
2584
|
...prev,
|
|
2565
2585
|
[node.name.value]: {
|
|
2566
2586
|
type: utils.createStub(node.type, "input"),
|
|
2567
|
-
defaultValue: node.defaultValue !==
|
|
2587
|
+
defaultValue: node.defaultValue !== undefined ? graphql.valueFromASTUntyped(node.defaultValue) : undefined,
|
|
2568
2588
|
description: utils.getDescription(node, backcompatOptions),
|
|
2569
2589
|
astNode: node
|
|
2570
2590
|
}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FieldNode, SelectionSetNode, GraphQLNamedType, GraphQLSchema, GraphQLFieldConfig, GraphQLObjectType, GraphQLInterfaceType, GraphQLInputFieldConfig, GraphQLInputObjectType, GraphQLEnumValueConfig, GraphQLEnumType, GraphQLOutputType, SelectionNode } from 'graphql';
|
|
1
|
+
import { FieldNode, SelectionSetNode, GraphQLNamedType, GraphQLSchema, GraphQLFieldConfig, GraphQLObjectType, GraphQLInterfaceType, GraphQLInputFieldConfig, GraphQLInputObjectType, GraphQLEnumValueConfig, GraphQLEnumType, GraphQLOutputType, SelectionNode, FragmentDefinitionNode } from 'graphql';
|
|
2
2
|
import { SubschemaConfig, Subschema, MergedTypeResolverOptions, MergedTypeResolver } from '@graphql-tools/delegate';
|
|
3
3
|
import { IExecutableSchemaDefinition } from '@graphql-tools/schema';
|
|
4
4
|
import { TypeSource, Maybe, ExecutionRequest } from '@graphql-tools/utils';
|
|
@@ -103,6 +103,6 @@ declare function createStitchingExecutor(stitchedSchema: GraphQLSchema): (execut
|
|
|
103
103
|
|
|
104
104
|
declare function getDefaultFieldConfigMerger(useNonNullableFieldOnConflict?: boolean): <TContext = Record<string, any>>(candidates: Array<MergeFieldConfigCandidate<TContext>>) => GraphQLFieldConfig<any, TContext, any>;
|
|
105
105
|
|
|
106
|
-
declare
|
|
106
|
+
declare const calculateSelectionScore: (selections: readonly SelectionNode[], fragments: Record<string, FragmentDefinitionNode>) => number;
|
|
107
107
|
|
|
108
108
|
export { type IStitchSchemasOptions, type MergeEnumValueConfigCandidate, type MergeFieldConfigCandidate, type MergeInputFieldConfigCandidate, type MergeTypeCandidate, type MergeTypeFilter, type OnTypeConflict, type SubschemaConfigTransform, type TypeMergingOptions, ValidationLevel, type ValidationSettings, calculateSelectionScore, createMergedTypeResolver, createStitchingExecutor, forwardArgsToSelectionSet, getDefaultFieldConfigMerger, handleRelaySubschemas, isolateComputedFieldsTransformer, splitMergedTypeEntryPointsTransformer, stitchSchemas };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FieldNode, SelectionSetNode, GraphQLNamedType, GraphQLSchema, GraphQLFieldConfig, GraphQLObjectType, GraphQLInterfaceType, GraphQLInputFieldConfig, GraphQLInputObjectType, GraphQLEnumValueConfig, GraphQLEnumType, GraphQLOutputType, SelectionNode } from 'graphql';
|
|
1
|
+
import { FieldNode, SelectionSetNode, GraphQLNamedType, GraphQLSchema, GraphQLFieldConfig, GraphQLObjectType, GraphQLInterfaceType, GraphQLInputFieldConfig, GraphQLInputObjectType, GraphQLEnumValueConfig, GraphQLEnumType, GraphQLOutputType, SelectionNode, FragmentDefinitionNode } from 'graphql';
|
|
2
2
|
import { SubschemaConfig, Subschema, MergedTypeResolverOptions, MergedTypeResolver } from '@graphql-tools/delegate';
|
|
3
3
|
import { IExecutableSchemaDefinition } from '@graphql-tools/schema';
|
|
4
4
|
import { TypeSource, Maybe, ExecutionRequest } from '@graphql-tools/utils';
|
|
@@ -103,6 +103,6 @@ declare function createStitchingExecutor(stitchedSchema: GraphQLSchema): (execut
|
|
|
103
103
|
|
|
104
104
|
declare function getDefaultFieldConfigMerger(useNonNullableFieldOnConflict?: boolean): <TContext = Record<string, any>>(candidates: Array<MergeFieldConfigCandidate<TContext>>) => GraphQLFieldConfig<any, TContext, any>;
|
|
105
105
|
|
|
106
|
-
declare
|
|
106
|
+
declare const calculateSelectionScore: (selections: readonly SelectionNode[], fragments: Record<string, FragmentDefinitionNode>) => number;
|
|
107
107
|
|
|
108
108
|
export { type IStitchSchemasOptions, type MergeEnumValueConfigCandidate, type MergeFieldConfigCandidate, type MergeInputFieldConfigCandidate, type MergeTypeCandidate, type MergeTypeFilter, type OnTypeConflict, type SubschemaConfigTransform, type TypeMergingOptions, ValidationLevel, type ValidationSettings, calculateSelectionScore, createMergedTypeResolver, createStitchingExecutor, forwardArgsToSelectionSet, getDefaultFieldConfigMerger, handleRelaySubschemas, isolateComputedFieldsTransformer, splitMergedTypeEntryPointsTransformer, stitchSchemas };
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { extractUnavailableFields, leftOverByDelegationPlan, extractUnavailableFieldsFromSelectionSet, delegateToSchema, cloneSubschemaConfig, isSubschemaConfig, defaultMergedResolver, Subschema } from '@graphql-tools/delegate';
|
|
2
2
|
import { mergeType, mergeInputType, mergeInterface, mergeUnion, mergeEnum, mergeScalar, mergeTypeDefs, mergeResolvers, mergeExtensions, applyExtensions } from '@graphql-tools/merge';
|
|
3
3
|
import { extendResolversFromInterfaces, addResolversToSchema, assertResolversPresent, makeExecutableSchema } from '@graphql-tools/schema';
|
|
4
|
-
import { collectSubFields,
|
|
4
|
+
import { collectSubFields, memoize2, memoize1, memoize3, parseSelectionSet, mapMaybePromise, isSome, collectFields, getImplementingTypes, filterSchema, getRootTypeNames, mergeDeep, getDescription, createNamedStub, createStub, getRootTypeMap, getRootTypes, inspect, rewireTypes, getOperationASTFromRequest, getDefinedRootType } from '@graphql-tools/utils';
|
|
5
5
|
import { isAbstractType, Kind, getNamedType, GraphQLList, isObjectType, isInterfaceType, isLeafType, isInputObjectType, isUnionType, print, isScalarType, isCompositeType, isNonNullType, isEnumType, isListType, getNullableType, isNullableType, GraphQLObjectType, GraphQLInputObjectType, GraphQLInterfaceType, GraphQLUnionType, GraphQLEnumType, GraphQLScalarType, GraphQLDirective, valueFromASTUntyped, getDirectiveValues, GraphQLDeprecatedDirective, DirectiveLocation, isNamedType, isIntrospectionType, isDirective, isSpecifiedScalarType, specifiedDirectives, GraphQLSchema, extendSchema } from 'graphql';
|
|
6
6
|
import { batchDelegateToSchema } from '@graphql-tools/batch-delegate';
|
|
7
7
|
import { FilterTypes, TransformCompositeFields, wrapSchema } from '@graphql-tools/wrap';
|
|
@@ -220,7 +220,7 @@ function memoize5of7(fn) {
|
|
|
220
220
|
return newValue;
|
|
221
221
|
}
|
|
222
222
|
const cachedValue = cache5.get(a5);
|
|
223
|
-
if (cachedValue ===
|
|
223
|
+
if (cachedValue === undefined) {
|
|
224
224
|
const newValue = fn(a1, a2, a3, a4, a5, a6, a7);
|
|
225
225
|
cache5.set(a5, newValue);
|
|
226
226
|
return newValue;
|
|
@@ -229,7 +229,7 @@ function memoize5of7(fn) {
|
|
|
229
229
|
};
|
|
230
230
|
}
|
|
231
231
|
|
|
232
|
-
function calculateDelegationStage(mergedTypeInfo, sourceSubschemas, targetSubschemas, fieldNodes) {
|
|
232
|
+
function calculateDelegationStage(mergedTypeInfo, sourceSubschemas, targetSubschemas, fieldNodes, fragments) {
|
|
233
233
|
const { selectionSets, fieldSelectionSets, uniqueFields, nonUniqueFields } = mergedTypeInfo;
|
|
234
234
|
const proxiableSubschemas = [];
|
|
235
235
|
const nonProxiableSubschemas = [];
|
|
@@ -348,7 +348,10 @@ function calculateDelegationStage(mergedTypeInfo, sourceSubschemas, targetSubsch
|
|
|
348
348
|
return true;
|
|
349
349
|
}
|
|
350
350
|
);
|
|
351
|
-
const currentScore = calculateSelectionScore(
|
|
351
|
+
const currentScore = calculateSelectionScore(
|
|
352
|
+
unavailableFields,
|
|
353
|
+
fragments
|
|
354
|
+
);
|
|
352
355
|
if (currentScore < bestScore) {
|
|
353
356
|
bestScore = currentScore;
|
|
354
357
|
bestUniqueSubschema = nonUniqueSubschema;
|
|
@@ -371,25 +374,40 @@ function calculateDelegationStage(mergedTypeInfo, sourceSubschemas, targetSubsch
|
|
|
371
374
|
unproxiableFieldNodes
|
|
372
375
|
};
|
|
373
376
|
}
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
377
|
+
const calculateSelectionScore = memoize2(
|
|
378
|
+
function calculateSelectionScore2(selections, fragments) {
|
|
379
|
+
let score = 0;
|
|
380
|
+
for (const selectionNode of selections) {
|
|
381
|
+
switch (selectionNode.kind) {
|
|
382
|
+
case Kind.FIELD:
|
|
383
|
+
score++;
|
|
384
|
+
if (selectionNode.selectionSet?.selections) {
|
|
385
|
+
score += calculateSelectionScore2(
|
|
386
|
+
selectionNode.selectionSet.selections,
|
|
387
|
+
fragments
|
|
388
|
+
);
|
|
389
|
+
}
|
|
390
|
+
break;
|
|
391
|
+
case Kind.INLINE_FRAGMENT:
|
|
392
|
+
score += calculateSelectionScore2(
|
|
393
|
+
selectionNode.selectionSet.selections,
|
|
394
|
+
fragments
|
|
383
395
|
);
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
396
|
+
break;
|
|
397
|
+
case Kind.FRAGMENT_SPREAD:
|
|
398
|
+
const fragment = fragments?.[selectionNode.name.value];
|
|
399
|
+
if (fragment) {
|
|
400
|
+
score += calculateSelectionScore2(
|
|
401
|
+
fragment.selectionSet.selections,
|
|
402
|
+
fragments
|
|
403
|
+
);
|
|
404
|
+
}
|
|
405
|
+
break;
|
|
406
|
+
}
|
|
389
407
|
}
|
|
408
|
+
return score;
|
|
390
409
|
}
|
|
391
|
-
|
|
392
|
-
}
|
|
410
|
+
);
|
|
393
411
|
function getStitchingInfo(schema) {
|
|
394
412
|
const stitchingInfo = schema.extensions?.["stitchingInfo"];
|
|
395
413
|
if (!stitchingInfo) {
|
|
@@ -427,7 +445,8 @@ function createDelegationPlanBuilder(mergedTypeInfo) {
|
|
|
427
445
|
mergedTypeInfo,
|
|
428
446
|
sourceSubschemas,
|
|
429
447
|
targetSubschemas,
|
|
430
|
-
fieldsNotInSubschema
|
|
448
|
+
fieldsNotInSubschema,
|
|
449
|
+
fragments
|
|
431
450
|
);
|
|
432
451
|
let { delegationMap } = delegationStage;
|
|
433
452
|
while (delegationMap.size) {
|
|
@@ -445,7 +464,8 @@ function createDelegationPlanBuilder(mergedTypeInfo) {
|
|
|
445
464
|
mergedTypeInfo,
|
|
446
465
|
sourceSubschemas,
|
|
447
466
|
nonProxiableSubschemas,
|
|
448
|
-
unproxiableFieldNodes
|
|
467
|
+
unproxiableFieldNodes,
|
|
468
|
+
fragments
|
|
449
469
|
);
|
|
450
470
|
delegationMap = delegationStage.delegationMap;
|
|
451
471
|
}
|
|
@@ -639,7 +659,7 @@ function createMergedTypeResolver(mergedTypeResolverOptions, mergedType) {
|
|
|
639
659
|
});
|
|
640
660
|
};
|
|
641
661
|
}
|
|
642
|
-
return
|
|
662
|
+
return undefined;
|
|
643
663
|
}
|
|
644
664
|
|
|
645
665
|
function createStitchingInfo(subschemaMap, typeCandidates, mergeTypes) {
|
|
@@ -727,7 +747,7 @@ function createMergedTypes(typeCandidates, mergeTypes) {
|
|
|
727
747
|
const rawFieldSelectionSet = mergedTypeConfig2.fields[fieldName].selectionSet;
|
|
728
748
|
parsedFieldSelectionSets[fieldName] = rawFieldSelectionSet ? parseSelectionSet(rawFieldSelectionSet, {
|
|
729
749
|
noLocation: true
|
|
730
|
-
}) :
|
|
750
|
+
}) : undefined;
|
|
731
751
|
}
|
|
732
752
|
if (mergedTypeConfig2.fields[fieldName]?.provides) {
|
|
733
753
|
let providedSelectionsForSubschema = providedSelectionsByField.get(subschema);
|
|
@@ -888,7 +908,7 @@ function completeStitchingInfo(stitchingInfo, resolvers, schema) {
|
|
|
888
908
|
}
|
|
889
909
|
for (const typeName in resolvers) {
|
|
890
910
|
const type = schema.getType(typeName);
|
|
891
|
-
if (type ===
|
|
911
|
+
if (type === undefined || isLeafType(type) || isInputObjectType(type) || isUnionType(type)) {
|
|
892
912
|
continue;
|
|
893
913
|
}
|
|
894
914
|
const resolver = resolvers[typeName];
|
|
@@ -970,12 +990,12 @@ function updateSelectionSetMap(map, typeName, fieldName, selectionSet, includeTy
|
|
|
970
990
|
}
|
|
971
991
|
function updateArrayMap(map, typeName, fieldName, value, initialValue) {
|
|
972
992
|
if (map[typeName] == null) {
|
|
973
|
-
const initialItems = initialValue ===
|
|
993
|
+
const initialItems = initialValue === undefined ? [value] : [initialValue, value];
|
|
974
994
|
map[typeName] = {
|
|
975
995
|
[fieldName]: initialItems
|
|
976
996
|
};
|
|
977
997
|
} else if (map[typeName][fieldName] == null) {
|
|
978
|
-
const initialItems = initialValue ===
|
|
998
|
+
const initialItems = initialValue === undefined ? [value] : [initialValue, value];
|
|
979
999
|
map[typeName][fieldName] = initialItems;
|
|
980
1000
|
} else {
|
|
981
1001
|
map[typeName][fieldName].push(value);
|
|
@@ -1065,7 +1085,7 @@ function isolateComputedFieldsTransformer(subschemaConfig) {
|
|
|
1065
1085
|
...isolatedSchemaTypes[typeName]?.fields ?? {},
|
|
1066
1086
|
...isolatedFields
|
|
1067
1087
|
},
|
|
1068
|
-
canonical:
|
|
1088
|
+
canonical: undefined
|
|
1069
1089
|
};
|
|
1070
1090
|
for (const fieldName in isolatedFields) {
|
|
1071
1091
|
const returnType = getNamedType(
|
|
@@ -1205,8 +1225,8 @@ function _createCompositeFieldFilter(schema) {
|
|
|
1205
1225
|
}
|
|
1206
1226
|
}
|
|
1207
1227
|
return new TransformCompositeFields(
|
|
1208
|
-
(typeName, fieldName) => filteredFields[typeName]?.[fieldName] ?
|
|
1209
|
-
(typeName, fieldName) => filteredFields[typeName]?.[fieldName] ?
|
|
1228
|
+
(typeName, fieldName) => filteredFields[typeName]?.[fieldName] ? undefined : null,
|
|
1229
|
+
(typeName, fieldName) => filteredFields[typeName]?.[fieldName] ? undefined : null
|
|
1210
1230
|
);
|
|
1211
1231
|
}
|
|
1212
1232
|
function isIsolatedField(typeName, fieldName, isolatedSchemaTypes) {
|
|
@@ -1282,7 +1302,7 @@ function filterBaseSubschema(subschemaConfig, isolatedSchemaTypes) {
|
|
|
1282
1302
|
...subschemaConfig,
|
|
1283
1303
|
merge: subschemaConfig.merge ? {
|
|
1284
1304
|
...subschemaConfig.merge
|
|
1285
|
-
} :
|
|
1305
|
+
} : undefined,
|
|
1286
1306
|
transforms: (subschemaConfig.transforms ?? []).concat([
|
|
1287
1307
|
_createCompositeFieldFilter(filteredSchema),
|
|
1288
1308
|
new FilterTypes((type) => {
|
|
@@ -2413,7 +2433,7 @@ function canonicalFieldNamesForType(candidates) {
|
|
|
2413
2433
|
|
|
2414
2434
|
function mergeDirectives(directives) {
|
|
2415
2435
|
if (directives.size === 0) {
|
|
2416
|
-
return
|
|
2436
|
+
return undefined;
|
|
2417
2437
|
}
|
|
2418
2438
|
if (directives.size === 1) {
|
|
2419
2439
|
const directive = directives.values().next().value;
|
|
@@ -2447,7 +2467,7 @@ function mergeDirectives(directives) {
|
|
|
2447
2467
|
locations: Array.from(locations),
|
|
2448
2468
|
args,
|
|
2449
2469
|
isRepeatable,
|
|
2450
|
-
extensions: extensionsSet.size > 0 ? mergeDeep([...extensionsSet]) :
|
|
2470
|
+
extensions: extensionsSet.size > 0 ? mergeDeep([...extensionsSet]) : undefined
|
|
2451
2471
|
});
|
|
2452
2472
|
}
|
|
2453
2473
|
|
|
@@ -2562,7 +2582,7 @@ function makeValues(nodes) {
|
|
|
2562
2582
|
...prev,
|
|
2563
2583
|
[node.name.value]: {
|
|
2564
2584
|
type: createStub(node.type, "input"),
|
|
2565
|
-
defaultValue: node.defaultValue !==
|
|
2585
|
+
defaultValue: node.defaultValue !== undefined ? valueFromASTUntyped(node.defaultValue) : undefined,
|
|
2566
2586
|
description: getDescription(node, backcompatOptions),
|
|
2567
2587
|
astNode: node
|
|
2568
2588
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-tools/stitch",
|
|
3
|
-
"version": "9.4.
|
|
3
|
+
"version": "9.4.14-alpha-43377dcf7f0183163bf8260e8da347376d2bb23a",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A set of utils for faster development of GraphQL tools",
|
|
6
6
|
"repository": {
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"dataloader": "^2.2.3",
|
|
52
52
|
"graphql": "^16.9.0",
|
|
53
|
-
"pkgroll": "2.6.
|
|
53
|
+
"pkgroll": "2.6.1"
|
|
54
54
|
},
|
|
55
55
|
"sideEffects": false
|
|
56
56
|
}
|