-
Notifications
You must be signed in to change notification settings - Fork 94
/
Copy pathlist.rs
46 lines (38 loc) · 1.34 KB
/
list.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
use serde::Serialize;
use structopt::StructOpt;
use rover_client::query::subgraph::list;
use crate::client::StudioClientConfig;
use crate::command::RoverStdout;
use crate::utils::parsers::{parse_graph_ref, GraphRef};
use crate::Result;
#[derive(Debug, Serialize, StructOpt)]
pub struct List {
/// <NAME>@<VARIANT> of graph in Apollo Studio to list subgraphs from.
/// @<VARIANT> may be left off, defaulting to @current
#[structopt(name = "GRAPH_REF", parse(try_from_str = parse_graph_ref))]
#[serde(skip_serializing)]
graph: GraphRef,
/// Name of configuration profile to use
#[structopt(long = "profile", default_value = "default")]
#[serde(skip_serializing)]
profile_name: String,
}
impl List {
pub fn run(&self, client_config: StudioClientConfig) -> Result<RoverStdout> {
let client = client_config.get_client(&self.profile_name)?;
tracing::info!(
"Listing subgraphs for {}@{}, mx. {}!",
&self.graph.name,
&self.graph.variant,
&self.profile_name
);
let list_details = list::run(
list::list_subgraphs_query::Variables {
graph_id: self.graph.name.clone(),
variant: self.graph.variant.clone(),
},
&client,
)?;
Ok(RoverStdout::SubgraphList(list_details))
}
}