diff --git a/crates/torii/graphql/src/object/model.rs b/crates/torii/graphql/src/object/model.rs index 62c126c708..b2d8d12736 100644 --- a/crates/torii/graphql/src/object/model.rs +++ b/crates/torii/graphql/src/object/model.rs @@ -2,8 +2,8 @@ use async_graphql::dynamic::{ Field, FieldFuture, InputValue, SubscriptionField, SubscriptionFieldFuture, TypeRef, }; use async_graphql::{Name, Value}; -use dojo_types::core::CairoType; use indexmap::IndexMap; +use dojo_types::primitive::Primitive; use sqlx::{Pool, Sqlite}; use tokio_stream::StreamExt; use torii_core::simple_broker::SimpleBroker; @@ -28,11 +28,11 @@ impl Default for ModelObject { (Name::new("name"), TypeData::Simple(TypeRef::named(TypeRef::STRING))), ( Name::new("classHash"), - TypeData::Simple(TypeRef::named(CairoType::Felt252.to_string())), + TypeData::Simple(TypeRef::named("felt252")), ), ( Name::new("transactionHash"), - TypeData::Simple(TypeRef::named(CairoType::Felt252.to_string())), + TypeData::Simple(TypeRef::named("felt252")), ), ( Name::new("createdAt"), diff --git a/crates/torii/graphql/src/object/model_data.rs b/crates/torii/graphql/src/object/model_data.rs index b4be73b0da..952b739ef7 100644 --- a/crates/torii/graphql/src/object/model_data.rs +++ b/crates/torii/graphql/src/object/model_data.rs @@ -3,7 +3,7 @@ use std::str::FromStr; use async_graphql::dynamic::{Enum, Field, FieldFuture, InputObject, Object, TypeRef}; use async_graphql::{Error, Name, Value}; use chrono::{DateTime, Utc}; -use dojo_types::core::CairoType; +use dojo_types::primitive::Primitive; use serde::Deserialize; use sqlx::pool::PoolConnection; use sqlx::sqlite::SqliteRow; @@ -358,9 +358,9 @@ fn value_mapping_from_row(row: &SqliteRow, types: &TypeMapping) -> sqlx::Result< } fn fetch_value(row: &SqliteRow, column_name: &str, field_type: &str) -> sqlx::Result { - match CairoType::from_str(field_type) { + match Primitive::from_str(field_type) { // fetch boolean - Ok(CairoType::Bool) => { + Ok(Primitive::Bool(_)) => { Ok(Value::from(matches!(row.try_get::(column_name)?, BOOLEAN_TRUE))) } // fetch integer diff --git a/crates/torii/graphql/src/object/system.rs b/crates/torii/graphql/src/object/system.rs index c5071d8b48..205ef2b0a4 100644 --- a/crates/torii/graphql/src/object/system.rs +++ b/crates/torii/graphql/src/object/system.rs @@ -1,7 +1,6 @@ use async_graphql::dynamic::{Field, FieldFuture, FieldValue, InputValue, TypeRef}; use async_graphql::{Name, Value}; use chrono::{DateTime, Utc}; -use dojo_types::core::CairoType; use indexmap::IndexMap; use serde::Deserialize; use sqlx::{FromRow, Pool, Sqlite}; @@ -36,11 +35,11 @@ impl Default for SystemObject { (Name::new("name"), TypeData::Simple(TypeRef::named(TypeRef::STRING))), ( Name::new("classHash"), - TypeData::Simple(TypeRef::named(CairoType::Felt252.to_string())), + TypeData::Simple(TypeRef::named("felt252")), ), ( Name::new("transactionHash"), - TypeData::Simple(TypeRef::named(CairoType::Felt252.to_string())), + TypeData::Simple(TypeRef::named("felt252")), ), ( Name::new("createdAt"), diff --git a/crates/torii/graphql/src/query/mod.rs b/crates/torii/graphql/src/query/mod.rs index 0bf9bf9b2a..11d2867f12 100644 --- a/crates/torii/graphql/src/query/mod.rs +++ b/crates/torii/graphql/src/query/mod.rs @@ -2,7 +2,7 @@ use std::str::FromStr; use async_graphql::dynamic::TypeRef; use async_graphql::Name; -use dojo_types::core::CairoType; +use dojo_types::primitive::Primitive; use sqlx::pool::PoolConnection; use sqlx::sqlite::SqliteRow; use sqlx::{FromRow, QueryBuilder, Result, Sqlite}; @@ -94,7 +94,7 @@ pub async fn type_mapping_query( let type_mapping: TypeMapping = root_members .iter() .map(|member| { - let type_data = match CairoType::from_str(&member.ty) { + let type_data = match Primitive::from_str(&member.ty) { Ok(_) => TypeData::Simple(TypeRef::named(member.ty.clone())), _ => parse_nested_type(&member.model_id, &member.ty, &nested_members), }; @@ -116,7 +116,7 @@ fn parse_nested_type( .filter_map(|member| { // search for target type in nested members if target_id == member.model_id && member.id.ends_with(target_type) { - let type_data = match CairoType::from_str(&member.ty) { + let type_data = match Primitive::from_str(&member.ty) { Ok(_) => TypeData::Simple(TypeRef::named(member.ty.clone())), _ => parse_nested_type(&member.model_id, &member.ty, nested_members), }; diff --git a/crates/torii/graphql/src/types.rs b/crates/torii/graphql/src/types.rs index 35bc5e2975..60279f0096 100644 --- a/crates/torii/graphql/src/types.rs +++ b/crates/torii/graphql/src/types.rs @@ -1,6 +1,6 @@ use async_graphql::dynamic::TypeRef; use async_graphql::{Name, Value}; -use dojo_types::core::CairoType; +use dojo_types::primitive::Primitive; use indexmap::IndexMap; use strum::IntoEnumIterator; use strum_macros::{AsRefStr, Display, EnumIter, EnumString}; @@ -44,7 +44,7 @@ impl TypeData { #[derive(Debug)] pub enum ScalarType { - Cairo(CairoType), + Cairo(Primitive), Torii(GraphqlType), } @@ -57,7 +57,7 @@ pub enum GraphqlType { impl ScalarType { pub fn all() -> Vec { - CairoType::iter() + Primitive::iter() .map(|ty| ty.to_string()) .chain(GraphqlType::iter().map(|ty| ty.to_string())) .collect()