# Architecture Source: https://cosmo-docs.wundergraph.com/architecture High-level architecture of the Cosmo Platform The architecture of the Cosmo Platform is founded on several key principles. We have constructed our platform based on open standards such as Open Telemetry (OTEL), S3, and Prometheus. The Router is fully Open-Source under the Apache 2.0 license. You can fully customize it, e.g., with custom modules. We have designed all of our components with the intention of reducing downtime and preventing service loss. The Router is engineered to function independently, only having one dependency on the CDN to load its configuration, which guarantees an uptime of 99.999%. We have meticulously selected our components to handle even the most demanding use cases. This enables us to efficiently handle billions of requests per month. You have the option to run the entire platform on your own infrastructure, maintaining 100% data sovereignty. Alternatively, you can use [Cosmo Cloud](/deployments-and-hosting/cosmo-cloud) and only run the Router. We will operate the more complex, "stateful" components for you. All components have been engineered to work together in the most efficient manner. Despite the potential limitations this might introduce, we view it as a strategic advantage. This holistic control over the entire stack not only enables us to optimize operations and costs but also significantly enhances the development experience. ### Cosmo Reference Architecture Next, let's take a look at the Reference Architecture, which is also the blueprint of Cosmo Cloud. The Cosmo Platform architecture comprises several integral components. The **Router** efficiently manages traffic and routes requests between clients and Subgraphs, relying solely on the **CDN** to load its configuration. **Studio** provides a user-friendly interface for managing and monitoring services, validating Schema Checks, trying out Queries in the Playground, exploring the Schema or analyzing bottlenecks through metrics and distributed tracing. User authentication and authorization are handled by **Keycloak,** making it easy to integrate with your own Identity Provider through OpenID Connect (OIDC) or SCIM. The **Controlplane** manages the Graphs and their Schema, while the **OTEL Collector** aggregates telemetry data. The **GraphQL Metrics Collector** is responsible for gathering Schema usage information, which is essential to being able to provide composition checks against live traffic. **PostgreSQL** and **Redis** serve as core databases for storing critical data, with **Clickhouse** used for high-performance analytical queries. Together, these components ensure a robust, efficient, and scalable platform. # API Keys Source: https://cosmo-docs.wundergraph.com/cli/api-keys API Keys are required to perform any of the **wgc** CLI commands. To create an API key, follow the steps shown [here](/studio/api-keys). ### Usage ```bash theme={"system"} export COSMO_API_KEY= ``` # Auth Source: https://cosmo-docs.wundergraph.com/cli/auth # Login Source: https://cosmo-docs.wundergraph.com/cli/auth/login Login a user into the Cosmo platform. Supports browser-based authentication. ## Usage ```bash theme={"system"} npx wgc auth login ``` ## Description The `npx wgc auth login` command allows you to login as a user into the Cosmo platform. You will be prompted to select the organization if you are part of multiple organizations. # Logout Source: https://cosmo-docs.wundergraph.com/cli/auth/logout Logout a user from the Cosmo platform. ## Usage ```bash theme={"system"} npx wgc auth logout ``` ## Description The `npx wgc auth logout` command allows you to logout from the Cosmo platform. # Whoami Source: https://cosmo-docs.wundergraph.com/cli/auth/whoami Displays the identity currently authenticated and in use. ## Usage ```bash theme={"system"} npx wgc auth whoami ``` ## Description The `npx wgc auth whoami` command allows you to figure out who is currently authenticated with the controlplane. It displays the organization and controlplane URL. ### Options * `-j, --json` : Output the information in JSON format. # Clients Source: https://cosmo-docs.wundergraph.com/cli/clients Manage registered GraphQL clients for persisted operations # Delete Source: https://cosmo-docs.wundergraph.com/cli/clients/delete Delete a registered GraphQL client from a federated graph or monograph ## Usage ```bash theme={"system"} npx wgc clients delete --graph-name ``` ## Description The `npx wgc clients delete` command deletes a registered GraphQL client from a federated graph or monograph. If the client has persisted operations or persisted operation traffic, the command asks for confirmation. Confirming deletes the client and its related persisted operations. Use `--force` to skip confirmation. Use `--json` to print structured JSON output. ## Parameters * ``: The name of the registered GraphQL client. ## Options * `-g, --graph-name ` : The name of the federated graph or monograph the client belongs to. Required. * `-n, --namespace ` : The namespace of the federated graph or monograph. Defaults to `default`. * `-j, --json` : Prints structured JSON instead of text. * `-f, --force` : Deletes the client without confirmation. Required with `--json` if persisted operations would be deleted or have traffic. ## Examples ```bash theme={"system"} npx wgc clients delete web --graph-name production ``` Deletes the client named `web` from the graph named `production`. ```bash theme={"system"} npx wgc clients delete web --graph-name production --namespace staging --force ``` Deletes the client named `web` from the graph named `production` in the `staging` namespace without prompting. ```bash theme={"system"} npx wgc clients delete web --graph-name production --json --force ``` Deletes the client named `web` and prints JSON output. # List Source: https://cosmo-docs.wundergraph.com/cli/clients/list List registered GraphQL clients of a federated graph or monograph ## Usage ```bash theme={"system"} npx wgc clients list ``` ## Description The `npx wgc clients list` command lists the registered GraphQL clients of a federated graph or monograph. The table output includes the persisted operation count and whether the client has persisted operation traffic in the traffic retention window. Clients are registered when persisted operations are pushed for a given client name. ## Parameters * ``: The name of the federated graph or monograph. ## Options * `-n, --namespace` : The namespace of the federated graph or monograph. Defaults to `default`. * `-j, --json` : Prints structured JSON instead of a table. ## Examples ```bash theme={"system"} npx wgc clients list production ``` Lists all registered clients of the graph named `production`. ```bash theme={"system"} npx wgc clients list production --namespace staging --json ``` Lists all registered clients of the graph named `production` in the `staging` namespace and prints JSON output. # Demo Source: https://cosmo-docs.wundergraph.com/cli/demo Run the interactive Cosmo demo that creates a local federated graph onboarding setup. ## Overview `wgc demo` runs an interactive onboarding flow for a local Cosmo demo environment. Terminal running demo command It is intended for first-time setup. The command prepares a demo federated graph, publishes the required demo plugins, creates a router token, and starts a local router so you can query the graph immediately. ```bash theme={"system"} wgc demo ``` ## Requirements Before you run the command: * Authenticate with the CLI. * Use an organization account that is allowed to run onboarding. The command currently requires organization owner access. * Install Docker and make sure the Docker daemon is running. * Install Docker Buildx. If no `docker-container` builder exists, the command creates one automatically. ## What The Command Does The command prepares a ready-to-use local demo setup for the onboarding flow. It creates or reuses a demo federated graph in the `default` namespace, configures the required demo components, starts a local router on `http://localhost:3002`, and leaves you with a working graph that you can query immediately. If a previous demo setup already exists, you can continue with it or delete it and start over. During execution, the command also prints the path to the local log file so you can inspect router and publishing output if needed. ## Notes `wgc demo` is intentionally guided and uses predefined values. It is meant as a tutorial entry point, not as a general-purpose graph provisioning command. For manual graph management, use the standard CLI commands such as [`wgc federated-graph`](/cli/federated-graph), [`wgc subgraph`](/cli/subgraph), and [`wgc router token`](/cli/router/token). # Essentials Source: https://cosmo-docs.wundergraph.com/cli/essentials Please read through this to have a better understanding of the nuances that take place when executing commands which we will cover in the upcoming pages. ## Namespaces Namespaces are the way to group and isolate graphs in different environments, such as production and staging. For example you can have a federated graph called `my-api` in a production and staging namespace. All graph operations and compositions are scoped to graphs present in a particular namespace. Every organization is provided a `default` namespace which cannot be deleted. You can create additional namespaces with the [namespace](/cli/namespace) CLI. Most of the CLI commands respect a `-n` flag or use `default` respectively. If you delete a namespace all resources within the namespace are deleted. Namespaces have the following restrictions: * Must begin and end with alphanumeric characters * Could contain dashes (-) or underscores (\_) in between. * Special characters other than the above mentioned are not allowed Namespaces allow to create and organize multiple environments. Every federated graph represents physically a router instance and every subgraph is a service connected to the router. ## Monographs vs Federated Graphs ### Federated Graphs Federated Graphs are the goto method of creating graphs in Cosmo. They compose multiple subgraphs into a unified Federated GraphQL schema. ### Monographs Monographs are graphs that do not perform GraphQL Federation. They consist strictly of a single subgraph that is created internally for you. Monograph commands abstract away the complexities with interacting with that subgraph. Everything supported by Federated Graphs is also supported by Monographs. ## Order of execution The order in which you create graphs does not matter. You can either create subgraphs first or federated graphs. Depending on the labels the appropriate subgraphs will be taken into account for composing your federated graphs. ## Labels Labels are a `key=value` pair separated by a `=` sign. Ex: `team=A` `region=us-east-1` You can assign labels to only subgraphs. Labels have the following restrictions * Both key and value must be 63 characters or less (cannot be empty). * Must begin and end with an alphanumeric character (\[a-z0-9A-Z]). * Could contain dashes (-), underscores (\_), dots (.), and alphanumerics between. ## Label Matcher Label matchers are used with Federated Graphs to determine which subgraphs are chosen for composition. They are a set of labels separated by spaces (or the option) and grouped by commas. To understand how they work here is an example. You can create subgraphs and federated graphs without labels and label matchers. In such a case, federated graphs with empty label matchers will only compose subgraphs with empty labels. The vice versa is also true, subgraphs without labels can only be composed by federated graphs with empty label matchers. #### Federated Graph example We create a federated graph from all subgraphs that match the label `Team A` or `Team B` and `Region us-east-1`. This can be expressed in the following way: `--label-matcher team=A,team=B region=us-east-1` the long version is `--label-matcher team=A,team=B --label-matcher region=us-east-1` The above *matcher* translates to logically to `(team=A || team=B) && region=us-east-1` #### Subgraphs example: Assuming we have the following subgraphs: 1\. Products `--label team=A region=us-east-1` 2\. Employees `--label team=B region=us-east-1` 3\. Hobbies `--label team=A` 4\. Users `--label region=us-east-1` Based on the matcher above, this setup will create a federated graph consisting of subgraphs *Products* and *Employees*. *Hobbies* is excluded because it has no `region` label, and *Users* is excluded because it has no `team` label. ## Validate composition While labeling is a powerful concept it can be very error-prone to understand the final result of your composition. For those reasons, we provide the CLI commands * [`wgc federated-graph check`](/cli/federated-graph/check) and * [`wgc subgraph check`](/cli/subgraph/check) That allows you to validate if the composition will produce any errors and what the result will look like at the end. ## Routing Url The routing Url must be specified when creating a federated graph or subgraph. In the case of a federated graph, it points to the Url of your Cosmo router. For subgraphs, it is the service URL that the subgraph will be accessible at. # Feature Flags Source: https://cosmo-docs.wundergraph.com/cli/feature-flags An overview of feature-flag (alias "ff") commands. A feature flag is a group of one or more [feature subgraphs](/cli/feature-subgraph). Each feature subgraph represents a replacement of a specific base subgraph that composes a federated graph. Feature flags define labels that dictate the federated graphs to which they will apply when enabled. Setting the corresponding feature-flag header or cookie value allows different graph constellations to be served to clients. ## Minimum Requirements | Package | Minimum version | | - | - | | [wgc](/cli/intro) | [0.58.0](https://github.com/wundergraph/cosmo/compare/wgc@0.57.7...wgc@0.58.0) | | [router](/router/intro) | [0.95.0](https://github.com/wundergraph/cosmo/releases/tag/router%400.95.0) | # Create Feature Flag Source: https://cosmo-docs.wundergraph.com/cli/feature-flags/create-feature-flag How to create a feature flag. ## Description Create a new feature flag within the specified namespace (or the "default" namespace if unspecified). A feature flag is a group of one or more [feature subgraphs](/cli/feature-subgraph). Each feature subgraph represents a replacement of a specific base subgraph that composes a federated graph. ## Minimum Requirements | Package | Minimum version | | - | - | | [wgc](/cli/intro) | [0.58.0](https://github.com/wundergraph/cosmo/compare/wgc@0.57.7...wgc@0.58.0) | | [router](/router/intro) | [0.95.0](https://github.com/wundergraph/cosmo/releases/tag/router%400.95.0) | ## Usage A feature flag is disabled when created by default. To create and immediately enable a feature flag, include the `--enabled` flag. To enable after creation, see [`wgc ff enable`](/cli/feature-flags/enable-feature-flag). ```bash theme={"system"} wgc feature-flag create my-flag --feature-subgraphs my-graph-one my-graph-two ``` The alias for `feature-flag` is `ff`. Note that unless specified by the `--namespace` parameter, the namespace will be automatically passed as "default". If either the base composition (the Federated Graph with the original Subgraphs) or the Feature Flag composition fail, the Router Config will not be updated with the Feature Flag configuration. ## Parameters * ``: The name of the Feature Flag to create. Must be unique among all feature flags in the specified (otherwise "default") namespace. ## Required Options `--fs, --feature-subgraphs:` A list of names of the feature subgraphs that compose the feature flag. At least one feature subgraph name must be included, and multiple names are space delimited. Including a non-feature subgraph or a feature subgraph that does not exist in the specified (otherwise "default") namespace will produce an error. ## Options * `-n, --namespace` : The namespace of the feature flag (defaults to "default"). Returns an error if the feature flag does not exist in that namespace. * `-e --enabled`: Activates the feature flag immediately upon creation. A new feature flag is disabled by default to prevent accidental compositions. * `--label [labels...]:`The labels to apply to the feature flag. The labels are passed in the format `key=value`, and multiple values are space delimited. * `-j, --json` : Outputs the information in JSON format. ## Example Create the feature flag "my-flag" in the namespace "prod" with multiple feature subgraphs and the labels `team=A` and `team=B`: ```bash theme={"system"} wgc feature-flag create my-flag \ --feature-subgraphs my-graph my-other-graph \ -n prod --label team=A team=B ``` # Delete Feature Flag Source: https://cosmo-docs.wundergraph.com/cli/feature-flags/delete-feature-flag How to delete a feature flag ## Description Deletes an existing feature flag within the specified namespace (or the "default" namespace if unspecified). ## Minimum Requirements | Package | Minimum version | | - | - | | [wgc](/cli/intro) | [0.58.0](https://github.com/wundergraph/cosmo/compare/wgc@0.57.7...wgc@0.58.0) | | [router](/router/intro) | [0.95.0](https://github.com/wundergraph/cosmo/releases/tag/router%400.95.0) | ## Usage If a feature flag is deleted, the feature subgraphs part of the feature flag is not deleted. ```bash theme={"system"} wgc feature-flag delete my-flag ``` The alias for `feature-flag` is `ff`. Note that unless specified by the `--namespace` parameter, the namespace will be automatically passed as "default". ## Parameters * ``: The name of the feature flag to delete. Returns an error if the feature flag does not exist in the specified (otherwise "default") namespace. ## Options * `-n, --namespace` : The namespace of the feature flag (defaults to "default"). Returns an error if the feature flag does not exist in that namespace. * `-f, --force`: An optional flag that allows you to force delete the feature flag without being prompted for confirmation. Use this option if you want to delete the feature flag without additional prompts. ## Examples Enable the existing feature flag "my-flag" in the namespace "prod": ```bash theme={"system"} wgc feature-flag delete my-flag -n prod ``` # Disable Feature Flag Source: https://cosmo-docs.wundergraph.com/cli/feature-flags/disable-feature-flag How to disable a feature flag. ## Description Disable (deactivate) an existing feature flag within the specified namespace (or the "default" namespace if unspecified). A feature flag is a group of one or more [feature subgraphs](/cli/feature-subgraph). Each feature subgraph represents a replacement of a specific base subgraph that composes a federated graph. ## Minimum Requirements | Package | Minimum version | | - | - | | [wgc](/cli/intro) | [0.58.0](https://github.com/wundergraph/cosmo/compare/wgc@0.57.7...wgc@0.58.0) | | [router](/router/intro) | [0.95.0](https://github.com/wundergraph/cosmo/releases/tag/router%400.95.0) | ## Usage If `feature-flag disable` is used when the feature flag is already disabled, no changes (nor errors) will occur. ```bash theme={"system"} wgc feature-flag disable my-flag ``` The alias for `feature-flag` is `ff`. Note that unless specified by the `--namespace` parameter, the namespace will be automatically passed as "default". ## Parameters * ``: The name of the feature flag to disable. Returns an error if the feature flag does not exist in the specified (otherwise "default") namespace. ## Options * `-n, --namespace` : The namespace of the feature flag (defaults to "default"). Returns an error if the feature flag does not exist in that namespace. ## Examples Enable the existing feature flag "my-flag" in the namespace "prod": ```bash theme={"system"} wgc feature-flag disable my-flag -n prod ``` # Enable Feature Flag Source: https://cosmo-docs.wundergraph.com/cli/feature-flags/enable-feature-flag How to enable a feature flag. ## Description Enable (activate) an existing feature flag within the specified namespace (or the "default" namespace if unspecified). A feature flag is a group of one or more [feature subgraphs](/cli/feature-subgraph). Each feature subgraph represents a replacement of a specific base subgraph that composes a federated graph. ## Minimum Requirements | Package | Minimum version | | - | - | | [wgc](/cli/intro) | [0.58.0](https://github.com/wundergraph/cosmo/compare/wgc@0.57.7...wgc@0.58.0) | | [router](/router/intro) | [0.95.0](https://github.com/wundergraph/cosmo/releases/tag/router%400.95.0) | ## Usage If `feature-flag enable` is used when the feature flag is already enabled, no changes (nor errors) will occur. ```bash theme={"system"} wgc feature-flag enable my-flag ``` The alias for `feature-flag` is `ff`. Note that unless specified by the `--namespace` parameter, the namespace will be automatically passed as "default". If either the base composition (the federated graph with the original subgraphs) or the feature flag composition fail, the router execution config will not be updated with the feature flag configuration. ## Parameters * ``: The name of the feature flag to enable. Returns an error if the feature flag does not exist in the specified (otherwise "default") namespace. ## Options * `-n, --namespace` : The namespace of the feature flag (defaults to "default"). Returns an error if the feature flag does not exist in that namespace. ## Examples Enable the existing feature flag "my-flag" in the namespace "prod": ```bash theme={"system"} wgc feature-flag enable my-flag -n prod ``` # Update Feature Flag Source: https://cosmo-docs.wundergraph.com/cli/feature-flags/update-feature-flag How to update a feature flag. ## Description Update an existing feature flag within the specified namespace (or the "default" namespace if unspecified). A feature flag is a group of one or more [feature subgraphs](/cli/feature-subgraph). Each feature subgraph represents a replacement of a specific base subgraph that composes a federated graph. ## Minimum Requirements | Package | Minimum version | | - | - | | [wgc](/cli/intro) | [0.58.0](https://github.com/wundergraph/cosmo/compare/wgc@0.57.7...wgc@0.58.0) | | [router](/router/intro) | [0.95.0](https://github.com/wundergraph/cosmo/releases/tag/router%400.95.0) | ## Usage ```bash theme={"system"} wgc feature-flag update my-flag --feature-subgraphs fs1 fs2 ``` The alias for `feature-flag` is `ff`. Note that unless specified by the `--namespace` parameter, the namespace will be automatically passed as "default". If either the base composition (the federated graph with the original subgraphs) or the feature flag composition fail, the router execution configuration will not be updated with the feature flag configuration. ## Parameters * ``: The name of the existing feature flag to update. Returns an error if the feature flag does not exist in the specified (otherwise "default") namespace. ## Options * `--fs, --feature-subgraphs:` A list of names of the feature subgraphs that compose the feature flag. At least one feature subgraph name must be included, and multiple names are space delimited. Including a non-feature subgraph or a feature subgraph that does not exist in the specified (otherwise "default") namespace will produce an error. Including this option will overwrite the existing list. * `-n, --namespace` : The namespace of the feature flag (defaults to "default"). Returns an error if the feature flag does not exist in that namespace. * `--label [labels...]:`The labels to apply to the feature flag. The labels are passed in the format `key=value`, and multiple values are space delimited. Including this option will overwrite the existing list. * `--unsetlabels:` Removes all existing labels. If the `--label` parameter is also provided, it will be ignored. * `-j, --json` : Output the information in JSON format. ## Example Update the existing feature flag "my-flag" in the namespace "prod" with multiple feature subgraphs and the labels `team=A` and `team=B`: ```bash theme={"system"} wgc feature-flag update my-flag \ --feature-subgraphs my-graph my-other-graph \ -n prod --label team=A team=B ``` # Feature Subgraph Source: https://cosmo-docs.wundergraph.com/cli/feature-subgraph An overview of feature-subgraph (alias "fs") commands. Federated graphs are composed of "base subgraphs". Feature subgraphs represent a replacement (or "override") for a specific base subgraph. A feature subgraph exists only as long as its base subgraph also exists. Creating a feature subgraph does nothing in isolation. It must be added to an enabled [feature flag](/concepts/feature-flags) to be considered by composition. ## Minimum Requirements | Package | Minimum version | | - | - | | [wgc](/cli/intro) | [0.58.0](https://github.com/wundergraph/cosmo/compare/wgc@0.57.7...wgc@0.58.0) | | [router](/router/intro) | [0.95.0](https://github.com/wundergraph/cosmo/releases/tag/router%400.95.0) | # Create Feature Subgraph Source: https://cosmo-docs.wundergraph.com/cli/feature-subgraph/create-feature-subgraph How to create a feature subgraph. ## Description Create a feature subgraph based on an existing subgraph for your federated graph within the specified (otherwise "default") namespace. A feature subgraph is an "override" of an existing subgraph. One or more feature subgraphs are used to compose a [feature flag](/cli/feature-flags). ## Minimum Requirements | Package | Minimum version | | - | - | | [wgc](/cli/intro) | [0.58.0](https://github.com/wundergraph/cosmo/compare/wgc@0.57.7...wgc@0.58.0) | | [router](/router/intro) | [0.95.0](https://github.com/wundergraph/cosmo/releases/tag/router%400.95.0) | ## Usage A feature subgraph does not function in isolation. One or more feature subgraphs must compose a [feature flag](/cli/feature-flags), which itself must be enabled to take effect. ```bash theme={"system"} wgc feature-subgraph create my-feature-subgraph --subgraph my-subgraph --routing-url http://localhost:4000 ``` The alias for `feature-subgraph` is `fs`. Note that unless specified by the `--namespace` parameter, the namespace will be automatically passed as "default". The type of the feature subgraph is determined by the type of the base subgraph. For example, if the base subgraph is a plugin subgraph, the feature subgraph will also be a plugin subgraph. ## Parameters * ``: The name of the feature subgraph to create. Must be unique among all subgraphs and feature subgraphs within the specified (otherwise "default") namespace. ## Required Options If the base subgraph does not exist in the specified (otherwise "default") namespace, the command will fail. `--subgraph`: The name of the existing base subgraph for which the feature subgraph is to be created. ## Options Feature subgraphs do not use labels directly; labels are set by the [feature flag](/cli/feature-flags) that the feature subgraph(s) compose. If the base subgraph is not a plugin subgraph, the routing url is required. * `-r , --routing-url`: Set the URL for the subgraph's data source. This URL defines the endpoint from which the subgraph will fetch data. * `-n, --namespace` : The namespace of the feature subgraph (defaults to "default"). Returns an error if the feature flag does not exist in that namespace. * `--subscription-url:` Use a different URL for subscription requests. If no subscription URL is provided, the router URL is used for subscriptions. * `--subscription-protocol:` Set a protocol to use for subscriptions. The available options are: * `ws` (default): Negotiate an appropriate protocol over websockets. Both `graphql-ws` and `subscription-transport-ws` are supported. * `sse`: Use Server-Sent Events with a GET request. * `sse_post`: Use Server-Sent events with a POST request. ## Examples * Create the feature subgraph "my-feature-subgraph" based on the existing subgraph "my-subgraph" in the namespace "prod". ```bash theme={"system"} wgc feature-subgraph create my-feature-subgraph \ --subgraph my-subgraph \ --namespace prod \ --routing-url http://localhost:4000 ``` # Delete Feature Subgraph Source: https://cosmo-docs.wundergraph.com/cli/feature-subgraph/delete-feature-subgraph How to delete a feature subgraph ## Description Delete a feature subgraph within the specified (otherwise "default") namespace. A feature subgraph is an "override" of an existing subgraph. ## Usage The command to delete the feature subgraph is the same as the subgraph. Please refer to [subgraph delete](/cli/subgraph/delete). # Publish Feature Subgraph Source: https://cosmo-docs.wundergraph.com/cli/feature-subgraph/publish-feature-subgraph How to publish a feature subgraph. ## Description Publish a feature subgraph within the specified (otherwise "default") namespace. A feature subgraph is an "override" of an existing subgraph. ## Usage The command to publish the feature subgraph is the same as the subgraph. Please refer to [subgraph publish](/cli/subgraph/publish). # Update Feature Subgraph Source: https://cosmo-docs.wundergraph.com/cli/feature-subgraph/update-feature-subgraph How to update a feature subgraph ## Description Update a feature subgraph within the specified (otherwise "default") namespace. A feature subgraph is an "override" of an existing subgraph. ## Usage The command to update the feature subgraph is the same as the subgraph. Please refer to [subgraph update](/cli/subgraph/update). Feature subgraph labels cannot be changed. Feature subgraph labels are determined by the feature flag they compose. # Federated Graph Source: https://cosmo-docs.wundergraph.com/cli/federated-graph A federated graph refers to a single, unified data graph that is composed of multiple subgraphs. Before you can interact with a federated graph, you need to [`create`](/cli/federated-graph/create) it. Each federated graph is mapped to a [Cosmo Router](/router/intro) service that can respond to the relevant GraphQL schema. # Changelog Source: https://cosmo-docs.wundergraph.com/cli/federated-graph/changelog Retrieves the changelog for a federated graph ## Usage ```bash theme={"system"} npx wgc federated-graph changelog ``` ## Description The `npx wgc federated-graph changelog` command allows you to retrieve the changelog for a given federated graph. By default it fetches the latest 10 schema versions from the past 3 days and writes to changelog.json file. ## Parameters * ``: The name of the federated graph you want to create. Replace `` with the desired name for your federated graph. ## Options `-n, --namespace` : The namespace of the federated graph (Default: "default"). `-l, --limit`: The number of entries to fetch. Defaults to 10. `-f, --offset`: Used for pagination. Sets the offset from which you want to query. `-s, --start`: The start date in `MM-DD-YY` format. Defaults to 3 days ago from current date. `-e, --end`: The end date in `MM-DD-YY` format. Defaults to today. `-o, --out`: The destination file for the json output. Defaults to `changelog.json` ## Examples ```bash theme={"system"} npx wgc federated-graph changelog production -s 08-15-23 -e 08-31-23 -o changes.json ``` Fetch first 10 changes from 8th August to 31st August for the graph `production` and write it to `changes.json` file. ```bash theme={"system"} npx wgc federated-graph changelog production -s 08-15-23 -e 08-31-23 -l 10 -f 10 -o changes.json ``` Fetch the next 10 changes (after the ones in the previous example) from 8th August to 31st August for the graph `production` and write it to `changes.json` file. ## Sample output ```json theme={"system"} [ { "createdAt": "Fri Sep 15 2023 21:25:26 GMT+0530 (India Standard Time)", "schemaVersionId": "4f46116d-b307-4bf4-8d24-1974e794819d", "changelogs": [ { "id": "2b1db820-6f93-42ac-80a2-b0f5a8d765f3", "path": "ProductNames", "changeType": "TYPE_ADDED", "changeMessage": "Type 'ProductNames' was added", "createdAt": "Fri Sep 15 2023 21:25:26 GMT+0530 (India Standard Time)" }, { "id": "0aaf1f49-2fb9-4528-85e4-f4b4b3c671ae", "path": "Employee.products", "changeType": "FIELD_ADDED", "changeMessage": "Field 'products' was added to object type 'Employee'", "createdAt": "Fri Sep 15 2023 21:25:26 GMT+0530 (India Standard Time)" } ] }, ..more versions ] ``` # Check Source: https://cosmo-docs.wundergraph.com/cli/federated-graph/check Checks for composition errors and presents a list of subgraphs that constitute the new federated graph. ## Usage ```bash theme={"system"} npx wgc federated-graph check --label-matcher ``` ## Description The `npx wgc federated-graph check` command allows you to check for composition errors for the new labels provided. The subgraphs which match the labels will be federated and the errors, if they exist will be displayed to the user. This check can be performed without updating the labels of the federated graph. ## Parameters * ``: The name of the federated graph you want to check for composition errors. Replace `` with the name of the federated graph. ## Options * `-n, --namespace` : The namespace of the federated graph (Default: "default"). * `--label-matcher ` : The label matchers to the federated graph with which the check is to be performed The labels used to select the subgraphs to be federated. Labels are passed in the format `= =`, where each `=` pair represents a label key and its corresponding value. The federated graph will include the subgraphs that match the updated labels. * `--suppress-warnings`: This flag suppresses any warnings produced by composition. ## Examples ```bash theme={"system"} npx wgc federated-graph check production --label-matcher team=B department=Engineering ``` Checks the federated graph named "production" for composition errors by composing the subgraphs that match the labels "team=B" or "department=Engineering". ```bash theme={"system"} npx wgc federated-graph check production --label-matcher team=B --label-matcher department=Engineering ``` Checks the federated graph named "production" for composition errors by composing the subgraphs that match the labels "team=B" and "department=Engineering". # Create Source: https://cosmo-docs.wundergraph.com/cli/federated-graph/create Creates a federated graph on the control plane. ## Usage ```bash theme={"system"} npx wgc federated-graph create -r --label-matcher ``` ## Description The `npx wgc federated-graph create` command allows you to create a new federated graph on the Cosmo platform's control plane. Federated graphs provide a mechanism to combine multiple subgraphs into a unified schema, enabling efficient, scalable, and distributed GraphQL APIs. With this command, you can create a federated graph and specify the routing URL for your router and the labels used to select the subgraphs to be federated. ## Parameters * ``: The name of the federated graph you want to create. Replace `` with the desired name for your federated graph. ## Required Options `-r , --routing-url`: The routing URL of your router. This URL defines the endpoint where the router will be accessible. The federated graph will be accessible through this router. `--label-matcher `: The labels used to select the subgraphs to be federated. Labels are passed in the format `= =`, where each `=` pair represents a label key and its corresponding value. The federated graph will include the subgraphs that match the specified labels. `--readme`: The path to the markdown file which describes the federated graph. The readme can be used to communicate the information of the federated graph to other team members. ## Options * `-n, --namespace` : The namespace of the federated graph (Default: "default"). * `-r, --routing-url` :The routing url of your router. This is the url that the router will be accessible at. * `--admission-webhook-url ` the base url of the admission webhook. This is the url that the controlplane will use to implement admission control for the federated graph. Example: `https://admission.example.com` (without the `/validate-config` path name) * `--admission-webhook-secret`: Allows you to sign requests (HMAC) made to your admission webhook url. The header containing this signature is `X-Cosmo-Signature-256` * `--label-matcher [labels...]` : The label matcher is used to select the subgraphs to federate. The labels are passed in the format = =. They are separated by spaces and grouped using comma. Example: --label-matcher team=A,team=B env=prod * `--readme` : The markdown file which describes the federated graph. * `--suppress-warnings`: This flag suppresses any warnings produced by composition. ## Examples ```bash theme={"system"} npx wgc federated-graph create production -r http://router.example.com/graphql --label-matcher team=A department=backend ``` Create a federated graph named "production" with a routing URL of "[http://router.example.com/graphql](http://router.example.com/graphql)" and federate subgraphs with labels `team=A` and `department=backend`. ## Notes * The `npx wgc federated-graph create` command interacts with the Cosmo platform's control plane to create the specified federated graph. * The routing URL of the router should be accessible by the federated graph to handle incoming queries and route them to the appropriate subgraphs. # Delete Source: https://cosmo-docs.wundergraph.com/cli/federated-graph/delete Deletes a federated graph on the control plane. ## Usage ```bash theme={"system"} npx wgc federated-graph delete [-f, --force] ``` **Delete** is an irreversible action. It will delete the entire federated graph, including versions, schema checks, etc. It will not delete the associated subgraphs. Contract Graph behavior: Deleting a federated grpah will delete all associated contract graphs. Deleting a contract graph has no effect on the source federated graph. ## Description The `npx wgc federated-graph delete` command allows you to delete a federated graph on the Cosmo platform's control plane. Deleting a federated graph will remove its configuration and associated resources. Use this command with caution, as the action cannot be undone. ## Parameters * ``: The name of the federated graph you want to delete. Replace `` with the name of the federated graph you wish to remove. ## Options `-n, --namespace` : The namespace of the federated graph (Default: "default"). ```bash theme={"system"} -f, --force ``` An optional flag that allows you to force delete the federated graph without being prompted for confirmation. Use this option if you want to delete the federated graph without additional prompts. ## Examples ```bash theme={"system"} npx wgc federated-graph delete production ``` Delete the federated graph named "production". ```bash theme={"system"} npx wgc federated-graph delete production -f ``` Force delete the federated graph named "production" without confirmation. ## Notes * The `npx wgc federated-graph delete` command interacts with the Cosmo platform's control plane to delete the specified federated graph. Ensure that you have the necessary permissions to perform this operation. * When using the `--force` option, the command will not prompt for confirmation, so exercise caution to prevent accidental deletions. # Fetch Source: https://cosmo-docs.wundergraph.com/cli/federated-graph/fetch Fetches the latest valid SDL of a federated graph and all its subgraphs and the latest valid router config of a federated graph. ## Usage ```bash theme={"system"} npx wgc federated-graph fetch ``` ## Description The `npx wgc federated-graph fetch` command allows you to download the latest valid Schema Definition Language (SDL) of a federated graph and all its subgraphs and the latest valid router config of a federated graph from the Cosmo platform's control plane. The fetched SDL represents the unified schema of the federated graph. You can use this command to retrieve the SDL. ## Parameters * ``: The name of the federated graph you want to fetch. Replace `` with the name of the federated graph you wish to retrieve the SDL for. ## Options * `-n, --namespace` : The namespace of the federated graph (Default: "default"). * `-o, --out` : Destination folder for the SDL of the federated graph and its subgraphs. * `-a, --apollo-compatibility` : Enable Apollo compatibility to generate the composition configs and script to generate schema using rover. * `-v, --federation-version`: The version of federation to be used by rover in the format "1", "2", or "2.x.y". Default is 2.5.0. ## Apollo Compatibility This mode will help smooth migration from the Apollo router to the WunderGraph Cosmo router. Initially, the users can use the schema registry from Cosmo and use this mode to update their routers/gateways. Later they can move from Apollo Router/Gateway to WunderGraph Router. Diagram showing Cosmo Schema Registry and WGC CLI generating an Apollo-compatible supergraph for the Apollo Router/Gateway, updated via webhook on schema change. ## Output The output of this command is stored in the structure mentioned below * **\-\: **The top-level folder which contains 2 folders, subgraphs and supergraphs. * **subgraphs** folder: This folder contains the files of all the subgraph's SDLs. * **supergraph** folder: This folder contains the SDL, router config of the federated graph. * cosmoSchema.graphql - The SDL of the federated graph. * cosmoConfig.json - The router config of the federated graph. * **cosmo-composition.yaml: **The Cosmo federated graph configuration file includes configuration options for each of your subgraphs. This file can be used to generate the router config using the [compose](/cli/router/compose) command. If **Apollo-compatibility mode** is enabled, the output will contain a few more folders/files, they are as follows:- * **rover-composition.yaml: **The Apollo supergraph configuration file includes configuration options for each of your subgraphs. * **scripts **folder * apollo.sh - This script is used to generate the supergraph schema using rover, and the generated file would be in the **supergraph** folder and the name of the file would be '**apolloSchema.graphql**'. ## Examples ```bash theme={"system"} npx wgc federated-graph fetch production ``` Fetches the latest valid SDL and router config of the federated graph named "production" and SDL of all its subgraphs. ```bash theme={"system"} npx wgc federated-graph fetch production --apollo-compatibility -v 2.6.1 ``` Fetches the latest valid SDL and router config of the federated graph named "production" and SDL of all its subgraphs. As Apollo compatibility mode is enabled, it generates the extra files mentioned above. Using the `-v` option, pass the version of the federation used by the rover, if not provided it falls back to "2.5.0". # Fetch-Schema Source: https://cosmo-docs.wundergraph.com/cli/federated-graph/fetch-schema Fetches the latest valid SDL of a federated graph. The output can be piped to a file. This is primarily used for debugging purposes ## Usage ```bash theme={"system"} npx wgc federated-graph fetch-schema ``` ## Description The `npx wgc federated-graph fetch-schema` command allows you to fetch the latest valid Schema Definition Language (SDL) of a federated graph from the Cosmo platform's control plane. You can use this command to retrieve the SDL and, if needed, pipe the output to a file. By default, the output schema is set to the **Router Schema**. To use the **Client Schema** instead, specify the `-c` or `--client-schema` flag to the command. ## Parameters * ``: The name of the federated graph you want to fetch. Replace `` with the name of the federated graph you wish to retrieve the SDL for. ## Options * `-n, --namespace` : The namespace of the federated graph (Default: "default"). * `-o, --out` : Destination file for the SDL. Prints to standard output if not provided. * `-c, --client-schema`: Output the Client Schema instead of the default Router Schema. ## Examples ```bash theme={"system"} npx wgc federated-graph fetch-schema production ``` Fetch the latest valid SDL of the federated graph named "production." ```bash theme={"system"} npx wgc federated-graph fetch-schema production -o production-schema.graphql ``` Fetch the latest valid SDL of the federated graph named "production" and save it to a file named "production-schema.graphql." ```bash theme={"system"} npx wgc federated-graph fetch-schema production --client-schema ``` Fetch the latest valid client SDL of the federated graph named "production". ## Notes * The `npx wgc federated-graph fetch-schema` command interacts with the Cosmo platform's control plane to fetch the latest valid SDL of the specified federated graph. Ensure that you have the necessary permissions to perform this operation. # List Source: https://cosmo-docs.wundergraph.com/cli/federated-graph/list Lists all the federated graphs. ## Usage ```bash theme={"system"} npx wgc federated-graph list ``` ## Description The `npx wgc federated-graph list` command allows you to list all the federated graphs under your organization. ## Options * `-n, --namespace` : Filter to get graphs in this namespace only. * `-r, --raw` : Prints to the console in json format instead of table (Deprecated). * `-j, --json` : Prints to the console in json format instead of table. * `-o, --out` : Destination file for the json output. Has precedence over both `raw` and `json` * `--only-contracts` : Filter to list only contracts # Move Source: https://cosmo-docs.wundergraph.com/cli/federated-graph/move ## Usage ```bash theme={"system"} npx wgc federated-graph move -n fromNS -t toNS ``` Moving a federated graph will result in a new graph composition but only subgraphs from the target namespace are respected. ## Description The `npx wgc federated-graph move` command allows you to move a federated-graph into a different namespace. ## Parameters * ``: The name of the federated-graph you want to move. ## Options * `-n, --namespace` : The namespace of the federated-graph. * `-t, --to`: The new namespace of the federated-graph. * `--suppress-warnings`: This flag suppresses any warnings produced by composition. ## Examples * Moves the federated-graph named "mygraph" into the "production" namespace. ```bash theme={"system"} npx wgc subgraph move mygraph -n default -t production ``` # Update Source: https://cosmo-docs.wundergraph.com/cli/federated-graph/update Updates a federated graph on the control plane. ## Usage ```bash theme={"system"} npx wgc federated-graph update [-r, --routing-url ] [--label-matcher ] [--readme ] ``` **Update** is an irreversible action. However, the change will only be visible to the routers once the composition has been successful. Until then, the routers will operate with the most recent valid composition. Please use [federated-graph check](/cli/federated-graph/check) to understand the impact of your change. ## Description The `npx wgc federated-graph update` command allows you to update an existing federated graph on the Cosmo platform's control plane. With this command, you can modify the routing URL of your router and update the labels used to select the subgraphs to be federated. ## Parameters * ``: The name of the federated graph you want to update. Replace `` with the name of the federated graph you wish to modify. ## Options * `-n, --namespace` : The namespace of the federated graph (Default: "default"). * `-r , --routing-url` : The updated routing URL of your router. This URL defines the endpoint where the router will be accessible. The federated graph will be accessible through this updated router URL. * `--label-matcher `: The updated labels used to select the subgraphs to be federated. Labels are passed in the format `= =`, where each `=` pair represents a label key and its corresponding value. The federated graph will include the subgraphs that match the updated labels. * `--unset-label-matcher`: This will remove all label matchers. It will not add new label matchers if both this and --label-matchers option is passed. * `--admission-webhook-url ` the base url of the admission webhook. This is the url that the controlplane will use to implement admission control for the federated graph. Example: `https://admission.example.com` (without the `/validate-config` path name) * `--admission-webhook-secret`: Allows you to sign requests (HMAC) made to your admission webhook url. The header containing this signature is `X-Cosmo-Signature-256` * `--readme ` : The path to the markdown file which describes the federated graph. The readme can be used to communicate the information of the federated graph to other team members. * `--suppress-warnings`: This flag suppresses any warnings produced by composition. ## Examples ```bash theme={"system"} npx wgc federated-graph update production -r http://new-router.example.com/graphql --selector team=B department=Engineering ``` Update the federated graph named "production" with an updated routing URL of "[http://new-router.example.com/graphql](http://new-router.example.com/graphql)" and update the labels to select subgraphs with "team=B" and "department=Engineering". ## Notes * The `npx wgc federated-graph update` command interacts with the Cosmo platform's control plane to update the specified federated graph. Ensure that you have the necessary permissions to perform this operation. * If you want to update both the routing URL and labels, you can combine the options in a single command as demonstrated in the examples. # Version Source: https://cosmo-docs.wundergraph.com/cli/federated-graph/version # Get Source: https://cosmo-docs.wundergraph.com/cli/federated-graph/version/get Retrieves and displays the router compatibility version that has been set for a specific federated graph. ## Requirements | Package | Minimum version | | - | - | | [wgc](/cli/intro) | [0.74.0](https://github.com/wundergraph/cosmo/releases/tag/wgc%400.74.0) | ## Usage ```bash theme={"system"} npx wgc federated-graph version get ``` ## Description The `wgc federated-graph version get` command retrieves and displays the router compatibility version that has been set for a specific federated graph. ## Output The router compatibility version that has been set for the federated graph. ## Example ```bash theme={"system"} > npx wgc federated-graph version get mygraph -n prod ┌────────────┬───────────┬─────────┐ │ GRAPH NAME │ NAMESPACE │ VERSION │ ├────────────┼───────────┼─────────┤ │ mygraph │ prod │ 1 │ └────────────┴───────────┴─────────┘ ``` # Set Source: https://cosmo-docs.wundergraph.com/cli/federated-graph/version/set Sets the router compatibility version for a federated graph. Currently, there is only one router compatibility version. Consequently, this command does not yet serve a meaningful function (but will in the near future). ## Requirements | Package | Minimum version | | - | - | | [wgc](/cli/intro) | [0.74.0](https://github.com/wundergraph/cosmo/releases/tag/wgc%400.74.0) | ## Usage ```bash theme={"system"} npx wgc federated-graph version set --version ``` ## Arguments | Description | Type | | - | - | | The name of the federated graph. | string | ## Options | Option | Type | Value | Required | Default value | | - | - | - | - | - | | `--version/-v` | string | The router compatibility version to be set. | true | n/a | | `--namespace/-n` | string | The namespace where the federated graph exists. | false | "default" | ## Description The `wgc federated-graph version set` command allows a [valid router compatibility version](/cli/router/compatibility-version/list) to be set for a federated graph. ## Output If successful, a table will display the graph name, its namespace, the previous router compatibility version, and the current router compatibility version. ## Example ```bash theme={"system"} npx wgc federated-graph version set mygraph -v 1 ✔ Successfully set the router compatibility version for federated graph "prod" to 1. ┌────────────┬───────────┬──────────────────┬─────────────┐ │ GRAPH NAME │ NAMESPACE │ PREVIOUS VERSION │ NEW VERSION │ ├────────────┼───────────┼──────────────────┼─────────────┤ │ prod │ default │ 2 │ 1 │ └────────────┴───────────┴──────────────────┴─────────────┘ ``` # gRPC Services Source: https://cosmo-docs.wundergraph.com/cli/grpc-service Commands for working with gRPC services for the Cosmo Router WunderGraph Cosmo CLI includes commands for working with gRPC services for the Cosmo Router. Scaffold a new gRPC service project from a template List all available gRPC service templates for the init command Generate a protobuf definition and mapping file for a gRPC service from a GraphQL schema Create a federated gRPC subgraph on the control plane Publish a gRPC subgraph schema to the control plane Delete a gRPC subgraph from the control plane For detailed documentation about gRPC services and how they work, see the [Router gRPC Services](/router/gRPC/grpc-services) documentation. # Create Source: https://cosmo-docs.wundergraph.com/cli/grpc-service/create Creates a federated gRPC subgraph on the control plane. ## Usage A gRPC subgraph name must be unique within a namespace. ```bash theme={"system"} wgc grpc-service create -r [options] ``` After creating a gRPC subgraph, you can publish it with [wgc grpc-service publish](/cli/grpc-service/publish). ## Description The `wgc grpc-service create` command allows you to create a new gRPC subgraph within the Cosmo platform. The `` argument specifies the name of the new gRPC subgraph. This establishes the subgraph metadata and routing configuration without publishing any schema. ## Parameters * ``: The name of the gRPC subgraph you want to create. It is used to uniquely identify your gRPC subgraph. ## Options * `-r, --routing-url `: The routing URL of your subgraph. This is the gRPC endpoint where requests will be directed, and must follow the format from the gRPC protocol ([https://grpc.github.io/grpc/core/md\_doc\_naming.html](https://grpc.github.io/grpc/core/md_doc_naming.html)). * `-n, --namespace [string]`: The namespace of the gRPC subgraph (Default: "default"). * `--label [labels...]`: Assign multiple labels to the new gRPC subgraph. Labels are used to categorize and organize subgraphs based on specific criteria (e.g., team, department, project). The labels are passed in the format `=`. * Example: `--label team=backend` * `--readme `: The path to the markdown file which describes the gRPC subgraph. ## Examples * Create a new gRPC subgraph named "users-service" with a routing URL: ```bash theme={"system"} wgc grpc-service create users-service -r dns:///localhost:4001/ ``` * Create a new gRPC subgraph with labels: ```bash theme={"system"} wgc grpc-service create users-service -r dns:///localhost:4001/ --label team=backend ``` * Create a new gRPC subgraph with a readme file: ```bash theme={"system"} wgc grpc-service create users-service -r dns:///localhost:4001/ --readme ./service-readme.md ``` * Create a gRPC subgraph in a specific namespace: ```bash theme={"system"} wgc grpc-service create users-service -r dns:///localhost:4001/ --namespace production ``` ## Notes * The `wgc grpc-service create` command interacts with the Cosmo platform's control plane to create the specified gRPC subgraph. * The routing URL must be accessible from your router instances when you later publish the subgraph schema. * The readme file will be displayed in the Studio for documentation purposes. * After creating the subgraph, you'll need to use `wgc grpc-service publish` to publish your schema. # Delete Source: https://cosmo-docs.wundergraph.com/cli/grpc-service/delete Deletes a gRPC subgraph on the control plane. The gRPC subgraph will be deleted from all federated graphs. ## Usage ```bash theme={"system"} wgc grpc-service delete [-f, --force] ``` **Delete** is an irreversible action. However, the change will only be visible to the routers once the composition has been successful. Until then, the routers will operate with the most recent valid composition. Please use [subgraph check](/cli/subgraph/check) to understand the impact of your change. ## Description The `wgc grpc-service delete` command allows you to delete a gRPC subgraph on the Cosmo platform's control plane. When you delete a gRPC subgraph, all associated data and configurations will be permanently removed. Use this command with caution, as the action cannot be undone. ## Parameters * ``: The name of the gRPC subgraph you want to delete. This should be the exact name of the gRPC subgraph you wish to remove. ## Options * `-n, --namespace [string]`: The namespace of the gRPC subgraph (Default: "default"). * `-f, --force`: An optional flag that allows you to force delete the gRPC subgraph without being prompted for confirmation. Use this option if you want to delete the gRPC subgraph without additional prompts. * `--suppress-warnings`: This flag suppresses any warnings produced by composition. ## Examples 1. Delete the gRPC subgraph named "users-service": ```bash theme={"system"} wgc grpc-service delete users-service ``` 2. Force delete the gRPC subgraph named "users-service" without confirmation: ```bash theme={"system"} wgc grpc-service delete users-service -f ``` 3. Delete a gRPC subgraph in a specific namespace: ```bash theme={"system"} wgc grpc-service delete users-service -n production ``` ## Notes * The `wgc grpc-service delete` command interacts with the Cosmo platform's control plane to delete the specified gRPC subgraph. * When using the `--force` option, the command will not prompt for confirmation, so exercise caution to prevent accidental data loss. * If composition errors occur during deletion, the gRPC subgraph will still be deleted, but the router will continue to work with the latest valid schema until the composition issues are resolved. # Generate Source: https://cosmo-docs.wundergraph.com/cli/grpc-service/generate Generate a protobuf definition for a gRPC service from a GraphQL schema # wgc grpc-service generate The `generate` command generates a protobuf definition and mapping file for a gRPC service from a GraphQL schema, which can be used to implement a gRPC service and can be used for the composition. ## Usage ```bash theme={"system"} wgc grpc-service generate [options] [service-name] ``` ## Arguments | Argument | Description | Default | | - | - | - | | `service-name` | Name of the gRPC service | `service.v1` | ## Options | Option | Description | Default | | - | - | - | | `-i, --input ` | The GraphQL schema file to generate a protobuf schema from | Required | | `-o, --output ` | The output directory for the protobuf schema | `.` | | `-p, --package-name ` | The name of the proto package | `service.v1` | | `-g, --go-package ` | Adds an `option go_package` to the proto file | None | ## Description This command generates a protobuf definition for a gRPC service from a GraphQL schema. ## Examples ### Generate a protobuf definition for a gRPC service from a GraphQL schema ```bash theme={"system"} wgc grpc-service generate -i ./schema.graphql -o ./service MyService ``` ### Define a custom package name ```bash theme={"system"} wgc grpc-service generate -i ./schema.graphql -o ./service MyService --package-name my.custom.package ``` ### Define a custom go package name ```bash theme={"system"} wgc grpc-service generate -i ./schema.graphql -o ./service MyService --go-package github.com/wundergraph/cosmo/service/my-service ``` ## Output The command generates multiple files in the output directory: * `service.proto`: The protobuf definition for the gRPC service * `service.mapping.json`: The mapping file for the gRPC service * `service.proto.lock.json`: The lock file for the protobuf definition The generated protobuf definition can be used to implement a gRPC service in any language that supports protobuf. The mapping and the protobuf definition is needed for the composition part. See also: [gRPC Services](/router/gRPC/grpc-services) · [GraphQL Support for gRPC Integration](/router/gRPC/graphql-support) # Init Source: https://cosmo-docs.wundergraph.com/cli/grpc-service/init Scaffold a new gRPC service project from a template The `init` command scaffolds a new gRPC service project from a template, downloading and extracting the template from the [wundergraph/cosmo-templates](https://github.com/wundergraph/cosmo-templates) repository. ## Usage ```bash theme={"system"} wgc grpc-service init [options] ``` ## Options | Option | Description | Default | | - | - | - | | `-t, --template