Skip to content

Commit

Permalink
error when a non-federated graph is about to be overwritten by a subg…
Browse files Browse the repository at this point in the history
…raph
  • Loading branch information
lrlna committed May 11, 2021
1 parent 2ca3b27 commit 4021ee1
Show file tree
Hide file tree
Showing 6 changed files with 97 additions and 306 deletions.
7 changes: 7 additions & 0 deletions crates/rover-client/src/query/config/is_federated.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
query IsFederatedGraph($graphId: ID!, $graphVariant: String!) {
service(id: $graphId) {
implementingServices(graphVariant: $graphVariant) {
__typename
}
}
}
49 changes: 49 additions & 0 deletions crates/rover-client/src/query/config/is_federated.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// PublishPartialSchemaMutation
use crate::blocking::StudioClient;
use crate::RoverClientError;
use graphql_client::*;

#[derive(GraphQLQuery)]
// 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/config/is_federated.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. publish_partial_schema_mutation
pub struct IsFederatedGraph;

#[derive(Debug, PartialEq)]
pub struct IsFederatedGraphResponse {
pub result: bool,
}

pub fn run(
variables: is_federated_graph::Variables,
client: &StudioClient,
) -> Result<IsFederatedGraphResponse, RoverClientError> {
let data = client.post::<IsFederatedGraph>(variables)?;
let is_federated_response = data.service.unwrap();
Ok(build_response(is_federated_response))
}

type FederatedResponse = is_federated_graph::IsFederatedGraphService;
type ImplementingServices = is_federated_graph::IsFederatedGraphServiceImplementingServices;

fn build_response(service: FederatedResponse) -> IsFederatedGraphResponse {
match service.implementing_services {
Some(typename) => match typename {
ImplementingServices::FederatedImplementingServices => {
IsFederatedGraphResponse { result: true }
}
ImplementingServices::NonFederatedImplementingService => {
IsFederatedGraphResponse { result: false }
}
},
None => IsFederatedGraphResponse { result: false },
}
}
3 changes: 3 additions & 0 deletions crates/rover-client/src/query/config/mod.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
/// runner for rover config whoami
pub mod whoami;

/// runner is_federated check
pub mod is_federated;
301 changes: 4 additions & 297 deletions installers/npm/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion installers/npm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@
"console.table": "^0.10.0"
},
"devDependencies": {
"prettier": "^2.2.1"
"prettier": "^2.3.0"
}
}
Loading

0 comments on commit 4021ee1

Please sign in to comment.