Skip to main content

Crate lineark_derive

Crate lineark_derive 

Source
Expand description

Derive macro for the GraphQLFields trait.

Automatically generates selection() from a struct’s field definitions. No manual GraphQL strings needed — the struct shape IS the query shape.

§Usage

use lineark_sdk::GraphQLFields;
use lineark_sdk::generated::types::Issue;

#[derive(GraphQLFields, Deserialize)]
#[graphql(full_type = Issue)]
#[serde(rename_all = "camelCase")]
struct MyIssue {
    id: Option<String>,
    title: Option<String>,
    #[graphql(nested)]
    state: Option<StateRef>,
}

Generates: "id title state { <StateRef::selection()> }"

With full_type, the macro also generates compile-time validation that each field exists on the full type with a compatible type.

Derive Macros§

GraphQLFields
Derive GraphQLFields for a struct.