-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wip: refactor subgraph check and add line numbers
- Loading branch information
1 parent
c1b08d9
commit 716c278
Showing
14 changed files
with
191 additions
and
143 deletions.
There are no files selected for viewing
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,3 @@ | ||
pub mod query_runner; | ||
pub(crate) mod types; | ||
pub use types::SubgraphCheckResponse; |
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,53 @@ | ||
use std::fmt; | ||
|
||
use super::query_runner::subgraph_check_query; | ||
|
||
pub(crate) type Timestamp = String; | ||
type QueryChangeSeverity = subgraph_check_query::ChangeSeverity; | ||
|
||
#[derive(Debug, Clone, PartialEq)] | ||
pub struct SubgraphCheckResponse { | ||
pub target_url: Option<String>, | ||
pub number_of_checked_operations: i64, | ||
pub changes: Vec<SchemaChange>, | ||
pub change_severity: ChangeSeverity | ||
} | ||
|
||
#[derive(Debug, Clone, PartialEq)] | ||
pub enum ChangeSeverity { | ||
PASS, | ||
FAIL, | ||
} | ||
|
||
impl fmt::Display for ChangeSeverity { | ||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | ||
let msg = match self { | ||
ChangeSeverity::PASS => "PASS", | ||
ChangeSeverity::FAIL => "FAIL" | ||
}; | ||
write!(f, "{}", msg) | ||
} | ||
} | ||
|
||
impl From<QueryChangeSeverity> for ChangeSeverity { | ||
fn from(severity: QueryChangeSeverity) -> Self { | ||
match severity { | ||
QueryChangeSeverity::NOTICE => ChangeSeverity::PASS, | ||
QueryChangeSeverity::FAILURE => ChangeSeverity::FAIL, | ||
_ => unreachable!("Unknown change severity") | ||
} | ||
} | ||
} | ||
|
||
#[derive(Debug, Clone, PartialEq)] | ||
pub struct SchemaChange { | ||
pub code: String, | ||
pub description: String, | ||
pub severity: ChangeSeverity | ||
} | ||
|
||
#[derive(Debug, Clone, PartialEq)] | ||
pub struct CompositionError { | ||
pub message: String, | ||
pub code: Option<String> | ||
} |
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
Oops, something went wrong.