737 B
737 B
InputObject
You can use an Object
as an argument, and GraphQL calls it an InputObject
.
The definition of InputObject
is similar to SimpleObject, but
SimpleObject
can only be used as output and InputObject
can only be used as input.
You can add optional #[graphql]
attributes to add descriptions or rename the field.
use async_graphql::*;
#[derive(InputObject)]
struct Coordinate {
latitude: f64,
longitude: f64
}
struct Mutation;
#[Object]
impl Mutation {
async fn users_at_location(&self, coordinate: Coordinate, radius: f64) -> Vec<User> {
// Writes coordination to database.
// ...
}
}