Skip to content

Commit d47cb61

Browse files
authored
Merge branch 'main' into wilson/eng-6493-add-api-key-in-audit-log
2 parents 96f8983 + e0755c9 commit d47cb61

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+600
-210
lines changed

.release-please-manifest.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
2-
"helm/cosmo": "0.12.3",
3-
"helm/cosmo/charts/router": "0.9.0"
2+
"helm/cosmo": "0.13.0",
3+
"helm/cosmo/charts/router": "0.10.0"
44
}

README.md

+6-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@
2121

2222
WunderGraph Cosmo is a comprehensive Lifecycle API Management platform tailored for Federated GraphQL. It encompasses everything from Schema Registry, composition checks, and analytics, to metrics, tracing, and routing. Whether you’re looking to deploy 100% on-prem or prefer a [Managed Service](https://cosmo.wundergraph.com/login), Cosmo offers flexibility without vendor lock-in, all under the Apache 2.0 license.
2323

24+
## The State of GraphQL Federation 2024
25+
26+
Get insights from industry experts and Federation practicioners across all industries and learn how companies are using GraphQL Federation.
27+
Head over to the [State of GraphQL Federation 2024](https://wundergraph.com/state-of-graphql-federation/2024) page and download the full **48 page PDF report** for free!
28+
2429
### Why Federated GraphQL?
2530

2631
GraphQL Federation empowers organizations to break down their GraphQL schema into multiple smaller, manageable schemas, each maintained by different teams or services. These individual schemas are then combined into a single, unified graph, ensuring that all teams have consistent access to the data they need. In today's data-driven world, where information is often referred to as the new oil, building a unified API that can be consumed by both internal and external teams is more crucial than ever.
@@ -74,4 +79,4 @@ We welcome contributions from the community! Whether it's fixing a bug, adding n
7479

7580
## License
7681

77-
Cosmo is licensed under the [Apache License, Version 2.0](LICENSE).
82+
Cosmo is licensed under the [Apache License, Version 2.0](LICENSE).

cdn-server/CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ Binaries are attached to the github release otherwise all images can be found [h
44
All notable changes to this project will be documented in this file.
55
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
66

7+
## [0.14.2](https://github.com/wundergraph/cosmo/compare/[email protected]@0.14.2) (2025-03-11)
8+
9+
**Note:** Version bump only for package cdn
10+
711
## [0.14.1](https://github.com/wundergraph/cosmo/compare/[email protected]@0.14.1) (2025-02-21)
812

913
**Note:** Version bump only for package cdn

cdn-server/cdn/CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ Binaries are attached to the github release otherwise all images can be found [h
44
All notable changes to this project will be documented in this file.
55
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
66

7+
## [0.9.2](https://github.com/wundergraph/cosmo/compare/@wundergraph/[email protected]...@wundergraph/[email protected]) (2025-03-11)
8+
9+
**Note:** Version bump only for package @wundergraph/cosmo-cdn
10+
711
## [0.9.1](https://github.com/wundergraph/cosmo/compare/@wundergraph/[email protected]...@wundergraph/[email protected]) (2025-02-21)
812

913
**Note:** Version bump only for package @wundergraph/cosmo-cdn

cdn-server/cdn/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@wundergraph/cosmo-cdn",
3-
"version": "0.9.1",
3+
"version": "0.9.2",
44
"author": {
55
"name": "WunderGraph Maintainers",
66
"email": "[email protected]"

cdn-server/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "cdn",
3-
"version": "0.14.1",
3+
"version": "0.14.2",
44
"private": true,
55
"author": {
66
"name": "WunderGraph Maintainers",

cli/CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ Binaries are attached to the github release otherwise all images can be found [h
44
All notable changes to this project will be documented in this file.
55
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
66

7+
## [0.75.6](https://github.com/wundergraph/cosmo/compare/[email protected]@0.75.6) (2025-03-11)
8+
9+
### Bug Fixes
10+
11+
* composition warnings should respect --json flag and output in JSON format ([#1673](https://github.com/wundergraph/cosmo/issues/1673)) ([745140f](https://github.com/wundergraph/cosmo/commit/745140f001230fea2cbd1fd7e6e2b12d47eeb36f)) (@JivusAyrus)
12+
713
## [0.75.5](https://github.com/wundergraph/cosmo/compare/[email protected]@0.75.5) (2025-03-06)
814

915
### Bug Fixes

cli/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "wgc",
3-
"version": "0.75.5",
3+
"version": "0.75.6",
44
"description": "The official CLI tool to manage the GraphQL Federation Platform Cosmo",
55
"type": "module",
66
"main": "dist/src/index.js",

cli/src/commands/feature-subgraph/commands/publish.ts

+29-126
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { BaseCommandOptions, SubgraphCommandJsonOutput } from '../../../core/typ
1111
import { getBaseHeaders } from '../../../core/config.js';
1212
import { validateSubscriptionProtocols } from '../../../utils.js';
1313
import { websocketSubprotocolDescription } from '../../../constants.js';
14+
import { handleCompositionResult } from '../../../handle-composition-result.js';
1415

1516
export default (opts: BaseCommandOptions) => {
1617
const command = new Command('publish');
@@ -60,6 +61,7 @@ export default (opts: BaseCommandOptions) => {
6061
);
6162
command.option('-r, --raw', 'Prints to the console in json format instead of table');
6263
command.option('-j, --json', 'Prints to the console in json format instead of table');
64+
command.option('--suppress-warnings', 'This flag suppresses any warnings produced by composition.');
6365

6466
command.action(async (name, options) => {
6567
const schemaFile = resolve(options.schema);
@@ -114,132 +116,33 @@ export default (opts: BaseCommandOptions) => {
114116
},
115117
);
116118

117-
switch (resp.response?.code) {
118-
case EnumStatusCode.OK: {
119-
if (shouldOutputJson) {
120-
const successMessageJson: SubgraphCommandJsonOutput = {
121-
status: 'success',
122-
message: 'Feature subgraph published successfully.',
123-
compositionErrors: resp.compositionErrors,
124-
deploymentErrors: resp.deploymentErrors,
125-
};
126-
console.log(JSON.stringify(successMessageJson));
127-
} else {
128-
spinner.succeed(
129-
resp?.hasChanged === false ? 'No new changes to publish.' : 'Feature subgraph published successfully.',
130-
);
131-
}
132-
133-
break;
134-
}
135-
case EnumStatusCode.ERR_SUBGRAPH_COMPOSITION_FAILED: {
136-
if (shouldOutputJson) {
137-
const compositionFailedMessageJson: SubgraphCommandJsonOutput = {
138-
status: 'error',
139-
message: 'Feature subgraph published but with composition errors.',
140-
compositionErrors: resp.compositionErrors,
141-
deploymentErrors: resp.deploymentErrors,
142-
};
143-
console.log(JSON.stringify(compositionFailedMessageJson));
144-
} else {
145-
spinner.warn('Feature subgraph published but with composition errors.');
146-
147-
const compositionErrorsTable = new Table({
148-
head: [
149-
pc.bold(pc.white('FEDERATED_GRAPH_NAME')),
150-
pc.bold(pc.white('NAMESPACE')),
151-
pc.bold(pc.white('FEATURE_FLAG')),
152-
pc.bold(pc.white('ERROR_MESSAGE')),
153-
],
154-
colWidths: [30, 30, 30, 120],
155-
wordWrap: true,
156-
});
157-
158-
console.log(
159-
pc.red(
160-
`We found composition errors, while composing the federated graph.\nThe router will continue to work with the latest valid schema.\n${pc.bold(
161-
'Please check the errors below:',
162-
)}`,
163-
),
164-
);
165-
for (const compositionError of resp.compositionErrors) {
166-
compositionErrorsTable.push([
167-
compositionError.federatedGraphName,
168-
compositionError.namespace,
169-
compositionError.featureFlag || '-',
170-
compositionError.message,
171-
]);
172-
}
173-
// Don't exit here with 1 because the change was still applied
174-
console.log(compositionErrorsTable.toString());
175-
176-
if (options.failOnCompositionError) {
177-
program.error(pc.red(pc.bold('The command failed due to composition errors.')));
178-
}
179-
}
180-
break;
181-
}
182-
case EnumStatusCode.ERR_DEPLOYMENT_FAILED: {
183-
if (shouldOutputJson) {
184-
const deploymentFailedMessageJson: SubgraphCommandJsonOutput = {
185-
status: 'error',
186-
message: `Feature subgraph was published, but the updated composition hasn't been deployed, so it's not accessible to the router. Check the errors listed below for details.`,
187-
compositionErrors: resp.compositionErrors,
188-
deploymentErrors: resp.deploymentErrors,
189-
};
190-
console.log(JSON.stringify(deploymentFailedMessageJson));
191-
} else {
192-
spinner.warn(
193-
"Feature subgraph was published, but the updated composition hasn't been deployed, so it's not accessible to the router. Check the errors listed below for details.",
194-
);
195-
196-
const deploymentErrorsTable = new Table({
197-
head: [
198-
pc.bold(pc.white('FEDERATED_GRAPH_NAME')),
199-
pc.bold(pc.white('NAMESPACE')),
200-
pc.bold(pc.white('ERROR_MESSAGE')),
201-
],
202-
colWidths: [30, 30, 120],
203-
wordWrap: true,
204-
});
205-
206-
for (const deploymentError of resp.deploymentErrors) {
207-
deploymentErrorsTable.push([
208-
deploymentError.federatedGraphName,
209-
deploymentError.namespace,
210-
deploymentError.message,
211-
]);
212-
}
213-
// Don't exit here with 1 because the change was still applied
214-
console.log(deploymentErrorsTable.toString());
215-
216-
if (options.failOnAdmissionWebhookError) {
217-
program.error(pc.red(pc.bold('The command failed due to admission webhook errors.')));
218-
}
219-
}
220-
221-
break;
222-
}
223-
default: {
224-
if (shouldOutputJson) {
225-
const defaultErrorMessageJson: SubgraphCommandJsonOutput = {
226-
status: 'error',
227-
message: `Failed to publish feature subgraph "${name}".`,
228-
compositionErrors: resp.compositionErrors,
229-
deploymentErrors: resp.deploymentErrors,
230-
details: resp.response?.details,
231-
};
232-
console.log(JSON.stringify(defaultErrorMessageJson));
233-
} else {
234-
spinner.fail(`Failed to publish feature subgraph "${name}".`);
235-
if (resp.response?.details) {
236-
program.error(pc.red(pc.bold(resp.response?.details)));
237-
}
238-
}
239-
process.exitCode = 1;
240-
// eslint-disable-next-line no-useless-return
241-
return;
242-
}
119+
try {
120+
handleCompositionResult({
121+
responseCode: resp.response?.code,
122+
responseDetails: resp.response?.details,
123+
compositionErrors: resp.compositionErrors,
124+
compositionWarnings: resp.compositionWarnings,
125+
deploymentErrors: resp.deploymentErrors,
126+
spinner,
127+
successMessage:
128+
resp?.hasChanged === false ? 'No new changes to publish.' : 'Feature subgraph published successfully.',
129+
subgraphCompositionBaseErrorMessage: 'Feature subgraph published but with composition errors.',
130+
subgraphCompositionDetailedErrorMessage: `We found composition errors, while composing the federated graph.\nThe router will continue to work with the latest valid schema.\n${pc.bold(
131+
'Please check the errors below:',
132+
)}`,
133+
deploymentErrorMessage: `Feature subgraph was published, but the updated composition hasn't been deployed, so it's not accessible to the router. Check the errors listed below for details.`,
134+
defaultErrorMessage: `Failed to publish feature subgraph "${name}".`,
135+
shouldOutputJson: options.json,
136+
suppressWarnings: options.suppressWarnings,
137+
failOnCompositionError: options.failOnCompositionError,
138+
failOnAdmissionWebhookError: options.failOnAdmissionWebhookError,
139+
failOnCompositionErrorMessage: `The command failed due to composition errors.`,
140+
failOnAdmissionWebhookErrorMessage: `The command failed due to admission webhook errors.`,
141+
});
142+
} catch {
143+
process.exitCode = 1;
144+
// eslint-disable-next-line no-useless-return
145+
return;
243146
}
244147
});
245148

cli/src/core/types/types.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
import { CompositionError, DeploymentError } from '@wundergraph/cosmo-connect/dist/platform/v1/platform_pb.js';
1+
import {
2+
CompositionError,
3+
CompositionWarning,
4+
DeploymentError,
5+
} from '@wundergraph/cosmo-connect/dist/platform/v1/platform_pb.js';
26
import { Client } from '../client/client.js';
37

48
export interface BaseCommandOptions {
@@ -13,6 +17,7 @@ export type SubgraphCommandJsonOutput = {
1317
status: 'success' | 'error';
1418
compositionErrors: CompositionError[];
1519
deploymentErrors: DeploymentError[];
20+
compositionWarnings?: CompositionWarning[];
1621
message: string;
1722
details?: string;
1823
};

cli/src/handle-composition-result.ts

+31-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ export const handleCompositionResult = ({
2424
defaultErrorMessage,
2525
shouldOutputJson,
2626
suppressWarnings,
27+
failOnCompositionError,
28+
failOnCompositionErrorMessage,
29+
failOnAdmissionWebhookError,
30+
failOnAdmissionWebhookErrorMessage,
2731
}: {
2832
responseCode: EnumStatusCode | undefined;
2933
responseDetails: string | undefined;
@@ -38,6 +42,10 @@ export const handleCompositionResult = ({
3842
defaultErrorMessage: string;
3943
shouldOutputJson?: boolean;
4044
suppressWarnings?: boolean;
45+
failOnCompositionError?: boolean;
46+
failOnCompositionErrorMessage?: string;
47+
failOnAdmissionWebhookError?: boolean;
48+
failOnAdmissionWebhookErrorMessage?: string;
4149
}) => {
4250
switch (responseCode) {
4351
case EnumStatusCode.OK: {
@@ -48,6 +56,9 @@ export const handleCompositionResult = ({
4856
compositionErrors,
4957
deploymentErrors,
5058
};
59+
if (!suppressWarnings) {
60+
successMessageJson.compositionWarnings = compositionWarnings;
61+
}
5162
console.log(JSON.stringify(successMessageJson));
5263
} else {
5364
spinner.succeed(successMessage);
@@ -62,6 +73,9 @@ export const handleCompositionResult = ({
6273
compositionErrors,
6374
deploymentErrors,
6475
};
76+
if (!suppressWarnings) {
77+
compositionFailedMessageJson.compositionWarnings = compositionWarnings;
78+
}
6579
console.log(JSON.stringify(compositionFailedMessageJson));
6680
} else {
6781
spinner.fail(subgraphCompositionBaseErrorMessage);
@@ -89,6 +103,10 @@ export const handleCompositionResult = ({
89103
// Don't exit here with 1 because the change was still applied
90104
console.log(compositionErrorsTable.toString());
91105
}
106+
if (failOnCompositionError) {
107+
console.log(pc.red(pc.bold(failOnCompositionErrorMessage || 'The command failed due to composition errors.')));
108+
throw new Error(failOnCompositionErrorMessage || 'The command failed due to composition errors.');
109+
}
92110
break;
93111
}
94112
case EnumStatusCode.ERR_DEPLOYMENT_FAILED: {
@@ -99,6 +117,9 @@ export const handleCompositionResult = ({
99117
compositionErrors,
100118
deploymentErrors,
101119
};
120+
if (!suppressWarnings) {
121+
deploymentFailedMessageJson.compositionWarnings = compositionWarnings;
122+
}
102123
console.log(JSON.stringify(deploymentFailedMessageJson));
103124
} else {
104125
spinner.warn(deploymentErrorMessage);
@@ -123,6 +144,12 @@ export const handleCompositionResult = ({
123144
// Don't exit here with 1 because the change was still applied
124145
console.log(deploymentErrorsTable.toString());
125146
}
147+
if (failOnAdmissionWebhookError) {
148+
console.log(
149+
pc.red(pc.bold(failOnAdmissionWebhookErrorMessage || 'The command failed due to admission webhook errors.')),
150+
);
151+
throw new Error(failOnAdmissionWebhookErrorMessage || 'The command failed due to admission webhook errors.');
152+
}
126153
break;
127154
}
128155
default: {
@@ -134,6 +161,9 @@ export const handleCompositionResult = ({
134161
deploymentErrors,
135162
details: responseDetails,
136163
};
164+
if (!suppressWarnings) {
165+
defaultErrorMessageJson.compositionWarnings = compositionWarnings;
166+
}
137167
console.log(JSON.stringify(defaultErrorMessageJson));
138168
} else {
139169
spinner.fail(defaultErrorMessage);
@@ -145,7 +175,7 @@ export const handleCompositionResult = ({
145175
}
146176
}
147177

148-
if (!suppressWarnings && compositionWarnings.length > 0) {
178+
if (!shouldOutputJson && !suppressWarnings && compositionWarnings.length > 0) {
149179
const compositionWarningsTable = new Table({
150180
head: [
151181
pc.bold(pc.white('FEDERATED_GRAPH_NAME')),

composition/CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ Binaries are attached to the github release otherwise all images can be found [h
44
All notable changes to this project will be documented in this file.
55
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
66

7+
## [0.37.2](https://github.com/wundergraph/cosmo/compare/@wundergraph/[email protected]...@wundergraph/[email protected]) (2025-03-11)
8+
9+
**Note:** Version bump only for package @wundergraph/composition
10+
711
## [0.37.1](https://github.com/wundergraph/cosmo/compare/@wundergraph/[email protected]...@wundergraph/[email protected]) (2025-02-27)
812

913
### Bug Fixes

composition/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@wundergraph/composition",
3-
"version": "0.37.1",
3+
"version": "0.37.2",
44
"author": {
55
"name": "WunderGraph Maintainers",
66
"email": "[email protected]"

0 commit comments

Comments
 (0)