UNPKG

1.28 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.composeAndValidate = void 0;
4const compose_1 = require("./compose");
5const validate_1 = require("./validate");
6const normalize_1 = require("./normalize");
7const utils_1 = require("./utils");
8function composeAndValidate(serviceList) {
9 const errors = (0, validate_1.validateServicesBeforeNormalization)(serviceList);
10 const normalizedServiceList = serviceList.map(({ typeDefs, ...rest }) => ({
11 typeDefs: (0, normalize_1.normalizeTypeDefs)(typeDefs),
12 ...rest
13 }));
14 errors.push(...(0, validate_1.validateServicesBeforeComposition)(normalizedServiceList));
15 const compositionResult = (0, compose_1.composeServices)(normalizedServiceList);
16 if ((0, utils_1.compositionHasErrors)(compositionResult)) {
17 errors.push(...compositionResult.errors);
18 }
19 errors.push(...(0, validate_1.validateComposedSchema)({
20 schema: compositionResult.schema,
21 serviceList,
22 }));
23 if (errors.length > 0) {
24 return {
25 schema: compositionResult.schema,
26 errors,
27 };
28 }
29 else {
30 return compositionResult;
31 }
32}
33exports.composeAndValidate = composeAndValidate;
34//# sourceMappingURL=composeAndValidate.js.map
\No newline at end of file