async-graphql / examples

217 stars 54 forks source link

sea orm issues #69

Open EevieForgor opened 1 year ago

EevieForgor commented 1 year ago

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'

bendo01 commented 1 year ago

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>,
}
EevieForgor commented 1 year ago

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