Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wip: initial commit for rover subgraph dev #1185

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
320 changes: 253 additions & 67 deletions Cargo.lock

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ timber = { path = "./crates/timber" }

# git dependencies
billboard = { git = "https://github.com/EverlastingBugstopper/billboard.git", branch = "main" }
saucer = { git = "https://github.com/EverlastingBugstopper/awc.git", branch = "main" }
# saucer = { path = "../awc/saucer" }
# saucer = { git = "https://github.com/EverlastingBugstopper/awc.git", branch = "main" }
saucer = { path = "../awc/saucer" }

# crates.io dependencies
ansi_term = "0.12"
Expand All @@ -74,6 +74,7 @@ dialoguer = "0.10"
heck = "0.4"
humantime = "2.1.0"
lazycell = "1"
notify = "4"
opener = "0.5"
os_info = "3.4"
prettytable-rs = "0.8"
Expand Down
11 changes: 11 additions & 0 deletions crates/rover-client/src/shared/graph_ref.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,17 @@ pub struct GraphRef {
pub variant: String,
}

impl GraphRef {
pub fn new(name: String, variant: Option<String>) -> Result<Self, RoverClientError> {
let mut s = name;
if let Some(variant) = variant {
s.push('@');
s.push_str(&variant);
};
Ok(Self::from_str(&s)?)
}
}

