1 | "use strict";
|
2 | var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3 | if (k2 === undefined) k2 = k;
|
4 | var desc = Object.getOwnPropertyDescriptor(m, k);
|
5 | if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
6 | desc = { enumerable: true, get: function() { return m[k]; } };
|
7 | }
|
8 | Object.defineProperty(o, k2, desc);
|
9 | }) : (function(o, m, k, k2) {
|
10 | if (k2 === undefined) k2 = k;
|
11 | o[k2] = m[k];
|
12 | }));
|
13 | var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
14 | Object.defineProperty(o, "default", { enumerable: true, value: v });
|
15 | }) : function(o, v) {
|
16 | o["default"] = v;
|
17 | });
|
18 | var __importStar = (this && this.__importStar) || function (mod) {
|
19 | if (mod && mod.__esModule) return mod;
|
20 | var result = {};
|
21 | if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
22 | __setModuleDefault(result, mod);
|
23 | return result;
|
24 | };
|
25 | Object.defineProperty(exports, "__esModule", { value: true });
|
26 | exports.validateComposedSchema = exports.validateServicesBeforeComposition = exports.validateServicesBeforeNormalization = void 0;
|
27 | const graphql_1 = require("graphql");
|
28 | const preNormalizationRules = __importStar(require("./preNormalization"));
|
29 | const preCompositionRules = __importStar(require("./preComposition"));
|
30 | const postCompositionRules = __importStar(require("./postComposition"));
|
31 | const preNormalizationValidators = Object.values(preNormalizationRules);
|
32 | function validateServicesBeforeNormalization(services) {
|
33 | const errors = [];
|
34 | for (const serviceDefinition of services) {
|
35 | for (const validator of preNormalizationValidators) {
|
36 | errors.push(...validator(serviceDefinition));
|
37 | }
|
38 | }
|
39 | return errors;
|
40 | }
|
41 | exports.validateServicesBeforeNormalization = validateServicesBeforeNormalization;
|
42 | const preCompositionValidators = Object.values(preCompositionRules);
|
43 | const validateServicesBeforeComposition = (services) => {
|
44 | const warningsOrErrors = [];
|
45 | for (const serviceDefinition of services) {
|
46 | for (const validator of preCompositionValidators) {
|
47 | warningsOrErrors.push(...validator(serviceDefinition));
|
48 | }
|
49 | }
|
50 | return warningsOrErrors;
|
51 | };
|
52 | exports.validateServicesBeforeComposition = validateServicesBeforeComposition;
|
53 | const postCompositionValidators = Object.values(postCompositionRules);
|
54 | const validateComposedSchema = ({ schema, serviceList, }) => {
|
55 | const warningsOrErrors = [];
|
56 | warningsOrErrors.push(...(0, graphql_1.validateSchema)(schema));
|
57 | for (const validator of postCompositionValidators) {
|
58 | warningsOrErrors.push(...validator({ schema, serviceList }));
|
59 | }
|
60 | return warningsOrErrors;
|
61 | };
|
62 | exports.validateComposedSchema = validateComposedSchema;
|
63 |
|
\ | No newline at end of file |