#[graphql_enum]Expand description
Define a GraphQL enum type.
Generates a GraphQL Enum type definition from a Rust enum. Only unit variants (no fields) are supported.
§Example
ⓘ
use server_less::graphql_enum;
#[graphql_enum]
#[derive(Clone, Debug)]
enum Status {
/// User is active
Active,
/// User is inactive
Inactive,
/// Awaiting approval
Pending,
}
// Then register with #[graphql]:
#[graphql(enums(Status))]
impl MyService {
pub fn get_status(&self) -> Status { Status::Active }
}§Generated Methods
__graphql_enum_type() -> async_graphql::dynamic::Enum- Enum type definition__to_graphql_value(&self) -> async_graphql::Value- Convert to GraphQL value
§Variant Naming
Variant names are converted to SCREAMING_SNAKE_CASE for GraphQL:
Active→ACTIVEInProgress→IN_PROGRESS