Skip to main content

Object

Derive Macro Object 

Source
#[derive(Object)]
{
    // Attributes available to this derive:
    #[graphql]
}
Expand description

Derive a GraphQL object type.

The Rust type name becomes the GraphQL type name; override it with #[graphql(name = "...")]. A doc comment on the type becomes its description, and #[graphql(description = "...")] overrides the comment.

Fields are not derived. An object’s GraphQL fields are declared explicitly on the schema builder with field, field_result, field_async, field_result_async or expose, so every field’s resolver and access rules live in one place.

ⓘ
use gurafi::Object;

#[derive(Object)]
#[graphql(description = "A long-necked animal.")]
struct Giraffe {
    name: String,
}