@theguild/federation-composition 0.8.2 → 0.9.0-alpha-20240226120350-5cdff5e

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/cjs/compose.js CHANGED
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.compositionHasErrors = exports.assertCompositionFailure = exports.assertCompositionSuccess = exports.composeServices = void 0;
4
4
  const graphql_1 = require("graphql");
5
5
  const printer_js_1 = require("./graphql/printer.js");
6
+ const transform_supergraph_to_public_schema_js_1 = require("./graphql/transform-supergraph-to-public-schema.js");
6
7
  const authenticated_js_1 = require("./specifications/authenticated.js");
7
8
  const inaccessible_js_1 = require("./specifications/inaccessible.js");
8
9
  const join_js_1 = require("./specifications/join.js");
@@ -44,6 +45,7 @@ function composeServices(services, __internal) {
44
45
  const usedPolicySpec = validationResult.specs.policy;
45
46
  const usedRequiresScopesSpec = validationResult.specs.requiresScopes;
46
47
  const usedAuthenticatedSpec = validationResult.specs.authenticated;
48
+ let _publicSdl;
47
49
  return {
48
50
  supergraphSdl: `
49
51
  schema
@@ -80,6 +82,16 @@ ${(0, printer_js_1.print)({
80
82
  definitions: validationResult.supergraph,
81
83
  })}
82
84
  `,
85
+ get publicSdl() {
86
+ if (_publicSdl) {
87
+ return _publicSdl;
88
+ }
89
+ _publicSdl = (0, printer_js_1.print)((0, transform_supergraph_to_public_schema_js_1.transformSupergraphToPublicSchema)({
90
+ kind: graphql_1.Kind.DOCUMENT,
91
+ definitions: validationResult.supergraph,
92
+ }));
93
+ return _publicSdl;
94
+ },
83
95
  };
84
96
  }
85
97
  exports.composeServices = composeServices;
package/esm/compose.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { Kind } from 'graphql';
2
2
  import { print } from './graphql/printer.js';
3
+ import { transformSupergraphToPublicSchema } from './graphql/transform-supergraph-to-public-schema.js';
3
4
  import { sdl as authenticatedSDL } from './specifications/authenticated.js';
4
5
  import { sdl as inaccessibleSDL } from './specifications/inaccessible.js';
5
6
  import { sdl as joinSDL } from './specifications/join.js';
@@ -41,6 +42,7 @@ export function composeServices(services, __internal) {
41
42
  const usedPolicySpec = validationResult.specs.policy;
42
43
  const usedRequiresScopesSpec = validationResult.specs.requiresScopes;
43
44
  const usedAuthenticatedSpec = validationResult.specs.authenticated;
45
+ let _publicSdl;
44
46
  return {
45
47
  supergraphSdl: `
46
48
  schema
@@ -77,6 +79,16 @@ ${print({
77
79
  definitions: validationResult.supergraph,
78
80
  })}
79
81
  `,
82
+ get publicSdl() {
83
+ if (_publicSdl) {
84
+ return _publicSdl;
85
+ }
86
+ _publicSdl = print(transformSupergraphToPublicSchema({
87
+ kind: Kind.DOCUMENT,
88
+ definitions: validationResult.supergraph,
89
+ }));
90
+ return _publicSdl;
91
+ },
80
92
  };
81
93
  }
82
94
  export function assertCompositionSuccess(compositionResult, message) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@theguild/federation-composition",
3
- "version": "0.8.2",
3
+ "version": "0.9.0-alpha-20240226120350-5cdff5e",
4
4
  "description": "Open Source Composition library for Apollo Federation",
5
5
  "peerDependencies": {
6
6
  "graphql": "^16.0.0"
@@ -10,6 +10,7 @@ export interface CompositionFailure {
10
10
  }
11
11
  export interface CompositionSuccess {
12
12
  supergraphSdl: string;
13
+ publicSdl: string;
13
14
  errors?: undefined;
14
15
  }
15
16
  export declare function assertCompositionSuccess(compositionResult: CompositionResult, message?: string): asserts compositionResult is CompositionSuccess;
@@ -10,6 +10,7 @@ export interface CompositionFailure {
10
10
  }
11
11
  export interface CompositionSuccess {
12
12
  supergraphSdl: string;
13
+ publicSdl: string;
13
14
  errors?: undefined;
14
15
  }
15
16
  export declare function assertCompositionSuccess(compositionResult: CompositionResult, message?: string): asserts compositionResult is CompositionSuccess;