Skip to main content

GraphQLModel

Derive Macro GraphQLModel 

Source
#[derive(GraphQLModel)]
{
    // Attributes available to this derive:
    #[table]
    #[column]
}
Expand description

派生宏:自动生成 sz_orm_graphql::schema_gen::GraphQLModelInfo 实现。

#[derive(GraphQLModel)] 结构体提取字段元数据(字段名 + Rust 类型 + 可空性), 供 SchemaGenerator::from_model 使用。零运行时开销。

§支持的属性

  • #[table(name = "users")] — 指定表名(默认使用结构体名的 snake_case)
  • #[column(skip)] — 跳过此字段
  • #[column(name = "custom_name")] — 指定列名

§示例

use sz_orm_macros::GraphQLModel;

#[derive(GraphQLModel)]
#[table(name = "users")]
struct User {
    id: i64,
    name: String,
    email: Option<String>,
}