Skip to content

Commit 6e0d540

Browse files
chore: finish renaming subgraph and graph
1 parent d2cee55 commit 6e0d540

File tree

18 files changed

+35
-39
lines changed

18 files changed

+35
-39
lines changed

crates/rover-client/src/blocking/client.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,7 @@ impl Client {
4646
pub fn handle_response<Q: graphql_client::GraphQLQuery>(
4747
response: reqwest::blocking::Response,
4848
) -> Result<Q::ResponseData, RoverClientError> {
49-
let response_body: graphql_client::Response<Q::ResponseData> =
50-
response
51-
.json()
52-
.map_err(|_| RoverClientError::HandleResponse {
53-
msg: String::from("failed to parse response JSON"),
54-
})?;
49+
let response_body: graphql_client::Response<Q::ResponseData> = response.json()?;
5550

5651
if let Some(errs) = response_body.errors {
5752
return Err(RoverClientError::GraphQL {

crates/rover-client/src/query/schema/get.graphql crates/rover-client/src/query/graph/fetch.graphql

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
query GetSchemaQuery($variant: String, $graphId: ID!, $hash: ID) {
1+
query FetchSchemaQuery($variant: String, $graphId: ID!, $hash: ID) {
22
service(id: $graphId) {
33
schema(tag: $variant, hash: $hash) {
44
document

crates/rover-client/src/query/schema/get.rs crates/rover-client/src/query/graph/fetch.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -10,29 +10,29 @@ type GraphQLDocument = String;
1010
// The paths are relative to the directory where your `Cargo.toml` is located.
1111
// Both json and the GraphQL schema language are supported as sources for the schema
1212
#[graphql(
13-
query_path = "src/query/schema/get.graphql",
13+
query_path = "src/query/graph/fetch.graphql",
1414
schema_path = ".schema/schema.graphql",
1515
response_derives = "PartialEq, Debug, Serialize, Deserialize",
1616
deprecated = "warn"
1717
)]
1818
/// This struct is used to generate the module containing `Variables` and
1919
/// `ResponseData` structs.
20-
/// Snake case of this name is the mod name. i.e. get_schema_query
21-
pub struct GetSchemaQuery;
20+
/// Snake case of this name is the mod name. i.e. fetch_schema_query
21+
pub struct FetchSchemaQuery;
2222

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

3434
fn get_schema_from_response_data(
35-
response_data: get_schema_query::ResponseData,
35+
response_data: fetch_schema_query::ResponseData,
3636
) -> Result<String, RoverClientError> {
3737
let service_data = match response_data.service {
3838
Some(data) => Ok(data),
@@ -61,7 +61,7 @@ mod tests {
6161
}
6262
}
6363
});
64-
let data: get_schema_query::ResponseData = serde_json::from_value(json_response).unwrap();
64+
let data: fetch_schema_query::ResponseData = serde_json::from_value(json_response).unwrap();
6565
let output = get_schema_from_response_data(data);
6666

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

7777
assert!(output.is_err());
@@ -84,7 +84,7 @@ mod tests {
8484
"schema": null
8585
}
8686
});
87-
let data: get_schema_query::ResponseData = serde_json::from_value(json_response).unwrap();
87+
let data: fetch_schema_query::ResponseData = serde_json::from_value(json_response).unwrap();
8888
let output = get_schema_from_response_data(data);
8989

9090
assert!(output.is_err());
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/// "graph get" command execution
2+
pub mod fetch;
3+
4+
/// "graph push" command execution
5+
pub mod push;

crates/rover-client/src/query/schema/push.rs crates/rover-client/src/query/graph/push.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use graphql_client::*;
66
// The paths are relative to the directory where your `Cargo.toml` is located.
77
// Both json and the GraphQL schema language are supported as sources for the schema
88
#[graphql(
9-
query_path = "src/query/schema/push.graphql",
9+
query_path = "src/query/graph/push.graphql",
1010
schema_path = ".schema/schema.graphql",
1111
response_derives = "PartialEq, Debug, Serialize, Deserialize",
1212
deprecated = "warn"

crates/rover-client/src/query/mod.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
/// all rover-client functionality for the "schema" commands in rover
2-
pub mod schema;
1+
/// all rover-client functionality for the "graph" commands in rover
2+
pub mod graph;
33

4-
/// all rover-client functionality for the "partial" commands in rover
5-
pub mod partial;
4+
/// all rover-client functionality for the "subgraph" commands in rover
5+
pub mod subgraph;

crates/rover-client/src/query/partial/mod.rs

-5
This file was deleted.

crates/rover-client/src/query/schema/mod.rs

-5
This file was deleted.

crates/rover-client/src/query/partial/delete.rs crates/rover-client/src/query/subgraph/delete.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use graphql_client::*;
66
// The paths are relative to the directory where your `Cargo.toml` is located.
77
// Both json and the GraphQL schema language are supported as sources for the schema
88
#[graphql(
9-
query_path = "src/query/partial/delete.graphql",
9+
query_path = "src/query/subgraph/delete.graphql",
1010
schema_path = ".schema/schema.graphql",
1111
response_derives = "PartialEq, Debug, Serialize, Deserialize",
1212
deprecated = "warn"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/// "subgraph push" command execution
2+
pub mod push;
3+
4+
/// "subgraph delete" command execution
5+
pub mod delete;
6+

crates/rover-client/src/query/partial/push.rs crates/rover-client/src/query/subgraph/push.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use graphql_client::*;
77
// The paths are relative to the directory where your `Cargo.toml` is located.
88
// Both json and the GraphQL schema language are supported as sources for the schema
99
#[graphql(
10-
query_path = "src/query/partial/push.graphql",
10+
query_path = "src/query/subgraph/push.graphql",
1111
schema_path = ".schema/schema.graphql",
1212
response_derives = "PartialEq, Debug, Serialize, Deserialize",
1313
deprecated = "warn"

src/command/graph/fetch.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use anyhow::{Context, Result};
22
use serde::Serialize;
33
use structopt::StructOpt;
44

5-
use rover_client::query::schema::get;
5+
use rover_client::query::graph::fetch;
66

77
use crate::client::get_studio_client;
88
use crate::command::RoverStdout;
@@ -34,8 +34,8 @@ impl Fetch {
3434
&self.profile_name
3535
);
3636

37-
let sdl = get::run(
38-
get::get_schema_query::Variables {
37+
let sdl = fetch::run(
38+
fetch::fetch_schema_query::Variables {
3939
graph_id: self.graph.name.clone(),
4040
hash: None,
4141
variant: Some(self.graph.variant.clone()),

src/command/graph/push.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use anyhow::{Context, Result};
22
use serde::Serialize;
33
use structopt::StructOpt;
44

5-
use rover_client::query::schema::push;
5+
use rover_client::query::graph::push;
66

77
use crate::client::get_studio_client;
88
use crate::command::RoverStdout;

src/command/subgraph/delete.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use crate::client::get_studio_client;
22
use crate::command::RoverStdout;
33
use crate::utils::parsers::{parse_graph_ref, GraphRef};
44
use anyhow::Result;
5-
use rover_client::query::partial::delete::{self, DeleteServiceResponse};
5+
use rover_client::query::subgraph::delete::{self, DeleteServiceResponse};
66
use serde::Serialize;
77
use structopt::StructOpt;
88

src/command/subgraph/push.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use anyhow::{Context, Result};
2-
use rover_client::query::partial::push::{self, PushPartialSchemaResponse};
2+
use rover_client::query::subgraph::push::{self, PushPartialSchemaResponse};
33
use serde::Serialize;
44
use structopt::StructOpt;
55

0 commit comments

Comments
 (0)