examples icon indicating copy to clipboard operation
examples copied to clipboard

sea orm issues

Open EevieForgor opened this issue 2 years ago • 2 comments

i get an error when using async_graphql to return a seaorm model from two routes: thread 'main' panicked at: 'entity::user::Model' and 'entity::config::Model' have the same GraphQL name 'Model'

EevieForgor avatar Mar 01 '23 16:03 EevieForgor

add this to your model #[graphql(name = "GenericLiterateCategory")]

#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize, SimpleObject)]
#[sea_orm(schema_name = "public", table_name = "posts")]
#[graphql(name = "Post")] // <- this makes GraphQL recognize Model to Post Entity
pub struct Model {
    #[sea_orm(primary_key, auto_increment = false)]
    pub id: Uuid,
    pub title: String,
    pub created_by: Option<Uuid>,
    pub updated_by: Option<Uuid>,
    pub created_at: Option<DateTime>,
    pub updated_at: Option<DateTime>,
    pub sync_at: Option<DateTime>,
    pub deleted_at: Option<DateTime>,
}

bendo01 avatar Mar 09 '23 04:03 bendo01

hey, forgot to respond but this worked, thank you!

EevieForgor avatar Mar 24 '23 15:03 EevieForgor