@wundergraph/composition 0.58.3 → 0.59.0
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/errors/errors.d.ts +18 -11
- package/dist/errors/errors.js +64 -29
- package/dist/errors/errors.js.map +1 -1
- 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/tsconfig.tsbuildinfo +1 -1
- package/dist/utils/composition-version.js +1 -1
- package/dist/v1/federation/federation-factory.d.ts +9 -4
- package/dist/v1/federation/federation-factory.js +160 -45
- 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.js +94 -11
- package/dist/v1/normalization/normalization-factory.js.map +1 -1
- package/package.json +2 -2
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type ConstDirectiveNode, type ConstObjectValueNode, type DefinitionNode, type DirectiveDefinitionNode, type NamedTypeNode, type StringValueNode } from 'graphql';
|
|
2
2
|
import { type MutableDefinitionNode, type MutableInputValueNode, type MutableTypeNode } from '../../schema-building/ast';
|
|
3
|
+
import { type ExecutionMultiResult } from '../../types/results';
|
|
3
4
|
import { type ChildTagData, type InterfaceImplementationData, type InterfaceObjectForInternalGraphOptions, type ParentTagData, type SubscriptionFilterData } from './utils';
|
|
4
5
|
import { type FieldConfiguration, type SubscriptionCondition, type SubscriptionFieldCondition } from '../../router-configuration/types';
|
|
5
6
|
import { type AuthorizationData, type ChildData, type CompositeOutputData, type EntityData, type EntityInterfaceFederationData, type EnumValueData, type FederatedDirectivesData, type FieldData, type InputObjectDefinitionData, type InputValueData, type InterfaceDefinitionData, type NodeData, type ObjectDefinitionData, type ParentDefinitionData, type UnionDefinitionData } from '../../schema-building/types/types';
|
|
@@ -10,9 +11,10 @@ import { type GraphNode } from '../../resolvability-graph/graph-nodes';
|
|
|
10
11
|
import { type InternalSubgraph } from '../../subgraph/types';
|
|
11
12
|
import { type Warning } from '../../warnings/types';
|
|
12
13
|
import { type ContractTagOptions, type FederationResult, type FederationResultWithContracts, type MutualParentDefinitionData } from '../../federation/types/types';
|
|
14
|
+
import { type SubscriptionFilterTargetResult } from '../../federation/types/results';
|
|
13
15
|
import type { GraphFieldData } from '../../utils/types';
|
|
14
16
|
import { type DirectiveName, type FieldCoords, type InterfaceTypeName, type SubgraphName, type TypeName } from '../../types/types';
|
|
15
|
-
import { type ExtractFederatedDirectivesParams, type FederateSubgraphsContractV1Params, type FederateSubgraphsWithContractsV1Params, type FederationFactoryParams, type FederationParams, type UpsertDirectiveArgumentDataParams, type ValidateOneOfDirectiveParams } from './types/params';
|
|
17
|
+
import { type ExtractFederatedDirectivesParams, type FederateSubgraphsContractV1Params, type FederateSubgraphsWithContractsV1Params, type FederationFactoryParams, type FederationParams, type MergeSubscriptionFilterTargetResultParams, type UpsertDirectiveArgumentDataParams, type ValidateSubscriptionFilterAndGenerateConfigurationParams, type ValidateOneOfDirectiveParams } from './types/params';
|
|
16
18
|
import type { CompositionOptions } from '../../types/params';
|
|
17
19
|
import { type DirectiveArgumentData, type DirectiveDefinitionData } from '../../directive-definition-data/types/types';
|
|
18
20
|
export declare class FederationFactory {
|
|
@@ -101,10 +103,13 @@ export declare class FederationFactory {
|
|
|
101
103
|
validateReferencesOfInaccessibleType(data: ParentDefinitionData): void;
|
|
102
104
|
validateQueryRootType(): void;
|
|
103
105
|
validateSubscriptionFieldConditionFieldPath(conditionFieldPath: string, objectData: ObjectDefinitionData, inputFieldPath: string, directiveSubgraphName: string, fieldErrorMessages: Array<string>): string[];
|
|
104
|
-
validateSubscriptionFieldCondition(objectValueNode: ConstObjectValueNode, condition: SubscriptionFieldCondition, objectData: ObjectDefinitionData, depth: number, inputPath: string, directiveSubgraphName: string
|
|
105
|
-
validateSubscriptionFilterCondition(objectValueNode: ConstObjectValueNode, configuration: SubscriptionCondition, objectData: ObjectDefinitionData, depth: number, inputPath: string, directiveSubgraphName: string
|
|
106
|
-
|
|
106
|
+
validateSubscriptionFieldCondition(objectValueNode: ConstObjectValueNode, condition: SubscriptionFieldCondition, objectData: ObjectDefinitionData, depth: number, inputPath: string, directiveSubgraphName: string): ExecutionMultiResult;
|
|
107
|
+
validateSubscriptionFilterCondition(objectValueNode: ConstObjectValueNode, configuration: SubscriptionCondition, objectData: ObjectDefinitionData, depth: number, inputPath: string, directiveSubgraphName: string): ExecutionMultiResult;
|
|
108
|
+
validateSubscriptionFilterForTarget(directiveNode: ConstDirectiveNode, target: ObjectDefinitionData, directiveSubgraphName: string): SubscriptionFilterTargetResult;
|
|
109
|
+
validateSubscriptionFilterAndGenerateConfiguration({ directiveNode, objectData, fieldPath, fieldName, parentTypeName, directiveSubgraphName, }: ValidateSubscriptionFilterAndGenerateConfigurationParams): void;
|
|
110
|
+
collectSubscriptionFilterConcreteTargets(abstractTypeName: string): Array<ObjectDefinitionData>;
|
|
107
111
|
validateSubscriptionFiltersAndGenerateConfiguration(): void;
|
|
112
|
+
mergeSubscriptionFilterTargetResults({ directiveNode, abstractTypeData, targets, directiveSubgraphName, }: MergeSubscriptionFilterTargetResultParams): SubscriptionFilterTargetResult;
|
|
108
113
|
buildFederationResult(): FederationResult;
|
|
109
114
|
getClientSchemaObjectBoolean(): {
|
|
110
115
|
shouldIncludeClientSchema?: undefined;
|
|
@@ -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,74 @@ 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
|
+
});
|
|
2265
2325
|
continue;
|
|
2266
2326
|
}
|
|
2267
|
-
|
|
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({ directiveNode, abstractTypeData, targets, directiveSubgraphName, }) {
|
|
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.
|
|
2372
|
+
continue;
|
|
2373
|
+
}
|
|
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);
|
|
2378
|
+
continue;
|
|
2379
|
+
}
|
|
2380
|
+
if (firstCondition === null || aggregatedErrors.length > 0) {
|
|
2381
|
+
return { errors: aggregatedErrors, success: false };
|
|
2268
2382
|
}
|
|
2383
|
+
return { condition: firstCondition, success: true };
|
|
2269
2384
|
}
|
|
2270
2385
|
buildFederationResult() {
|
|
2271
2386
|
if (this.subscriptionFilterDataByFieldPath.size > 0) {
|