Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
d6b4498
feat(tests): add test for checking schema CLI
comatory Mar 5, 2026
548dd66
feat: JSON output
comatory Mar 4, 2026
99d1364
chore(test): add JSON output tests
comatory Mar 5, 2026
77d0ea6
fix: formatting
comatory Mar 5, 2026
100c4fa
refactor: make the handler function more readable
comatory Mar 5, 2026
a2a73fe
chore: use root version of prettier
comatory Mar 5, 2026
b93bb02
fix: prettier invocation
comatory Mar 5, 2026
b7198f6
feat: add JSON flag to monograph check
comatory Mar 5, 2026
58b1b8f
fix: displaying errors/warnings as arrays
comatory Mar 5, 2026
89a31d4
fix: ensure tests can handle colorized/non-colorized outputs
comatory Mar 5, 2026
69bcd1e
fix: duplicate flag
comatory Mar 5, 2026
7e03da4
Merge branch 'main' into ondrej/eng-8836-cli-add-json-to-subgraph-check
comatory Mar 6, 2026
852cec7
Merge branch 'main' into ondrej/eng-8836-cli-add-json-to-subgraph-check
comatory Mar 9, 2026
12a0dfb
feat: support `outFile`
comatory Mar 9, 2026
21d40be
fix: exclude traffic checks in JSON output
comatory Mar 9, 2026
a30f768
refactor: extract JSON builder class to separate file + tests
comatory Mar 9, 2026
6c41699
fix: omit `linkedToSubgraph` JSON property
comatory Mar 9, 2026
1b3a7ef
refactor: remove nested success properties for JSON output
comatory Mar 9, 2026
50b2cad
fix: do not include traffic property with --skip-traffic-check
comatory Mar 9, 2026
0655b96
feat: backport composedSchemaBreakingChanges
comatory Mar 10, 2026
0d950c2
chore(test): cover method for composed breaking changes
comatory Mar 10, 2026
fc2777e
fix: remove casts to any in tests for json output builder
comatory Mar 10, 2026
6644689
fix: traffic is only added when breaking changes are detected
comatory Mar 10, 2026
8642499
fix: rename Json builder class to be specific to check schemas
comatory Mar 10, 2026
a691057
Merge branch 'main' into ondrej/eng-8836-cli-add-json-to-subgraph-check
comatory Mar 10, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion cli/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ out
node_modules
.env
.eslintcache
e2e/config.json
e2e/config.json
coverage
66 changes: 33 additions & 33 deletions cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,32 +12,32 @@

With `wgc`, you can:

* Create and manage **federated GraphQL APIs** and **subgraphs**
* Perform **schema checks** and **composition validations**
* Generate and deploy **router configurations**
* Integrate with **CI/CD pipelines** for automated workflows
* Manage **namespaces**, **API keys**, and more
- Create and manage **federated GraphQL APIs** and **subgraphs**
- Perform **schema checks** and **composition validations**
- Generate and deploy **router configurations**
- Integrate with **CI/CD pipelines** for automated workflows
- Manage **namespaces**, **API keys**, and more

Whether you're building monolithic or federated GraphQL architectures, `wgc` provides the tools to manage your development and deployment processes.

---

## 🧰 Cosmo Features

* **Federation Support**: Compatible with GraphQL Federation v1 and v2
* **Schema Registry**: Centralized management of your GraphQL schemas with versioning and change tracking
* **Composition Checks**: Automated validation to ensure subgraphs compose correctly without breaking changes
* **Router Configuration**: Generate and manage router configurations for efficient query planning and execution
* **Observability**: Integrated with OpenTelemetry and Prometheus for metrics, tracing, and monitoring
* **Access Control**: Fine-grained access controls with support for OIDC, RBAC, and SCIM
- **Federation Support**: Compatible with GraphQL Federation v1 and v2
- **Schema Registry**: Centralized management of your GraphQL schemas with versioning and change tracking
- **Composition Checks**: Automated validation to ensure subgraphs compose correctly without breaking changes
- **Router Configuration**: Generate and manage router configurations for efficient query planning and execution
- **Observability**: Integrated with OpenTelemetry and Prometheus for metrics, tracing, and monitoring
- **Access Control**: Fine-grained access controls with support for OIDC, RBAC, and SCIM

---

## 📦 Installation

### Prerequisites

