Skip to content

Commit 4021ee1

Browse files
committed
error when a non-federated graph is about to be overwritten by a subgraph
1 parent 2ca3b27 commit 4021ee1

File tree

6 files changed

+97
-306
lines changed

6 files changed

+97
-306
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
query IsFederatedGraph($graphId: ID!, $graphVariant: String!) {
2+
service(id: $graphId) {
3+
implementingServices(graphVariant: $graphVariant) {
4+
__typename
5+
}
6+
}
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
// PublishPartialSchemaMutation
2+
use crate::blocking::StudioClient;
3+
use crate::RoverClientError;
4+
use graphql_client::*;
5+
6+
#[derive(GraphQLQuery)]
7+
// The paths are relative to the directory where your `Cargo.toml` is located.
8+
// Both json and the GraphQL schema language are supported as sources for the schema
9+
#[graphql(
10+
query_path = "src/query/config/is_federated.graphql",
11+
schema_path = ".schema/schema.graphql",
12+
response_derives = "PartialEq, Debug, Serialize, Deserialize",
13+
deprecated = "warn"
14+
)]
15+
/// This struct is used to generate the module containing `Variables` and
16+
/// `ResponseData` structs.
17+
/// Snake case of this name is the mod name. i.e. publish_partial_schema_mutation
18+
pub struct IsFederatedGraph;
19+
20+
#[derive(Debug, PartialEq)]
21+
pub struct IsFederatedGraphResponse {
22+
pub result: bool,
23+
}
24+
25+
pub fn run(
26+
variables: is_federated_graph::Variables,
27+
client: &StudioClient,
28+
) -> Result<IsFederatedGraphResponse, RoverClientError> {
29+
let data = client.post::<IsFederatedGraph>(variables)?;
30+
let is_federated_response = data.service.unwrap();
31+
Ok(build_response(is_federated_response))
32+
}
33+
34+
type FederatedResponse = is_federated_graph::IsFederatedGraphService;
35+
type ImplementingServices = is_federated_graph::IsFederatedGraphServiceImplementingServices;
36+
37+
fn build_response(service: FederatedResponse) -> IsFederatedGraphResponse {
38+
match service.implementing_services {
39+
Some(typename) => match typename {
40+
ImplementingServices::FederatedImplementingServices => {
41+
IsFederatedGraphResponse { result: true }
42+
}
43+
ImplementingServices::NonFederatedImplementingService => {
44+
IsFederatedGraphResponse { result: false }
45+
}
46+
},
47+
None => IsFederatedGraphResponse { result: false },
48+
}
49+
}
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
/// runner for rover config whoami
22
pub mod whoami;
3+
4+
/// runner is_federated check
5+
pub mod is_federated;

installers/npm/package-lock.json

+4-297
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

installers/npm/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,6 @@
3333
"console.table": "^0.10.0"
3434
},
3535
"devDependencies": {
36-
"prettier": "^2.2.1"
36+
"prettier": "^2.3.0"
3737
}
3838
}

0 commit comments

Comments
 (0)