-
Notifications
You must be signed in to change notification settings - Fork 166
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(torii): dynamic schema for storage components
- Loading branch information
Showing
12 changed files
with
162 additions
and
33 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/bash | ||
pushd $(dirname "$0")/.. | ||
|
||
cargo test --bin torii -- --nocapture |
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
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 |
---|---|---|
@@ -1 +1,5 @@ | ||
pub mod value_accessor; | ||
|
||
pub fn remove_quotes(s: &str) -> String { | ||
s.replace(&['\"', '\''][..], "") | ||
} |
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 |
---|---|---|
@@ -1,14 +1,17 @@ | ||
// #[cfg(test)] | ||
// mod tests { | ||
// use async_graphql_parser::parse_schema; | ||
// use sqlx::SqlitePool; | ||
#[cfg(test)] | ||
mod tests { | ||
use sqlx::SqlitePool; | ||
|
||
// use crate::graphql::entity::Entity; | ||
// use crate::graphql::schema::{self, build_schema}; | ||
// use crate::tests::common::run_graphql_query; | ||
use crate::graphql::schema::build_schema; | ||
|
||
// #[sqlx::test(migrations = "./migrations", fixtures("components"))] | ||
// async fn test_dynamic_component(pool: SqlitePool) { | ||
// let schema = build_schema(&pool).await; | ||
// } | ||
// } | ||
#[sqlx::test(migrations = "./migrations", fixtures("components"))] | ||
async fn test_dynamic_component(pool: SqlitePool) { | ||
let schema = build_schema(&pool).await.expect("failed to build schema"); | ||
} | ||
|
||
#[sqlx::test(migrations = "./migrations", fixtures("components_bad_schema"))] | ||
async fn test_bad_schema(pool: SqlitePool) { | ||
let result = build_schema(&pool).await; | ||
assert!(result.is_err()); | ||
} | ||
} |
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 |
---|---|---|
@@ -1,11 +1,11 @@ | ||
INSERT INTO components (id, name, address, class_hash, transaction_hash, storage_schema) | ||
VALUES ('component_1', 'Game', '0x0', '0x0', '0x0', | ||
'type GameComponent { isFinished: Boolean! entity: Entity! component: Component! createdAt: DateTime! }'); | ||
'type Game { isFinished: Boolean! entity: Entity! component: Component! createdAt: DateTime! }'); | ||
|
||
INSERT INTO components (id, name, address, class_hash, transaction_hash, storage_schema) | ||
VALUES ('component_2', 'Stats', '0x0', '0x0', '0x0', | ||
'type StatsComponent { health: U8! entity: Entity! component: Component! createdAt: DateTime! }'); | ||
'type Stats { health: U8! entity: Entity! component: Component! createdAt: DateTime! }'); | ||
|
||
INSERT INTO components (id, name, address, class_hash, transaction_hash, storage_schema) | ||
VALUES ('component_3', 'Cash', '0x0', '0x0', '0x0', | ||
'type CashComponent { amount: U32! entity: Entity! component: Component! createdAt: DateTime! }'); | ||
'type Cash { amount: U32! entity: Entity! component: Component! createdAt: DateTime! }'); |
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,4 @@ | ||
INSERT INTO components (id, name, address, class_hash, transaction_hash, storage_schema) | ||
VALUES ('component_1', 'Game', '0x0', '0x0', '0x0', | ||
'type Game {{ isFinished: Boolean! }'); | ||
|