* [Node.js](https://nodejs.org/) v20 LTS or higher
- [Node.js](https://nodejs.org/) v20 LTS or higher

### Install via npm

Expand Down Expand Up @@ -83,8 +83,8 @@ chmod +x start-subgraphs.sh

Verify the subgraphs are running:

* [Posts Subgraph](http://localhost:4001/graphql)
* [Users Subgraph](http://localhost:4002/graphql)
- [Posts Subgraph](http://localhost:4001/graphql)
- [Users Subgraph](http://localhost:4002/graphql)

### 4. Generate Router Configuration

Expand Down Expand Up @@ -137,53 +137,53 @@ query {

## 📚 Documentation

* **CLI Reference**: [https://cosmo-docs.wundergraph.com/cli](https://cosmo-docs.wundergraph.com/cli)
* **Zero to Federation Tutorial**: [https://cosmo-docs.wundergraph.com/tutorial/from-zero-to-federation-in-5-steps-using-cosmo](https://cosmo-docs.wundergraph.com/tutorial/from-zero-to-federation-in-5-steps-using-cosmo)
* **Full Documentation**: [https://cosmo-docs.wundergraph.com/](https://cosmo-docs.wundergraph.com/)
- **CLI Reference**: [https://cosmo-docs.wundergraph.com/cli](https://cosmo-docs.wundergraph.com/cli)
- **Zero to Federation Tutorial**: [https://cosmo-docs.wundergraph.com/tutorial/from-zero-to-federation-in-5-steps-using-cosmo](https://cosmo-docs.wundergraph.com/tutorial/from-zero-to-federation-in-5-steps-using-cosmo)
- **Full Documentation**: [https://cosmo-docs.wundergraph.com/](https://cosmo-docs.wundergraph.com/)

---

## 🌐 About WunderGraph Cosmo

WunderGraph Cosmo is a comprehensive, open-source platform for managing GraphQL APIs at scale. It offers:

* **Schema Registry**: Centralized schema management with versioning and validation
* **Cosmo Studio**: A web interface for exploring schemas, monitoring performance, and managing access
* **Cosmo Router**: A high-performance, Go-based router supporting federation, subscriptions, and more
* **Observability**: Built-in support for OpenTelemetry and Prometheus
* **Security**: Fine-grained access controls with OIDC, RBAC, and SCIM support
- **Schema Registry**: Centralized schema management with versioning and validation
- **Cosmo Studio**: A web interface for exploring schemas, monitoring performance, and managing access
- **Cosmo Router**: A high-performance, Go-based router supporting federation, subscriptions, and more
- **Observability**: Built-in support for OpenTelemetry and Prometheus
- **Security**: Fine-grained access controls with OIDC, RBAC, and SCIM support

Cosmo can be deployed on-premises, in the cloud, or used as a managed service.

---

## 🧪 Example Commands

* **Create Namespace**:
- **Create Namespace**:

```bash
npx wgc namespace create production
```

* **Create Federated Graph**:
- **Create Federated Graph**:

```bash
npx wgc federated-graph create main -r http://router.example.com/graphql -n production
```

* **Create Subgraph**:
- **Create Subgraph**:

```bash
npx wgc subgraph create products --routing-url http://localhost:4001/graphql
```

* **Check Subgraph Schema Changes**:
- **Check Subgraph Schema Changes**:

```bash
npx wgc subgraph check products -n production --schema ./schemas/products.graphql
```

* **Generate Router Configuration locally**:
- **Generate Router Configuration locally**:

Composition Configuration (graph.yaml):

Expand All @@ -202,7 +202,7 @@ Generate CMD:
npx wgc router compose -i graph.yaml -o config.json
```

* **Run Router**:
- **Run Router**:

```bash
docker run \
Expand All @@ -223,9 +223,9 @@ docker run \

## 🔗 Related Projects

* **Cosmo Demo**: [https://github.com/wundergraph/cosmo-demo](https://github.com/wundergraph/cosmo-demo)
* **Cosmo GitHub Repository**: [https://github.com/wundergraph/cosmo](https://github.com/wundergraph/cosmo)
* **WunderGraph Website**: [https://wundergraph.com](https://wundergraph.com)
- **Cosmo Demo**: [https://github.com/wundergraph/cosmo-demo](https://github.com/wundergraph/cosmo-demo)
- **Cosmo GitHub Repository**: [https://github.com/wundergraph/cosmo](https://github.com/wundergraph/cosmo)
- **WunderGraph Website**: [https://wundergraph.com](https://wundergraph.com)

---

Expand Down Expand Up @@ -271,8 +271,8 @@ This project is licensed under the [Apache 2.0 License](https://github.com/wunde

## 📬 Support & Community

* **Discord**: Join our [Discord community](https://wundergraph.com/discord) for support and discussions
* **GitHub Issues**: Report issues or request features on our [GitHub repository](https://github.com/wundergraph/cosmo/issues)
- **Discord**: Join our [Discord community](https://wundergraph.com/discord) for support and discussions
- **GitHub Issues**: Report issues or request features on our [GitHub repository](https://github.com/wundergraph/cosmo/issues)

---

Expand Down
3 changes: 1 addition & 2 deletions cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"coverage": "vitest run test/ --coverage",
"lint": "eslint --cache --ext .ts,.mjs,.cjs . && prettier -c src",
"lint:fix": "eslint --cache --fix --ext .ts,.mjs,.cjs . && pnpm format",
"format": "prettier -w -c .",
"format": "prettier -w .",
"e2e": "bun test e2e/"
},
"keywords": [
Expand Down Expand Up @@ -104,7 +104,6 @@
"eslint": "8.57.1",
"eslint-config-unjs": "0.2.1",
"eslint-plugin-require-extensions": "0.1.3",
"prettier": "3.5.2",
"tsx": "4.19.4",
"typescript": "5.5.2",
"vitest": "3.2.4"
Expand Down
14 changes: 13 additions & 1 deletion cli/src/commands/graph/monograph/commands/check.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,11 @@ export default (opts: BaseCommandOptions) => {
'This will skip checking for client traffic and any breaking change will fail the run.',
);
command.option('-l, --limit [number]', 'The amount of entries shown in the schema checks output.', '50');
command.option('-j, --json', 'Prints to the console in json format instead of table');
Comment thread
comatory marked this conversation as resolved.
command.option('-o, --out [string]', 'Destination file for the json output.');
Comment thread
comatory marked this conversation as resolved.

command.action(async (name, options) => {
let outFile;
const schemaFile = resolve(options.schema);

if (!existsSync(schemaFile)) {
Expand All @@ -34,6 +37,10 @@ export default (opts: BaseCommandOptions) => {
return;
}

if (options.out) {
outFile = resolve(options.out);
}

const limit = Number(options.limit);
if (Number.isNaN(limit) || limit <= 0 || limit > limitMaxValue) {
program.error(
Expand Down Expand Up @@ -79,7 +86,12 @@ export default (opts: BaseCommandOptions) => {
},
);

const success = handleCheckResult(resp, limit);
const success = await handleCheckResult({
response: resp,
rowLimit: limit,
shouldOutputJson: options.json || !!outFile,
outFile,
});

if (!success && !ignoreErrorsDueToGitHubIntegration) {
process.exitCode = 1;
Expand Down
14 changes: 13 additions & 1 deletion cli/src/commands/subgraph/commands/check.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,12 @@ export default (opts: BaseCommandOptions) => {
'This flag will disable the validation for whether all nodes of the federated graph are resolvable. Do NOT use unless troubleshooting.',
);
command.option('-l, --limit [number]', 'The amount of entries shown in the schema checks output.', '50');
command.option('-j, --json', 'Prints to the console in json format instead of table');
command.option('-o, --out [string]', 'Destination file for the json output.');

command.action(async (name, options) => {
let schemaFile;
let outFile;

if (!options.schema && !options.delete) {
program.error("required option '--schema <path-to-schema>' or '--delete' not specified.");
Expand All @@ -52,6 +55,10 @@ export default (opts: BaseCommandOptions) => {
}
}

if (options.out) {
outFile = resolve(options.out);
}

const limit = Number(options.limit);
if (Number.isNaN(limit) || limit <= 0 || limit > limitMaxValue) {
program.error(
Expand Down Expand Up @@ -91,7 +98,12 @@ export default (opts: BaseCommandOptions) => {
},
);

const success = handleCheckResult(resp, limit);
const success = await handleCheckResult({
response: resp,
rowLimit: limit,
shouldOutputJson: options.json || !!outFile,
outFile,
});

if (!success && !ignoreErrorsDueToGitHubIntegration) {
process.exitCode = 1;
Expand Down
Loading
Loading