1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.TypeDefsFederation2Decorator = void 0;
|
4 | const shared_utils_1 = require("@nestjs/common/utils/shared.utils");
|
5 | const utils_1 = require("../utils");
|
6 | class TypeDefsFederation2Decorator {
|
7 | decorate(typeDefs, config = { version: 2 }) {
|
8 | const { directives = [
|
9 | '@composeDirective',
|
10 | '@extends',
|
11 | '@external',
|
12 | '@inaccessible',
|
13 | '@interfaceObject',
|
14 | '@key',
|
15 | '@override',
|
16 | '@provides',
|
17 | '@requires',
|
18 | '@shareable',
|
19 | '@tag',
|
20 | ], importUrl = 'https://specs.apollo.dev/federation/v2.3', } = config;
|
21 | const mappedDirectives = directives
|
22 | .map((directive) => {
|
23 | if (!(0, shared_utils_1.isString)(directive)) {
|
24 | return (0, utils_1.stringifyWithoutQuotes)(directive);
|
25 | }
|
26 | let finalDirective = directive;
|
27 | if (!directive.startsWith('@')) {
|
28 | finalDirective = `@${directive}`;
|
29 | }
|
30 | return `"${finalDirective}"`;
|
31 | })
|
32 | .join(', ');
|
33 | return `
|
34 | extend schema @link(url: "${importUrl}", import: [${mappedDirectives}])
|
35 | ${typeDefs}
|
36 | `;
|
37 | }
|
38 | }
|
39 | exports.TypeDefsFederation2Decorator = TypeDefsFederation2Decorator;
|