#[graphql_input]Expand description
Define a GraphQL input type.
Generates a GraphQL InputObject type definition from a Rust struct.
The struct must implement serde::Deserialize for input parsing.
§Example
ⓘ
use server_less::graphql_input;
use serde::Deserialize;
#[graphql_input]
#[derive(Clone, Debug, Deserialize)]
struct CreateUserInput {
/// User's name
name: String,
/// User's email address
email: String,
/// Optional age
age: Option<i32>,
}
// Then register with #[graphql]:
#[graphql(inputs(CreateUserInput))]
impl UserService {
pub fn create_user(&self, input: CreateUserInput) -> User { /* ... */ }
}§Generated Methods
__graphql_input_type() -> async_graphql::dynamic::InputObject- Input type definition__from_graphql_value(value) -> Result<Self, String>- Parse from GraphQL value
§Field Naming
Field names are converted to camelCase for GraphQL:
user_name→userNameemail_address→emailAddress