Skip to content

Commit bf7ac71

Browse files
authored
feat: use a static version id for the router configs generated by wgc router compose (#2337)
1 parent 6c49302 commit bf7ac71

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

cli/src/commands/router/commands/compose.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { existsSync } from 'node:fs';
22
import { readFile, writeFile } from 'node:fs/promises';
3-
import { randomUUID } from 'node:crypto';
43
import {
54
buildRouterConfig,
65
type ComposedSubgraph,
@@ -29,6 +28,8 @@ import { FederationSuccess, ROUTER_COMPATIBILITY_VERSION_ONE } from '@wundergrap
2928
import { BaseCommandOptions } from '../../../core/types/types.js';
3029
import { composeSubgraphs, introspectSubgraph } from '../../../utils.js';
3130

31+
const STATIC_SCHEMA_VERSION_ID = '00000000-0000-0000-0000-000000000000';
32+
3233
type ConfigSubgraph = StandardSubgraphConfig | SubgraphPluginConfig | GRPCSubgraphConfig;
3334

3435
type StandardSubgraphConfig = {
@@ -241,19 +242,19 @@ export default (opts: BaseCommandOptions) => {
241242
console.log(compositionWarningsTable.toString());
242243
}
243244

244-
const federatedClientSDL = result.shouldIncludeClientSchema ? printSchema(result.federatedGraphClientSchema) : '';
245+
const federatedClientSDL = result.shouldIncludeClientSchema
246+
? printSchemaWithDirectives(result.federatedGraphClientSchema)
247+
: '';
245248
const routerConfig = buildRouterConfig({
246249
federatedClientSDL,
247250
federatedSDL: printSchemaWithDirectives(result.federatedGraphSchema),
248251
fieldConfigurations: result.fieldConfigurations,
249252
// @TODO get router compatibility version programmatically
250253
routerCompatibilityVersion: ROUTER_COMPATIBILITY_VERSION_ONE,
251-
schemaVersionId: 'static',
254+
schemaVersionId: STATIC_SCHEMA_VERSION_ID,
252255
subgraphs: subgraphs.map((s, index) => constructRouterSubgraph(result, s, index)),
253256
});
254257

255-
routerConfig.version = randomUUID();
256-
257258
if (config.feature_flags && config.feature_flags.length > 0) {
258259
const ffConfigs = await buildFeatureFlagsConfig(config, inputFileLocation, subgraphs, options);
259260
routerConfig.featureFlagConfigs = ffConfigs;
@@ -663,7 +664,7 @@ async function buildFeatureFlagsConfig(
663664
engineConfig: featureRouterConfig.engineConfig,
664665
});
665666

666-
ffConfigs.configByFeatureFlagName[ff.name].version = randomUUID();
667+
ffConfigs.configByFeatureFlagName[ff.name].version = STATIC_SCHEMA_VERSION_ID;
667668
}
668669

669670
return ffConfigs;

0 commit comments

Comments
 (0)