Skip to content

Commit

Permalink
Add subgraph push option to specify endpoint (#130)
Browse files Browse the repository at this point in the history
  • Loading branch information
JakeDawkins authored and lrlna committed Jan 26, 2021
1 parent 8d165c6 commit 1de38c7
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 5 deletions.
25 changes: 21 additions & 4 deletions docs/source/subgraphs.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,23 @@ a `.graphql` SDL file, you can pass the path to that file as the `--schema` flag
(or `-s` for short):

```bash
rover subgraph push my-graph --schema ./accounts/schema.graphql --service-name accounts
rover subgraph push my-graph\
--schema ./accounts/schema.graphql\
--service-name accounts\
--routing-url https://my-running-service.com/api
```

this will push the schema at ./accounts/schema.graphql to the default (`current`) variant
of `my-graph`. You can specify a different variant by adding the variant name
after the graph name like `my-graph@variant-name`. The `--service-name` flag
just tells the registry which subgraph you're pushing changes to.

The `--routing-url` is used by a gateway running in [managed federation mode]
(https://www.apollographql.com/docs/federation/managed-federation/overview/). If
You're running a service which hasn't been deployed yet or isn't using managed
federation, you may pass a placeholder url or leave the flag empty
(i.e. `--routing-url=""`).

If you're not using an SDL file to build your schema, you'll likely want to
introspect your subgraph to push it. Rover supports accepting `stdin` for the
schema flag just for cases like this. You can use the `stdout` of another
Expand All @@ -70,7 +79,10 @@ any command with a `--schema` flag. To do this, pass `-` as the value for the
> TODO: check this API whenever the introspect command lands
```sh
rover subgraph introspect http://localhost:4001 | rover subgraph push my-graph@dev --schema - --service-name accounts
rover subgraph introspect http://localhost:4001\
| rover subgraph push my-graph@dev\
--schema - --service-name accounts\
--routing-url https://my-running-service.com/api
```

> For more on how `stdin` works, see [Essential Concepts](./essentials#using-stdin).
Expand All @@ -89,10 +101,15 @@ subgraph's service name and schema to check changes for using the same

```bash
# using a schema file
rover subgraph check my-graph --schema ./accounts/schema.graphql --service-name accounts
rover subgraph check my-graph\
--schema ./accounts/schema.graphql\
--service-name accounts

# using introspection
rover subgraph introspect http://localhost:4000 | rover subgraph check my-graph --schema - --service-name accounts
rover subgraph introspect http://localhost:4000\
| rover subgraph check my-graph\
--schema -\
--service-name accounts
```

> TODO: check after introspection lands
Expand Down
8 changes: 7 additions & 1 deletion src/command/subgraph/push.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ pub struct Push {
#[structopt(long)]
#[serde(skip_serializing)]
service_name: String,

/// Url of a running service that a gateway can route operations to
/// (often a deployed service). May be left empty ("") or a placeholder url
/// if not running a gateway in managed federation mode
#[structopt(long)]
routing_url: String,
}

impl Push {
Expand All @@ -58,7 +64,7 @@ impl Push {
hash: None,
},
revision: "".to_string(),
url: "".to_string(),
url: self.routing_url.clone(),
},
&client,
)
Expand Down

0 comments on commit 1de38c7

Please sign in to comment.