-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
036eedd
commit b128a40
Showing
31 changed files
with
9,094 additions
and
39 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
mutation CheckSchemaQuery( | ||
$graphId: ID! | ||
$variant: String | ||
$schema: String | ||
) { | ||
service(id: $graphId) { | ||
checkSchema( | ||
proposedSchemaDocument: $schema | ||
baseSchemaTag: $variant | ||
) { | ||
targetUrl | ||
diffToPrevious { | ||
severity | ||
affectedClients { | ||
__typename | ||
} | ||
affectedQueries { | ||
__typename | ||
} | ||
numberOfCheckedOperations | ||
changes { | ||
severity | ||
code | ||
description | ||
} | ||
validationConfig { | ||
from | ||
to | ||
queryCountThreshold | ||
queryCountThresholdPercentage | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
use crate::blocking::StudioClient; | ||
use crate::RoverClientError; | ||
use graphql_client::*; | ||
|
||
use reqwest::Url; | ||
|
||
type Timestamp = String; | ||
|
||
#[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/graph/check.graphql", | ||
schema_path = "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. check_schema_query | ||
pub struct CheckSchemaQuery; | ||
|
||
/// The main function to be used from this module. | ||
/// This function takes a proposed schema and validates it against a pushed | ||
/// schema. | ||
pub fn run( | ||
variables: check_schema_query::Variables, | ||
client: &StudioClient, | ||
) -> Result<CheckResponse, RoverClientError> { | ||
let data = client.post::<CheckSchemaQuery>(variables)?; | ||
get_check_response_from_data(data) | ||
} | ||
|
||
#[derive(Debug)] | ||
pub struct CheckResponse { | ||
pub target_url: Option<Url>, | ||
pub number_of_checked_operations: i64, | ||
pub change_severity: check_schema_query::ChangeSeverity, | ||
pub changes: Vec<check_schema_query::CheckSchemaQueryServiceCheckSchemaDiffToPreviousChanges>, | ||
} | ||
|
||
fn get_check_response_from_data( | ||
data: check_schema_query::ResponseData, | ||
) -> Result<CheckResponse, RoverClientError> { | ||
tracing::debug!("{:#?}", &data); | ||
let service = data.service.ok_or(RoverClientError::NoService)?; | ||
let target_url = get_url(service.check_schema.target_url); | ||
|
||
let diff_to_previous = service.check_schema.diff_to_previous; | ||
|
||
let number_of_checked_operations = diff_to_previous.number_of_checked_operations.unwrap_or(0); | ||
|
||
let change_severity = diff_to_previous.severity; | ||
let changes = diff_to_previous.changes; | ||
|
||
Ok(CheckResponse { | ||
target_url, | ||
number_of_checked_operations, | ||
change_severity, | ||
changes, | ||
}) | ||
} | ||
|
||
fn get_url(url: Option<String>) -> Option<Url> { | ||
match url { | ||
Some(url) => { | ||
let url = Url::parse(&url); | ||
match url { | ||
Ok(url) => Some(url), | ||
// if the API returns an invalid URL, don't put it in the response | ||
Err(_) => None, | ||
} | ||
} | ||
None => None, | ||
} | ||
} |
File renamed without changes.
Oops, something went wrong.