@wundergraph/composition 0.58.3 → 0.62.2
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/dist/directive-definition-data/directive-definition-data.d.ts +3 -0
- package/dist/directive-definition-data/directive-definition-data.js +82 -1
- package/dist/directive-definition-data/directive-definition-data.js.map +1 -1
- package/dist/errors/errors.d.ts +26 -12
- package/dist/errors/errors.js +96 -29
- package/dist/errors/errors.js.map +1 -1
- package/dist/errors/types/params.d.ts +4 -0
- package/dist/federation/types/results.d.ts +6 -0
- package/dist/federation/types/results.js +3 -0
- package/dist/federation/types/results.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/router-configuration/types.d.ts +26 -0
- package/dist/router-configuration/utils.d.ts +2 -1
- package/dist/router-configuration/utils.js +11 -0
- package/dist/router-configuration/utils.js.map +1 -1
- package/dist/schema-building/utils.js +9 -10
- package/dist/schema-building/utils.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utils/composition-version.js +1 -1
- package/dist/utils/string-constants.d.ts +8 -0
- package/dist/utils/string-constants.js +12 -4
- package/dist/utils/string-constants.js.map +1 -1
- package/dist/v1/constants/constants.js +3 -0
- package/dist/v1/constants/constants.js.map +1 -1
- package/dist/v1/constants/directive-definitions.d.ts +3 -0
- package/dist/v1/constants/directive-definitions.js +60 -1
- package/dist/v1/constants/directive-definitions.js.map +1 -1
- package/dist/v1/constants/type-nodes.d.ts +3 -1
- package/dist/v1/constants/type-nodes.js +6 -1
- package/dist/v1/constants/type-nodes.js.map +1 -1
- package/dist/v1/federation/federation-factory.d.ts +9 -4
- package/dist/v1/federation/federation-factory.js +220 -98
- package/dist/v1/federation/federation-factory.js.map +1 -1
- package/dist/v1/federation/types/params.d.ts +15 -1
- package/dist/v1/normalization/normalization-factory.d.ts +7 -2
- package/dist/v1/normalization/normalization-factory.js +293 -15
- package/dist/v1/normalization/normalization-factory.js.map +1 -1
- package/dist/v1/normalization/types/types.d.ts +73 -1
- package/dist/v1/normalization/utils.js +9 -1
- package/dist/v1/normalization/utils.js.map +1 -1
- package/package.json +2 -2
|
@@ -2039,11 +2039,10 @@ class FederationFactory {
|
|
|
2039
2039
|
}
|
|
2040
2040
|
return paths;
|
|
2041
2041
|
}
|
|
2042
|
-
validateSubscriptionFieldCondition(objectValueNode, condition, objectData, depth, inputPath, directiveSubgraphName
|
|
2042
|
+
validateSubscriptionFieldCondition(objectValueNode, condition, objectData, depth, inputPath, directiveSubgraphName) {
|
|
2043
2043
|
if (depth > integer_constants_1.MAX_SUBSCRIPTION_FILTER_DEPTH || this.isMaxDepth) {
|
|
2044
|
-
errorMessages.push((0, errors_1.subscriptionFilterConditionDepthExceededErrorMessage)(inputPath));
|
|
2045
2044
|
this.isMaxDepth = true;
|
|
2046
|
-
return false;
|
|
2045
|
+
return { success: false, errors: [(0, errors_1.subscriptionFilterConditionDepthExceededError)(inputPath)] };
|
|
2047
2046
|
}
|
|
2048
2047
|
let hasErrors = false;
|
|
2049
2048
|
const validFieldNames = new Set([string_constants_1.FIELD_PATH, string_constants_1.VALUES]);
|
|
@@ -2127,27 +2126,34 @@ class FederationFactory {
|
|
|
2127
2126
|
}
|
|
2128
2127
|
}
|
|
2129
2128
|
if (!hasErrors) {
|
|
2130
|
-
return true;
|
|
2129
|
+
return { success: true };
|
|
2131
2130
|
}
|
|
2132
|
-
|
|
2133
|
-
|
|
2131
|
+
return {
|
|
2132
|
+
success: false,
|
|
2133
|
+
errors: [
|
|
2134
|
+
(0, errors_1.subscriptionFieldConditionInvalidInputFieldError)(inputPath, [...validFieldNames], [...duplicatedFieldNames], [...invalidFieldNames], fieldErrorMessages),
|
|
2135
|
+
],
|
|
2136
|
+
};
|
|
2134
2137
|
}
|
|
2135
|
-
validateSubscriptionFilterCondition(objectValueNode, configuration, objectData, depth, inputPath, directiveSubgraphName
|
|
2138
|
+
validateSubscriptionFilterCondition(objectValueNode, configuration, objectData, depth, inputPath, directiveSubgraphName) {
|
|
2136
2139
|
if (depth > integer_constants_1.MAX_SUBSCRIPTION_FILTER_DEPTH || this.isMaxDepth) {
|
|
2137
|
-
errorMessages.push((0, errors_1.subscriptionFilterConditionDepthExceededErrorMessage)(inputPath));
|
|
2138
2140
|
this.isMaxDepth = true;
|
|
2139
|
-
return false;
|
|
2141
|
+
return { success: false, errors: [(0, errors_1.subscriptionFilterConditionDepthExceededError)(inputPath)] };
|
|
2140
2142
|
}
|
|
2141
2143
|
depth += 1;
|
|
2142
2144
|
if (objectValueNode.fields.length !== 1) {
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
+
return {
|
|
2146
|
+
success: false,
|
|
2147
|
+
errors: [(0, errors_1.subscriptionFilterConditionInvalidInputFieldNumberError)(inputPath, objectValueNode.fields.length)],
|
|
2148
|
+
};
|
|
2145
2149
|
}
|
|
2146
2150
|
const objectFieldNode = objectValueNode.fields[0];
|
|
2147
2151
|
const fieldName = objectFieldNode.name.value;
|
|
2148
2152
|
if (!strings_1.SUBSCRIPTION_FILTER_INPUT_NAMES.has(fieldName)) {
|
|
2149
|
-
|
|
2150
|
-
|
|
2153
|
+
return {
|
|
2154
|
+
success: false,
|
|
2155
|
+
errors: [(0, errors_1.subscriptionFilterConditionInvalidInputFieldError)(inputPath, fieldName)],
|
|
2156
|
+
};
|
|
2151
2157
|
}
|
|
2152
2158
|
const inputFieldPath = inputPath + `.${fieldName}`;
|
|
2153
2159
|
switch (objectFieldNode.value.kind) {
|
|
@@ -2155,16 +2161,18 @@ class FederationFactory {
|
|
|
2155
2161
|
switch (fieldName) {
|
|
2156
2162
|
case string_constants_1.IN_UPPER: {
|
|
2157
2163
|
configuration.in = { fieldPath: [], values: [] };
|
|
2158
|
-
return this.validateSubscriptionFieldCondition(objectFieldNode.value, configuration.in, objectData, depth, inputPath + `.IN`, directiveSubgraphName
|
|
2164
|
+
return this.validateSubscriptionFieldCondition(objectFieldNode.value, configuration.in, objectData, depth, inputPath + `.IN`, directiveSubgraphName);
|
|
2159
2165
|
}
|
|
2160
2166
|
case string_constants_1.NOT_UPPER: {
|
|
2161
2167
|
configuration.not = {};
|
|
2162
|
-
return this.validateSubscriptionFilterCondition(objectFieldNode.value, configuration.not, objectData, depth, inputPath + `.NOT`, directiveSubgraphName
|
|
2168
|
+
return this.validateSubscriptionFilterCondition(objectFieldNode.value, configuration.not, objectData, depth, inputPath + `.NOT`, directiveSubgraphName);
|
|
2163
2169
|
}
|
|
2164
2170
|
default:
|
|
2165
2171
|
// The field is guaranteed to be an AND or an OR
|
|
2166
|
-
|
|
2167
|
-
|
|
2172
|
+
return {
|
|
2173
|
+
success: false,
|
|
2174
|
+
errors: [(0, errors_1.subscriptionFilterConditionInvalidInputFieldTypeError)(inputFieldPath, string_constants_1.LIST, string_constants_1.OBJECT)],
|
|
2175
|
+
};
|
|
2168
2176
|
}
|
|
2169
2177
|
}
|
|
2170
2178
|
case graphql_1.Kind.LIST: {
|
|
@@ -2180,15 +2188,20 @@ class FederationFactory {
|
|
|
2180
2188
|
}
|
|
2181
2189
|
default:
|
|
2182
2190
|
// The field is guaranteed to be an IN or a NOT
|
|
2183
|
-
|
|
2184
|
-
|
|
2191
|
+
return {
|
|
2192
|
+
success: false,
|
|
2193
|
+
errors: [(0, errors_1.subscriptionFilterConditionInvalidInputFieldTypeError)(inputFieldPath, string_constants_1.OBJECT, string_constants_1.LIST)],
|
|
2194
|
+
};
|
|
2185
2195
|
}
|
|
2186
2196
|
const listLength = objectFieldNode.value.values.length;
|
|
2187
2197
|
if (listLength < 1 || listLength > 5) {
|
|
2188
|
-
|
|
2189
|
-
|
|
2198
|
+
return {
|
|
2199
|
+
success: false,
|
|
2200
|
+
errors: [(0, errors_1.subscriptionFilterArrayConditionInvalidLengthError)(inputFieldPath, listLength)],
|
|
2201
|
+
};
|
|
2190
2202
|
}
|
|
2191
2203
|
let isValid = true;
|
|
2204
|
+
const aggregatedErrors = [];
|
|
2192
2205
|
const invalidIndices = [];
|
|
2193
2206
|
for (let i = 0; i < objectFieldNode.value.values.length; i++) {
|
|
2194
2207
|
const arrayIndexPath = inputFieldPath + `[${i}]`;
|
|
@@ -2197,49 +2210,89 @@ class FederationFactory {
|
|
|
2197
2210
|
invalidIndices.push(i);
|
|
2198
2211
|
continue;
|
|
2199
2212
|
}
|
|
2213
|
+
/* Preserve original short-circuit behaviour (`isValid &&= ...`): once any earlier
|
|
2214
|
+
* item failed, do not recurse into subsequent items so error output stays focused
|
|
2215
|
+
* on the first failing branch.
|
|
2216
|
+
*/
|
|
2217
|
+
if (!isValid) {
|
|
2218
|
+
continue;
|
|
2219
|
+
}
|
|
2200
2220
|
const listConfiguration = {};
|
|
2201
|
-
|
|
2202
|
-
if (
|
|
2203
|
-
|
|
2221
|
+
const itemResult = this.validateSubscriptionFilterCondition(listValueNode, listConfiguration, objectData, depth, arrayIndexPath, directiveSubgraphName);
|
|
2222
|
+
if (!itemResult.success) {
|
|
2223
|
+
isValid = false;
|
|
2224
|
+
aggregatedErrors.push(...itemResult.errors);
|
|
2225
|
+
continue;
|
|
2204
2226
|
}
|
|
2227
|
+
listConfigurations.push(listConfiguration);
|
|
2205
2228
|
}
|
|
2206
2229
|
if (invalidIndices.length > 0) {
|
|
2207
|
-
|
|
2208
|
-
return false;
|
|
2230
|
+
aggregatedErrors.push((0, errors_1.subscriptionFilterArrayConditionInvalidItemTypeErrorMessage)(inputFieldPath, invalidIndices));
|
|
2231
|
+
return { success: false, errors: aggregatedErrors };
|
|
2209
2232
|
}
|
|
2210
|
-
return isValid;
|
|
2233
|
+
return isValid ? { success: true } : { success: false, errors: aggregatedErrors };
|
|
2211
2234
|
}
|
|
2212
2235
|
default: {
|
|
2213
2236
|
const expectedTypeString = strings_1.SUBSCRIPTION_FILTER_LIST_INPUT_NAMES.has(fieldName) ? string_constants_1.LIST : string_constants_1.OBJECT;
|
|
2214
|
-
|
|
2215
|
-
|
|
2237
|
+
return {
|
|
2238
|
+
success: false,
|
|
2239
|
+
errors: [
|
|
2240
|
+
(0, errors_1.subscriptionFilterConditionInvalidInputFieldTypeError)(inputFieldPath, expectedTypeString, (0, utils_6.kindToNodeType)(objectFieldNode.value.kind)),
|
|
2241
|
+
],
|
|
2242
|
+
};
|
|
2216
2243
|
}
|
|
2217
2244
|
}
|
|
2218
2245
|
}
|
|
2219
|
-
|
|
2220
|
-
// directive validation occurs elsewhere
|
|
2246
|
+
validateSubscriptionFilterForTarget(directiveNode, target, directiveSubgraphName) {
|
|
2247
|
+
// directive validation occurs elsewhere; an empty errors array signals "skip silently".
|
|
2221
2248
|
if (!directiveNode.arguments || directiveNode.arguments.length !== 1) {
|
|
2222
|
-
return;
|
|
2249
|
+
return { success: false, errors: [] };
|
|
2223
2250
|
}
|
|
2224
2251
|
const argumentNode = directiveNode.arguments[0];
|
|
2225
2252
|
if (argumentNode.value.kind !== graphql_1.Kind.OBJECT) {
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2253
|
+
return {
|
|
2254
|
+
success: false,
|
|
2255
|
+
errors: [
|
|
2256
|
+
(0, errors_1.subscriptionFilterConditionInvalidInputFieldTypeError)(string_constants_1.CONDITION, string_constants_1.OBJECT, (0, utils_6.kindToNodeType)(argumentNode.value.kind)),
|
|
2257
|
+
],
|
|
2258
|
+
};
|
|
2230
2259
|
}
|
|
2231
2260
|
const condition = {};
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2261
|
+
// Reset depth state so each target validation starts fresh.
|
|
2262
|
+
this.isMaxDepth = false;
|
|
2263
|
+
const result = this.validateSubscriptionFilterCondition(argumentNode.value, condition, target, 0, string_constants_1.CONDITION, directiveSubgraphName);
|
|
2264
|
+
if (!result.success) {
|
|
2265
|
+
return result;
|
|
2266
|
+
}
|
|
2267
|
+
return { success: true, condition };
|
|
2268
|
+
}
|
|
2269
|
+
validateSubscriptionFilterAndGenerateConfiguration({ directiveNode, objectData, fieldPath, fieldName, parentTypeName, directiveSubgraphName, }) {
|
|
2270
|
+
const result = this.validateSubscriptionFilterForTarget(directiveNode, objectData, directiveSubgraphName);
|
|
2271
|
+
if (!result.success) {
|
|
2272
|
+
if (result.errors.length > 0) {
|
|
2273
|
+
this.errors.push((0, errors_1.invalidSubscriptionFilterDirectiveError)(fieldPath, result.errors));
|
|
2274
|
+
}
|
|
2236
2275
|
return;
|
|
2237
2276
|
}
|
|
2238
2277
|
(0, utils_6.getValueOrDefault)(this.fieldConfigurationByFieldCoords, fieldPath, () => ({
|
|
2239
2278
|
argumentNames: [],
|
|
2240
2279
|
fieldName,
|
|
2241
2280
|
typeName: parentTypeName,
|
|
2242
|
-
})).subscriptionFilterCondition = condition;
|
|
2281
|
+
})).subscriptionFilterCondition = result.condition;
|
|
2282
|
+
}
|
|
2283
|
+
collectSubscriptionFilterConcreteTargets(abstractTypeName) {
|
|
2284
|
+
const concreteNames = this.concreteTypeNamesByAbstractTypeName.get(abstractTypeName);
|
|
2285
|
+
if (!concreteNames) {
|
|
2286
|
+
return [];
|
|
2287
|
+
}
|
|
2288
|
+
const out = [];
|
|
2289
|
+
for (const concreteName of concreteNames) {
|
|
2290
|
+
const data = this.parentDefinitionDataByTypeName.get(concreteName);
|
|
2291
|
+
if (data && data.kind === graphql_1.Kind.OBJECT_TYPE_DEFINITION && !(0, utils_5.isNodeDataInaccessible)(data)) {
|
|
2292
|
+
out.push(data);
|
|
2293
|
+
}
|
|
2294
|
+
}
|
|
2295
|
+
return out;
|
|
2243
2296
|
}
|
|
2244
2297
|
validateSubscriptionFiltersAndGenerateConfiguration() {
|
|
2245
2298
|
for (const [fieldPath, data] of this.subscriptionFilterDataByFieldPath) {
|
|
@@ -2252,7 +2305,7 @@ class FederationFactory {
|
|
|
2252
2305
|
*/
|
|
2253
2306
|
if (!namedTypeData) {
|
|
2254
2307
|
this.errors.push((0, errors_1.invalidSubscriptionFilterDirectiveError)(fieldPath, [
|
|
2255
|
-
(0, errors_1.
|
|
2308
|
+
(0, errors_1.subscriptionFilterNamedTypeError)(data.fieldData.namedTypeName),
|
|
2256
2309
|
]));
|
|
2257
2310
|
continue;
|
|
2258
2311
|
}
|
|
@@ -2260,12 +2313,73 @@ class FederationFactory {
|
|
|
2260
2313
|
// @inaccessible error are caught elsewhere
|
|
2261
2314
|
continue;
|
|
2262
2315
|
}
|
|
2263
|
-
|
|
2264
|
-
|
|
2316
|
+
if (namedTypeData.kind === graphql_1.Kind.OBJECT_TYPE_DEFINITION) {
|
|
2317
|
+
this.validateSubscriptionFilterAndGenerateConfiguration({
|
|
2318
|
+
directiveNode: data.directive,
|
|
2319
|
+
objectData: namedTypeData,
|
|
2320
|
+
fieldPath,
|
|
2321
|
+
fieldName: data.fieldData.name,
|
|
2322
|
+
parentTypeName: data.fieldData.renamedParentTypeName,
|
|
2323
|
+
directiveSubgraphName: data.directiveSubgraphName,
|
|
2324
|
+
});
|
|
2325
|
+
continue;
|
|
2326
|
+
}
|
|
2327
|
+
if (!(0, utils_1.isKindAbstract)(namedTypeData.kind)) {
|
|
2328
|
+
/* Other kinds (Enum/Input/Scalar) should be caught at normalization time.
|
|
2329
|
+
* Emit an explicit composition error so the directive cannot be silently dropped here again.
|
|
2330
|
+
*/
|
|
2331
|
+
this.errors.push((0, errors_1.invalidSubscriptionFilterDirectiveError)(fieldPath, [
|
|
2332
|
+
(0, errors_1.subscriptionFilterUnsupportedNamedTypeKindError)(namedTypeData.name, namedTypeData.kind),
|
|
2333
|
+
]));
|
|
2334
|
+
continue;
|
|
2335
|
+
}
|
|
2336
|
+
const targets = this.collectSubscriptionFilterConcreteTargets(namedTypeData.name);
|
|
2337
|
+
if (targets.length === 0) {
|
|
2338
|
+
const kindLabel = (0, utils_6.kindToNodeType)(namedTypeData.kind);
|
|
2339
|
+
this.errors.push((0, errors_1.invalidSubscriptionFilterDirectiveError)(fieldPath, [
|
|
2340
|
+
(0, errors_1.subscriptionFilterNoAccessibleConcreteTypesError)(namedTypeData.name, kindLabel),
|
|
2341
|
+
]));
|
|
2342
|
+
continue;
|
|
2343
|
+
}
|
|
2344
|
+
const result = this.mergeSubscriptionFilterTargetResults({
|
|
2345
|
+
directiveNode: data.directive,
|
|
2346
|
+
abstractTypeData: namedTypeData,
|
|
2347
|
+
targets,
|
|
2348
|
+
directiveSubgraphName: data.directiveSubgraphName,
|
|
2349
|
+
});
|
|
2350
|
+
if (!result.success) {
|
|
2351
|
+
this.errors.push((0, errors_1.invalidSubscriptionFilterDirectiveError)(fieldPath, result.errors));
|
|
2352
|
+
continue;
|
|
2353
|
+
}
|
|
2354
|
+
(0, utils_6.getValueOrDefault)(this.fieldConfigurationByFieldCoords, fieldPath, () => ({
|
|
2355
|
+
argumentNames: [],
|
|
2356
|
+
fieldName: data.fieldData.name,
|
|
2357
|
+
typeName: data.fieldData.renamedParentTypeName,
|
|
2358
|
+
})).subscriptionFilterCondition = result.condition;
|
|
2359
|
+
}
|
|
2360
|
+
}
|
|
2361
|
+
mergeSubscriptionFilterTargetResults({ abstractTypeData, directiveNode, directiveSubgraphName, targets, }) {
|
|
2362
|
+
const aggregatedErrors = [];
|
|
2363
|
+
let firstCondition = null;
|
|
2364
|
+
for (const target of targets) {
|
|
2365
|
+
const result = this.validateSubscriptionFilterForTarget(directiveNode, target, directiveSubgraphName);
|
|
2366
|
+
if (result.success) {
|
|
2367
|
+
firstCondition ??= result.condition;
|
|
2368
|
+
continue;
|
|
2369
|
+
}
|
|
2370
|
+
if (result.errors.length === 0) {
|
|
2371
|
+
// The directive is malformed — that error is reported elsewhere; skip silently.
|
|
2265
2372
|
continue;
|
|
2266
2373
|
}
|
|
2267
|
-
|
|
2374
|
+
const wrapped = abstractTypeData.kind === graphql_1.Kind.UNION_TYPE_DEFINITION
|
|
2375
|
+
? (0, errors_1.subscriptionFilterUnionMemberInvalidError)(abstractTypeData.name, target.name, result.errors.map((error) => error.message).join(string_constants_1.LITERAL_NEW_LINE))
|
|
2376
|
+
: (0, errors_1.subscriptionFilterInterfaceImplementationInvalidError)(abstractTypeData.name, target.name, result.errors.map((error) => error.message).join(string_constants_1.LITERAL_NEW_LINE));
|
|
2377
|
+
aggregatedErrors.push(wrapped);
|
|
2268
2378
|
}
|
|
2379
|
+
if (firstCondition === null || aggregatedErrors.length > 0) {
|
|
2380
|
+
return { errors: aggregatedErrors, success: false };
|
|
2381
|
+
}
|
|
2382
|
+
return { condition: firstCondition, success: true };
|
|
2269
2383
|
}
|
|
2270
2384
|
buildFederationResult() {
|
|
2271
2385
|
if (this.subscriptionFilterDataByFieldPath.size > 0) {
|
|
@@ -2416,13 +2530,21 @@ class FederationFactory {
|
|
|
2416
2530
|
** However, contracts require @inaccessible to exclude applicable tagged types. */
|
|
2417
2531
|
this.routerDefinitions.push(directive_definitions_1.INACCESSIBLE_DEFINITION);
|
|
2418
2532
|
}
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
|
|
2533
|
+
const tagIntersection = contractTagOptions.tagNamesToExclude.intersection(contractTagOptions.tagNamesToInclude);
|
|
2534
|
+
if (tagIntersection.size > 0) {
|
|
2535
|
+
return {
|
|
2536
|
+
errors: [(0, errors_1.intersectingExcludeAndIncludeContractTagsError)([...tagIntersection])],
|
|
2537
|
+
success: false,
|
|
2538
|
+
warnings: this.warnings,
|
|
2539
|
+
};
|
|
2540
|
+
}
|
|
2541
|
+
if (contractTagOptions.tagNamesToInclude.size > 0) {
|
|
2542
|
+
for (const [parentTypeName, parentDefinitionData] of this.parentDefinitionDataByTypeName) {
|
|
2422
2543
|
if ((0, utils_5.isNodeDataInaccessible)(parentDefinitionData)) {
|
|
2423
2544
|
continue;
|
|
2424
2545
|
}
|
|
2425
|
-
|
|
2546
|
+
const parentTagData = this.parentTagDataByTypeName.get(parentTypeName);
|
|
2547
|
+
if (!parentTagData) {
|
|
2426
2548
|
parentDefinitionData.federatedDirectivesData.directivesByName.set(string_constants_1.INACCESSIBLE, [
|
|
2427
2549
|
(0, utils_6.generateSimpleDirective)(string_constants_1.INACCESSIBLE),
|
|
2428
2550
|
]);
|
|
@@ -2430,50 +2552,42 @@ class FederationFactory {
|
|
|
2430
2552
|
// If the parent is inaccessible, there is no need to assess further
|
|
2431
2553
|
continue;
|
|
2432
2554
|
}
|
|
2555
|
+
if (!contractTagOptions.tagNamesToInclude.isDisjointFrom(parentTagData.tagNames)) {
|
|
2556
|
+
continue;
|
|
2557
|
+
}
|
|
2433
2558
|
if (parentTagData.childTagDataByChildName.size < 1) {
|
|
2559
|
+
parentDefinitionData.federatedDirectivesData.directivesByName.set(string_constants_1.INACCESSIBLE, [
|
|
2560
|
+
(0, utils_6.generateSimpleDirective)(string_constants_1.INACCESSIBLE),
|
|
2561
|
+
]);
|
|
2562
|
+
this.inaccessibleCoords.add(parentTypeName);
|
|
2563
|
+
// If the parent is inaccessible, there is no need to assess further
|
|
2434
2564
|
continue;
|
|
2435
2565
|
}
|
|
2436
2566
|
switch (parentDefinitionData.kind) {
|
|
2437
2567
|
case graphql_1.Kind.SCALAR_TYPE_DEFINITION:
|
|
2438
2568
|
// intentional fallthrough
|
|
2439
|
-
case graphql_1.Kind.UNION_TYPE_DEFINITION:
|
|
2440
|
-
|
|
2441
|
-
|
|
2442
|
-
|
|
2443
|
-
this.handleChildTagExclusions(parentDefinitionData, parentDefinitionData.enumValueDataByName, parentTagData.childTagDataByChildName, contractTagOptions.tagNamesToExclude);
|
|
2569
|
+
case graphql_1.Kind.UNION_TYPE_DEFINITION:
|
|
2570
|
+
continue;
|
|
2571
|
+
case graphql_1.Kind.ENUM_TYPE_DEFINITION:
|
|
2572
|
+
this.handleChildTagInclusions(parentDefinitionData, parentDefinitionData.enumValueDataByName, parentTagData.childTagDataByChildName, contractTagOptions.tagNamesToInclude);
|
|
2444
2573
|
break;
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
this.handleChildTagExclusions(parentDefinitionData, parentDefinitionData.inputValueDataByName, parentTagData.childTagDataByChildName, contractTagOptions.tagNamesToExclude);
|
|
2574
|
+
case graphql_1.Kind.INPUT_OBJECT_TYPE_DEFINITION:
|
|
2575
|
+
this.handleChildTagInclusions(parentDefinitionData, parentDefinitionData.inputValueDataByName, parentTagData.childTagDataByChildName, contractTagOptions.tagNamesToInclude);
|
|
2448
2576
|
break;
|
|
2449
|
-
|
|
2450
|
-
default: {
|
|
2577
|
+
default:
|
|
2451
2578
|
let accessibleFields = parentDefinitionData.fieldDataByName.size;
|
|
2452
|
-
for (const [fieldName,
|
|
2453
|
-
const fieldData = (0, utils_6.getOrThrowError)(parentDefinitionData.fieldDataByName, fieldName, `${parentTypeName}.fieldDataByFieldName`);
|
|
2579
|
+
for (const [fieldName, fieldData] of parentDefinitionData.fieldDataByName) {
|
|
2454
2580
|
if ((0, utils_5.isNodeDataInaccessible)(fieldData)) {
|
|
2455
2581
|
accessibleFields -= 1;
|
|
2456
2582
|
continue;
|
|
2457
2583
|
}
|
|
2458
|
-
|
|
2584
|
+
const childTagData = parentTagData.childTagDataByChildName.get(fieldName);
|
|
2585
|
+
if (!childTagData || contractTagOptions.tagNamesToInclude.isDisjointFrom(childTagData.tagNames)) {
|
|
2459
2586
|
(0, utils_6.getValueOrDefault)(fieldData.federatedDirectivesData.directivesByName, string_constants_1.INACCESSIBLE, () => [
|
|
2460
2587
|
(0, utils_6.generateSimpleDirective)(string_constants_1.INACCESSIBLE),
|
|
2461
2588
|
]);
|
|
2462
2589
|
this.inaccessibleCoords.add(fieldData.federatedCoords);
|
|
2463
2590
|
accessibleFields -= 1;
|
|
2464
|
-
continue;
|
|
2465
|
-
}
|
|
2466
|
-
for (const [argumentName, argTagNames] of childTagData.tagNamesByArgumentName) {
|
|
2467
|
-
const inputValueData = (0, utils_6.getOrThrowError)(fieldData.argumentDataByName, argumentName, `${fieldName}.argumentDataByArgumentName`);
|
|
2468
|
-
if ((0, utils_5.isNodeDataInaccessible)(inputValueData)) {
|
|
2469
|
-
continue;
|
|
2470
|
-
}
|
|
2471
|
-
if (!contractTagOptions.tagNamesToExclude.isDisjointFrom(argTagNames)) {
|
|
2472
|
-
(0, utils_6.getValueOrDefault)(inputValueData.federatedDirectivesData.directivesByName, string_constants_1.INACCESSIBLE, () => [
|
|
2473
|
-
(0, utils_6.generateSimpleDirective)(string_constants_1.INACCESSIBLE),
|
|
2474
|
-
]);
|
|
2475
|
-
this.inaccessibleCoords.add(inputValueData.federatedCoords);
|
|
2476
|
-
}
|
|
2477
2591
|
}
|
|
2478
2592
|
}
|
|
2479
2593
|
if (accessibleFields < 1) {
|
|
@@ -2482,17 +2596,16 @@ class FederationFactory {
|
|
|
2482
2596
|
]);
|
|
2483
2597
|
this.inaccessibleCoords.add(parentTypeName);
|
|
2484
2598
|
}
|
|
2485
|
-
}
|
|
2486
2599
|
}
|
|
2487
2600
|
}
|
|
2488
2601
|
}
|
|
2489
|
-
|
|
2490
|
-
for (const [parentTypeName,
|
|
2602
|
+
if (contractTagOptions.tagNamesToExclude.size > 0) {
|
|
2603
|
+
for (const [parentTypeName, parentTagData] of this.parentTagDataByTypeName) {
|
|
2604
|
+
const parentDefinitionData = (0, utils_6.getOrThrowError)(this.parentDefinitionDataByTypeName, parentTypeName, string_constants_1.PARENT_DEFINITION_DATA);
|
|
2491
2605
|
if ((0, utils_5.isNodeDataInaccessible)(parentDefinitionData)) {
|
|
2492
2606
|
continue;
|
|
2493
2607
|
}
|
|
2494
|
-
|
|
2495
|
-
if (!parentTagData) {
|
|
2608
|
+
if (!contractTagOptions.tagNamesToExclude.isDisjointFrom(parentTagData.tagNames)) {
|
|
2496
2609
|
parentDefinitionData.federatedDirectivesData.directivesByName.set(string_constants_1.INACCESSIBLE, [
|
|
2497
2610
|
(0, utils_6.generateSimpleDirective)(string_constants_1.INACCESSIBLE),
|
|
2498
2611
|
]);
|
|
@@ -2500,42 +2613,50 @@ class FederationFactory {
|
|
|
2500
2613
|
// If the parent is inaccessible, there is no need to assess further
|
|
2501
2614
|
continue;
|
|
2502
2615
|
}
|
|
2503
|
-
if (!contractTagOptions.tagNamesToInclude.isDisjointFrom(parentTagData.tagNames)) {
|
|
2504
|
-
continue;
|
|
2505
|
-
}
|
|
2506
2616
|
if (parentTagData.childTagDataByChildName.size < 1) {
|
|
2507
|
-
parentDefinitionData.federatedDirectivesData.directivesByName.set(string_constants_1.INACCESSIBLE, [
|
|
2508
|
-
(0, utils_6.generateSimpleDirective)(string_constants_1.INACCESSIBLE),
|
|
2509
|
-
]);
|
|
2510
|
-
this.inaccessibleCoords.add(parentTypeName);
|
|
2511
|
-
// If the parent is inaccessible, there is no need to assess further
|
|
2512
2617
|
continue;
|
|
2513
2618
|
}
|
|
2514
2619
|
switch (parentDefinitionData.kind) {
|
|
2515
2620
|
case graphql_1.Kind.SCALAR_TYPE_DEFINITION:
|
|
2516
2621
|
// intentional fallthrough
|
|
2517
|
-
case graphql_1.Kind.UNION_TYPE_DEFINITION:
|
|
2518
|
-
continue;
|
|
2519
|
-
case graphql_1.Kind.ENUM_TYPE_DEFINITION:
|
|
2520
|
-
this.handleChildTagInclusions(parentDefinitionData, parentDefinitionData.enumValueDataByName, parentTagData.childTagDataByChildName, contractTagOptions.tagNamesToInclude);
|
|
2622
|
+
case graphql_1.Kind.UNION_TYPE_DEFINITION: {
|
|
2521
2623
|
break;
|
|
2522
|
-
|
|
2523
|
-
|
|
2624
|
+
}
|
|
2625
|
+
case graphql_1.Kind.ENUM_TYPE_DEFINITION: {
|
|
2626
|
+
this.handleChildTagExclusions(parentDefinitionData, parentDefinitionData.enumValueDataByName, parentTagData.childTagDataByChildName, contractTagOptions.tagNamesToExclude);
|
|
2524
2627
|
break;
|
|
2525
|
-
|
|
2628
|
+
}
|
|
2629
|
+
case graphql_1.Kind.INPUT_OBJECT_TYPE_DEFINITION: {
|
|
2630
|
+
this.handleChildTagExclusions(parentDefinitionData, parentDefinitionData.inputValueDataByName, parentTagData.childTagDataByChildName, contractTagOptions.tagNamesToExclude);
|
|
2631
|
+
break;
|
|
2632
|
+
}
|
|
2633
|
+
default: {
|
|
2526
2634
|
let accessibleFields = parentDefinitionData.fieldDataByName.size;
|
|
2527
|
-
for (const [fieldName,
|
|
2635
|
+
for (const [fieldName, childTagData] of parentTagData.childTagDataByChildName) {
|
|
2636
|
+
const fieldData = (0, utils_6.getOrThrowError)(parentDefinitionData.fieldDataByName, fieldName, `${parentTypeName}.fieldDataByFieldName`);
|
|
2528
2637
|
if ((0, utils_5.isNodeDataInaccessible)(fieldData)) {
|
|
2529
2638
|
accessibleFields -= 1;
|
|
2530
2639
|
continue;
|
|
2531
2640
|
}
|
|
2532
|
-
|
|
2533
|
-
if (!childTagData || contractTagOptions.tagNamesToInclude.isDisjointFrom(childTagData.tagNames)) {
|
|
2641
|
+
if (!contractTagOptions.tagNamesToExclude.isDisjointFrom(childTagData.tagNames)) {
|
|
2534
2642
|
(0, utils_6.getValueOrDefault)(fieldData.federatedDirectivesData.directivesByName, string_constants_1.INACCESSIBLE, () => [
|
|
2535
2643
|
(0, utils_6.generateSimpleDirective)(string_constants_1.INACCESSIBLE),
|
|
2536
2644
|
]);
|
|
2537
2645
|
this.inaccessibleCoords.add(fieldData.federatedCoords);
|
|
2538
2646
|
accessibleFields -= 1;
|
|
2647
|
+
continue;
|
|
2648
|
+
}
|
|
2649
|
+
for (const [argumentName, argTagNames] of childTagData.tagNamesByArgumentName) {
|
|
2650
|
+
const inputValueData = (0, utils_6.getOrThrowError)(fieldData.argumentDataByName, argumentName, `${fieldName}.argumentDataByArgumentName`);
|
|
2651
|
+
if ((0, utils_5.isNodeDataInaccessible)(inputValueData)) {
|
|
2652
|
+
continue;
|
|
2653
|
+
}
|
|
2654
|
+
if (!contractTagOptions.tagNamesToExclude.isDisjointFrom(argTagNames)) {
|
|
2655
|
+
(0, utils_6.getValueOrDefault)(inputValueData.federatedDirectivesData.directivesByName, string_constants_1.INACCESSIBLE, () => [
|
|
2656
|
+
(0, utils_6.generateSimpleDirective)(string_constants_1.INACCESSIBLE),
|
|
2657
|
+
]);
|
|
2658
|
+
this.inaccessibleCoords.add(inputValueData.federatedCoords);
|
|
2659
|
+
}
|
|
2539
2660
|
}
|
|
2540
2661
|
}
|
|
2541
2662
|
if (accessibleFields < 1) {
|
|
@@ -2544,6 +2665,7 @@ class FederationFactory {
|
|
|
2544
2665
|
]);
|
|
2545
2666
|
this.inaccessibleCoords.add(parentTypeName);
|
|
2546
2667
|
}
|
|
2668
|
+
}
|
|
2547
2669
|
}
|
|
2548
2670
|
}
|
|
2549
2671
|
}
|