Skip to main content

GraphQLModel

Derive Macro GraphQLModel 

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

Derive macro: auto-generates an sz_orm_graphql::schema_gen::GraphQLModelInfo impl.

Extracts field metadata (field name + Rust type + nullability) from a #[derive(GraphQLModel)] struct for use by SchemaGenerator::from_model. Zero runtime overhead.

§Supported attributes

  • #[table(name = "users")] — specifies the table name (defaults to the snake_case form of the struct name)
  • #[column(skip)] — skips this field
  • #[column(name = "custom_name")] — specifies the column name

§Example

use sz_orm_macros::GraphQLModel;

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