impl fmt::Display for GraphRef {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}@{}", self.name, self.variant)
Expand Down
14 changes: 11 additions & 3 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,9 @@ impl Rover {

match &self.command {
Command::Config(command) => command.run(self.get_client_config()?),
Command::Dev(command) => {
command.run(self.get_install_override_path()?, self.get_client_config()?)
}
Command::Fed2(command) => command.run(self.get_client_config()?),
Command::Supergraph(command) => {
command.run(self.get_install_override_path()?, self.get_client_config()?)
Expand All @@ -190,9 +193,11 @@ impl Rover {
command.run(self.get_client_config()?, self.get_git_context()?)
}
Command::Readme(command) => command.run(self.get_client_config()?),
Command::Subgraph(command) => {
command.run(self.get_client_config()?, self.get_git_context()?)
}
Command::Subgraph(command) => command.run(
self.get_install_override_path().ok().flatten(),
self.get_client_config()?,
self.get_git_context()?,
),
Command::Update(command) => {
command.run(self.get_rover_config()?, self.get_reqwest_client())
}
Expand Down Expand Up @@ -303,6 +308,9 @@ pub enum Command {
/// Configuration profile commands
Config(command::Config),

/// Develop a GraphQL API
Dev(command::Dev),

/// (deprecated) Federation 2 Alpha commands
#[clap(setting(AppSettings::Hidden))]
Fed2(command::Fed2),
Expand Down
2 changes: 1 addition & 1 deletion src/command/config/whoami.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ pub struct WhoAmI {

impl WhoAmI {
pub fn run(&self, client_config: StudioClientConfig) -> Result<RoverOutput> {
let client = client_config.get_authenticated_client(&self.profile.profile_name)?;
let client = client_config.get_authenticated_client(&self.profile)?;
eprintln!("Checking identity of your API key against the registry.");

let identity = who_am_i::run(ConfigWhoAmIInput {}, &client)?;
Expand Down
42 changes: 42 additions & 0 deletions src/command/dev.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
use crate::command::subgraph::{Dev as SubgraphDev, SubgraphDevOpts};
use crate::command::{subgraph, RoverOutput};
use crate::utils::client::StudioClientConfig;
use crate::{Result, PKG_VERSION};
use saucer::{clap, ArgEnum, Parser, Utf8PathBuf};

use calm_io::stderrln;
use serde::Serialize;
use std::env;

#[derive(Debug, Serialize, Clone, Parser)]
pub struct Dev {
#[clap(flatten)]
opts: SubgraphDevOpts,
}

impl Dev {
#[cfg(feature = "composition-js")]
pub fn run(
&self,
override_install_path: Option<Utf8PathBuf>,
client_config: StudioClientConfig,
) -> Result<RoverOutput> {
// TODO: ensure project is subgraph type before running
SubgraphDev {
opts: self.opts.clone(),
}
.run(override_install_path, client_config)
}

#[cfg(not(feature = "composition-js"))]
pub fn run(
&self,
override_install_path: Option<Utf8PathBuf>,
client_config: StudioClientConfig,
) -> Result<RoverOutput> {
SubgraphDev {
opts: self.opts.clone(),
}
.run(override_install_path, client_config)
}
}
2 changes: 1 addition & 1 deletion src/command/graph/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ impl Check {
client_config: StudioClientConfig,
git_context: GitContext,
) -> Result<RoverOutput> {
let client = client_config.get_authenticated_client(&self.profile.profile_name)?;
let client = client_config.get_authenticated_client(&self.profile)?;
let proposed_schema = self
.schema
.read_file_descriptor("SDL", &mut std::io::stdin())?;
Expand Down
2 changes: 1 addition & 1 deletion src/command/graph/delete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pub struct Delete {

impl Delete {
pub fn run(&self, client_config: StudioClientConfig) -> Result<RoverOutput> {
let client = client_config.get_authenticated_client(&self.profile.profile_name)?;
let client = client_config.get_authenticated_client(&self.profile)?;
let graph_ref = self.graph.graph_ref.to_string();

eprintln!(
Expand Down
2 changes: 1 addition & 1 deletion src/command/graph/fetch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub struct Fetch {

impl Fetch {
pub fn run(&self, client_config: StudioClientConfig) -> Result<RoverOutput> {
let client = client_config.get_authenticated_client(&self.profile.profile_name)?;
let client = client_config.get_authenticated_client(&self.profile)?;
let graph_ref = self.graph.graph_ref.to_string();
eprintln!(
"Fetching SDL from {} using credentials from the {} profile.",
Expand Down
2 changes: 1 addition & 1 deletion src/command/graph/publish.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ impl Publish {
client_config: StudioClientConfig,
git_context: GitContext,
) -> Result<RoverOutput> {
let client = client_config.get_authenticated_client(&self.profile.profile_name)?;
let client = client_config.get_authenticated_client(&self.profile)?;
let graph_ref = self.graph.graph_ref.to_string();
eprintln!(
"Publishing SDL to {} using credentials from the {} profile.",
Expand Down
6 changes: 4 additions & 2 deletions src/command/mod.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
mod config;
mod dev;
mod docs;
mod explain;
mod fed2;
mod graph;
mod info;
mod install;
pub(crate) mod install;
mod readme;
mod subgraph;
pub(crate) mod subgraph;
mod supergraph;
mod update;

pub(crate) mod output;

pub use config::Config;
pub use dev::Dev;
pub use docs::Docs;
pub use explain::Explain;
pub use fed2::Fed2;
Expand Down
2 changes: 1 addition & 1 deletion src/command/readme/fetch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub struct Fetch {

impl Fetch {
pub fn run(&self, client_config: StudioClientConfig) -> Result<RoverOutput> {
let client = client_config.get_authenticated_client(&self.profile.profile_name)?;
let client = client_config.get_authenticated_client(&self.profile)?;
let graph_ref = self.graph.graph_ref.to_string();

eprintln!(
Expand Down
2 changes: 1 addition & 1 deletion src/command/readme/publish.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub struct Publish {

impl Publish {
pub fn run(&self, client_config: StudioClientConfig) -> Result<RoverOutput> {
let client = client_config.get_authenticated_client(&self.profile.profile_name)?;
let client = client_config.get_authenticated_client(&self.profile)?;
let graph_ref = self.graph.graph_ref.to_string();
eprintln!(
"Publishing README for {} using credentials from the {} profile.",
Expand Down
2 changes: 1 addition & 1 deletion src/command/subgraph/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ impl Check {
client_config: StudioClientConfig,
git_context: GitContext,
) -> Result<RoverOutput> {
let client = client_config.get_authenticated_client(&self.profile.profile_name)?;
let client = client_config.get_authenticated_client(&self.profile)?;

let proposed_schema = self
.schema
Expand Down
2 changes: 1 addition & 1 deletion src/command/subgraph/delete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub struct Delete {

impl Delete {
pub fn run(&self, client_config: StudioClientConfig) -> Result<RoverOutput> {
let client = client_config.get_authenticated_client(&self.profile.profile_name)?;
let client = client_config.get_authenticated_client(&self.profile)?;
eprintln!(
"Checking for build errors resulting from deleting subgraph {} from {} using credentials from the {} profile.",
Cyan.normal().paint(&self.subgraph.subgraph_name),
Expand Down
Loading