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

chore: finish renaming subgraph and graph #125

Merged
merged 1 commit into from
Dec 15, 2020
Merged
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
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
query GetSchemaQuery($variant: String, $graphId: ID!, $hash: ID) {
query FetchSchemaQuery($variant: String, $graphId: ID!, $hash: ID) {
service(id: $graphId) {
schema(tag: $variant, hash: $hash) {
document
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,29 @@ type GraphQLDocument = String;
// The paths are relative to the directory where your `Cargo.toml` is located.
// Both json and the GraphQL schema language are supported as sources for the schema
#[graphql(
query_path = "src/query/schema/get.graphql",
query_path = "src/query/graph/fetch.graphql",
schema_path = ".schema/schema.graphql",
response_derives = "PartialEq, Debug, Serialize, Deserialize",
deprecated = "warn"
)]
/// This struct is used to generate the module containing `Variables` and
/// `ResponseData` structs.
/// Snake case of this name is the mod name. i.e. get_schema_query
pub struct GetSchemaQuery;
/// Snake case of this name is the mod name. i.e. fetch_schema_query
pub struct FetchSchemaQuery;

/// The main function to be used from this module. This function fetches a
/// schema from apollo studio and returns it in either sdl (default) or json format
pub fn run(
variables: get_schema_query::Variables,
variables: fetch_schema_query::Variables,
client: &StudioClient,
) -> Result<String, RoverClientError> {
let response_data = client.post::<GetSchemaQuery>(variables)?;
let response_data = client.post::<FetchSchemaQuery>(variables)?;
get_schema_from_response_data(response_data)
// if we want json, we can parse & serialize it here
}

fn get_schema_from_response_data(
response_data: get_schema_query::ResponseData,
response_data: fetch_schema_query::ResponseData,
) -> Result<String, RoverClientError> {
let service_data = match response_data.service {
Some(data) => Ok(data),
Expand Down Expand Up @@ -61,7 +61,7 @@ mod tests {
}
}
});
let data: get_schema_query::ResponseData = serde_json::from_value(json_response).unwrap();
let data: fetch_schema_query::ResponseData = serde_json::from_value(json_response).unwrap();
let output = get_schema_from_response_data(data);

assert!(output.is_ok());
Expand All @@ -71,7 +71,7 @@ mod tests {
#[test]
fn get_schema_from_response_data_errs_on_no_service() {
let json_response = json!({ "service": null });
let data: get_schema_query::ResponseData = serde_json::from_value(json_response).unwrap();
let data: fetch_schema_query::ResponseData = serde_json::from_value(json_response).unwrap();
let output = get_schema_from_response_data(data);

assert!(output.is_err());
Expand All @@ -84,7 +84,7 @@ mod tests {
"schema": null
}
});
let data: get_schema_query::ResponseData = serde_json::from_value(json_response).unwrap();
let data: fetch_schema_query::ResponseData = serde_json::from_value(json_response).unwrap();
let output = get_schema_from_response_data(data);

assert!(output.is_err());
Expand Down
5 changes: 5 additions & 0 deletions crates/rover-client/src/query/graph/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/// "graph get" command execution
pub mod fetch;

/// "graph push" command execution
pub mod push;
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use graphql_client::*;
// The paths are relative to the directory where your `Cargo.toml` is located.
// Both json and the GraphQL schema language are supported as sources for the schema
#[graphql(
query_path = "src/query/schema/push.graphql",
query_path = "src/query/graph/push.graphql",
schema_path = ".schema/schema.graphql",
response_derives = "PartialEq, Debug, Serialize, Deserialize",
deprecated = "warn"
Expand Down
8 changes: 4 additions & 4 deletions crates/rover-client/src/query/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/// all rover-client functionality for the "schema" commands in rover
pub mod schema;
/// all rover-client functionality for the "graph" commands in rover
pub mod graph;

/// all rover-client functionality for the "partial" commands in rover
pub mod partial;
/// all rover-client functionality for the "subgraph" commands in rover
pub mod subgraph;
5 changes: 0 additions & 5 deletions crates/rover-client/src/query/partial/mod.rs

This file was deleted.

5 changes: 0 additions & 5 deletions crates/rover-client/src/query/schema/mod.rs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use graphql_client::*;
// The paths are relative to the directory where your `Cargo.toml` is located.
// Both json and the GraphQL schema language are supported as sources for the schema
#[graphql(
query_path = "src/query/partial/delete.graphql",
query_path = "src/query/subgraph/delete.graphql",
schema_path = ".schema/schema.graphql",
response_derives = "PartialEq, Debug, Serialize, Deserialize",
deprecated = "warn"
Expand Down
5 changes: 5 additions & 0 deletions crates/rover-client/src/query/subgraph/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/// "subgraph push" command execution
pub mod push;

/// "subgraph delete" command execution
pub mod delete;
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use graphql_client::*;
// The paths are relative to the directory where your `Cargo.toml` is located.
// Both json and the GraphQL schema language are supported as sources for the schema
#[graphql(
query_path = "src/query/partial/push.graphql",
query_path = "src/query/subgraph/push.graphql",
schema_path = ".schema/schema.graphql",
response_derives = "PartialEq, Debug, Serialize, Deserialize",
deprecated = "warn"
Expand Down
6 changes: 3 additions & 3 deletions src/command/graph/fetch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use anyhow::{Context, Result};
use serde::Serialize;
use structopt::StructOpt;

use rover_client::query::schema::get;
use rover_client::query::graph::fetch;

use crate::client::get_studio_client;
use crate::command::RoverStdout;
Expand Down Expand Up @@ -34,8 +34,8 @@ impl Fetch {
&self.profile_name
);

let sdl = get::run(
get::get_schema_query::Variables {
let sdl = fetch::run(
fetch::fetch_schema_query::Variables {
graph_id: self.graph.name.clone(),
hash: None,
variant: Some(self.graph.variant.clone()),
Expand Down
2 changes: 1 addition & 1 deletion src/command/graph/push.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use anyhow::{Context, Result};
use serde::Serialize;
use structopt::StructOpt;

use rover_client::query::schema::push;
use rover_client::query::graph::push;

use crate::client::get_studio_client;
use crate::command::RoverStdout;
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 @@ -2,7 +2,7 @@ use crate::client::get_studio_client;
use crate::command::RoverStdout;
use crate::utils::parsers::{parse_graph_ref, GraphRef};
use anyhow::Result;
use rover_client::query::partial::delete::{self, DeleteServiceResponse};
use rover_client::query::subgraph::delete::{self, DeleteServiceResponse};
use serde::Serialize;
use structopt::StructOpt;

Expand Down
2 changes: 1 addition & 1 deletion src/command/subgraph/push.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use anyhow::{Context, Result};
use rover_client::query::partial::push::{self, PushPartialSchemaResponse};
use rover_client::query::subgraph::push::{self, PushPartialSchemaResponse};
use serde::Serialize;
use structopt::StructOpt;

Expand Down