Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change model query field to camel case #1410

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion crates/torii/graphql/src/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use anyhow::Result;
use async_graphql::dynamic::{
Field, Object, Scalar, Schema, Subscription, SubscriptionField, Union,
};
use convert_case::{Case, Casing};
use sqlx::SqlitePool;
use torii_core::types::Model;

Expand Down Expand Up @@ -126,7 +127,7 @@ async fn build_objects(pool: &SqlitePool) -> Result<(Vec<Box<dyn ObjectTrait>>,
let type_mapping = type_mapping_query(&mut conn, &model.id).await?;

if !type_mapping.is_empty() {
let field_name = model.name.to_lowercase();
let field_name = model.name.to_case(Case::Camel);
let type_name = model.name;

union = union.possible_type(&type_name);
Expand Down
2 changes: 1 addition & 1 deletion crates/torii/graphql/src/tests/models_ordering_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ mod tests {
createdAt
}}
}}
pageInfo{{
pageInfo {{
startCursor
hasPreviousPage
hasNextPage
Expand Down
17 changes: 17 additions & 0 deletions crates/torii/graphql/src/tests/models_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,23 @@ mod tests {
let connection: Connection<Record> = serde_json::from_value(records).unwrap();
assert_eq!(connection.edges.len(), 0);

let result = run_graphql_query(
&schema,
r#"
{
recordSiblingModels {
edges {
node {
__typename
}
}
}
}
"#,
)
.await;
assert!(result.get("recordSiblingModels").is_some());

Ok(())
}
}
Loading