-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #794 from rainlanguage/2024-08-26-schema-validator
Subgraph schema validator
- Loading branch information
Showing
8 changed files
with
272 additions
and
13 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
use crate::execute::Execute; | ||
use anyhow::Result; | ||
use clap::Parser; | ||
use rain_orderbook_subgraph_client::validate::validate_subgraph_schema; | ||
|
||
#[derive(Parser)] | ||
pub enum Subgraph { | ||
#[command(about = "Validates a subgraph schema against this apps subgraph schema")] | ||
Validate { | ||
/// Subgraph url to validate | ||
subgraph_url: String, | ||
}, | ||
} | ||
|
||
impl Execute for Subgraph { | ||
async fn execute(&self) -> Result<()> { | ||
match self { | ||
Subgraph::Validate { subgraph_url } => Ok(validate_subgraph_schema(subgraph_url) | ||
.await | ||
.map(|v| println!("--- {}valid subgraph ---", if v { "" } else { "in" }))?), | ||
} | ||
} | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use super::*; | ||
use clap::CommandFactory; | ||
|
||
#[test] | ||
fn verify_command() { | ||
Subgraph::command().debug_assert(); | ||
} | ||
} |
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
Oops, something went wrong.