Publish - WunderGraph

Usage

npx wgc subgraph publish [subgraphName] --schema [schemaFilePath]

Publish 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 to understand the impact of your change.

Description

The npx wgc subgraph publish command enables you to publish a specific subgraph to the Cosmo platform. Publishing a subgraph makes it available for consumption by other services or applications, allowing them to send GraphQL queries and retrieve data from your subgraph. The [subgraphName] argument specifies the name of the subgraph you want to publish, while the --schema option defines the path to the GraphQL schema file that contains your subgraph’s schema definition.

A previously created Event-Driven Graph (EDG) cannot be changed into a regular subgraph. Similarly, a regular subgraph cannot be changed into an EDG. Attempting to do either of these actions will result in an error.

If you want to publish a plugin subgraph, you must use the router plugin publish command instead.

Parameters

Options

If the subgraph has already been created previously, the routing-url, label, subscription-url,subscription-protocol, and websocket-subprotocol parameters will be ignored. Use subgraph update to update these values. If creating an Event-Driven Graph with subgraph publish, providing any of routing-url, subscription-url,subscription-protocol, or websocket-subprotocol will produce an error.

If you are creating a subgraph for the first time with subgraph publish, the routing-url parameter is required for non-Event-Driven Graphs. If you are not creating a subgraph for the first time, the routing-url parameter will be ignored. To update the routing URL of an existing subgraph, use subgraph update.

If you are creating a subgraph for the first time with subgraph publish, the label parameter can be used to set labels. Note that a subgraph will only be considered for a federated graph composition if the subgraph’s labels match the labels matcher of that federated graph. If you are not creating a subgraph for the first time, the label parameter will be ignored. To update the labels of an existing subgraph, use subgraph update.

If you are creating a subgraph for the first time with subgraph publish, the subscription-url parameter can be used to set the subscription URL. If you are not creating a subgraph for the first time, the subscription-url parameter will be ignored. To update the subscription URL of an existing subgraph, use subgraph update.

If you are creating a subgraph for the first time with subgraph publish, the subscription-protocol parameter can be used to set the subscription protocol. If you are not creating a subgraph for the first time, the subscription-protocol parameter will be ignored. To update the subscription protocol of an existing subgraph, use subgraph update.

If you are creating a subgraph for the first time with subgraph publish, the websocket-subprotocol parameter can be used to set the websocket subprotocol. If you are not creating a subgraph for the first time, the websocket-subprotocol parameter will be ignored. To update the websocket subprotocol of an existing subgraph, use subgraph update.

Example

Publish a schema to an existing subgraph.

npx wgc subgraph publish products --schema ../demo/subgraphs/products/products.graphql

Create a subgraph and publish a schema in one command

npx wgc subgraph publish products --schema ../demo/subgraphs/products/products.graphql --routing-url http://localhost:4001/graphql --label=team=A

Notes