pub struct Mutation;
Expand description
Mutation struct
Implementations§
Source§impl Mutation
impl Mutation
Sourceasync fn login<'ctx>(
&self,
ctx: &Context<'ctx>,
input: LoginCredentials,
) -> FieldResult<AuthBody>
async fn login<'ctx>( &self, ctx: &Context<'ctx>, input: LoginCredentials, ) -> FieldResult<AuthBody>
Make GraphQL login
Example:
curl -X POST http://localhost:8000/graphql \
-H "Content-Type: application/json" \
-d '{
"query": "mutation Login($input: LoginCredentials!) { login(input: $input) { accessToken tokenType userId } }",
"variables": {
"input": {
"email": "***",
"password": "***"
}
}
}'
Sourceasync fn register_device<'ctx>(
&self,
ctx: &Context<'ctx>,
input: RegisterNotificationToken,
) -> FieldResult<User>
async fn register_device<'ctx>( &self, ctx: &Context<'ctx>, input: RegisterNotificationToken, ) -> FieldResult<User>
Make GraphQL call to register a notification device token for the user.
Example:
curl -X POST http://localhost:8000/graphql \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ***" \
-d '{
"query": "mutation RegisterDevice($input: RegisterNotificationToken!) { registerDevice(input: $input) { id name email } }",
"variables": {
"input": {
"token": "***",
}
}
}'
Sourceasync fn user_password_edit<'ctx>(
&self,
ctx: &Context<'ctx>,
input: UserPasswordEdit,
) -> FieldResult<User>
async fn user_password_edit<'ctx>( &self, ctx: &Context<'ctx>, input: UserPasswordEdit, ) -> FieldResult<User>
Make GraphQL call to edit their passowrd.
Example:
curl -X POST http://localhost:8000/graphql \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ***" \
-d '{
"query": "mutation UserPasswordEdit($input: UserPasswordEdit!) { userPasswordEdit(input: $input) { id email name address isAdmin } }",
"variables": {
"input": {
"password1": "***",
"password2": "***"
}
}
}'
Sourceasync fn user_edit<'ctx>(
&self,
ctx: &Context<'ctx>,
input: UserEdit,
id: i32,
) -> FieldResult<User>
async fn user_edit<'ctx>( &self, ctx: &Context<'ctx>, input: UserEdit, id: i32, ) -> FieldResult<User>
Make GraphQL call to edit an user. Not admins can edit only the user linked to the access token used.
Example:
curl -X POST http://localhost:8000/graphql \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ***" \
-d '{
"query": "mutation UserEdit($input: UserEdit!, $id: Int!) { userEdit(input: $input, id: $id) { id email name address isAdmin } }",
"variables": {
"input": {
"email": "mario.rossi@example.com",
"name": "Mario Rossi",
"address": ""
},
"id": 42
}
}'
Sourceasync fn new_position<'ctx>(
&self,
ctx: &Context<'ctx>,
input: PositionInput,
) -> FieldResult<Position>
async fn new_position<'ctx>( &self, ctx: &Context<'ctx>, input: PositionInput, ) -> FieldResult<Position>
Make GraphQL request to create new position to track
Example:
curl -X POST http://localhost:8000/graphql \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ***" \
-d '{
"query": "mutation NewPosition($input: PositionInput!) { newPosition(input: $input) { id userId createdAt latitude longitude movingActivity } }",
"variables": {
"input": {
"latitude": 44.50800643571219,
"longitude": 11.299600981136905,
"movingActivity": "STILL"
}
}
}'
Sourceasync fn new_alert<'ctx>(
&self,
ctx: &Context<'ctx>,
input: AlertInput,
) -> FieldResult<Alert>
async fn new_alert<'ctx>( &self, ctx: &Context<'ctx>, input: AlertInput, ) -> FieldResult<Alert>
Make GraphQL request to create new alert. Only for admins.
Example:
curl -X POST http://localhost:8000/graphql \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ****" \
-d '{
"query": "mutation NewAlert($input: AlertInput!) { newAlert(input: $input) { id createdAt } }",
"variables": {
"input": {
"points": [
{ "latitude": 44.490025, "longitude": 11.311499},
{ "latitude": 44.490361, "longitude": 11.327903},
{ "latitude": 44.497280, "longitude": 11.327776},
{ "latitude": 44.498321, "longitude": 11.312145},
{ "latitude": 44.490025, "longitude": 11.311498}
],
"text1": "Alert level 1",
"text2": "Alert level 2",
"text3": "Alert level 3"
}
}
}
Sourceasync fn notification_update<'ctx>(
&self,
ctx: &Context<'ctx>,
input: NotificationUpdateInput,
) -> FieldResult<Notification>
async fn notification_update<'ctx>( &self, ctx: &Context<'ctx>, input: NotificationUpdateInput, ) -> FieldResult<Notification>
Make GraphQL request to update notification seen status.
Example:
curl -X POST http://localhost:8000/graphql \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ****" \
-d '{
"query": "mutation NotificationUpdate($input: NotificationUpdateInput!) { notificationUpdate(input: $input) { id seen } }",
"variables": {
"input": {
"id": 42,
"seen": true
}
}
}
Trait Implementations§
Source§impl ContainerType for Mutation
impl ContainerType for Mutation
Source§async fn resolve_field(&self, ctx: &Context<'_>) -> ServerResult<Option<Value>>
async fn resolve_field(&self, ctx: &Context<'_>) -> ServerResult<Option<Value>>
Resolves a field value and outputs it as a json value
async_graphql::Value
. Read moreSource§async fn find_entity(
&self,
ctx: &Context<'_>,
params: &Value,
) -> ServerResult<Option<Value>>
async fn find_entity( &self, ctx: &Context<'_>, params: &Value, ) -> ServerResult<Option<Value>>
Find the GraphQL entity with the given name from the parameter. Read more
Source§impl OutputType for Mutation
impl OutputType for Mutation
Source§fn create_type_info(registry: &mut Registry) -> String
fn create_type_info(registry: &mut Registry) -> String
Create type information in the registry and return qualified typename.
Source§async fn resolve(
&self,
ctx: &ContextSelectionSet<'_>,
_field: &Positioned<Field>,
) -> ServerResult<Value>
async fn resolve( &self, ctx: &ContextSelectionSet<'_>, _field: &Positioned<Field>, ) -> ServerResult<Value>
Resolve an output value to
async_graphql::Value
.§fn qualified_type_name() -> String
fn qualified_type_name() -> String
Qualified typename.
§fn introspection_type_name(&self) -> Cow<'static, str>
fn introspection_type_name(&self) -> Cow<'static, str>
Introspection type name Read more
impl ObjectType for Mutation
Auto Trait Implementations§
impl Freeze for Mutation
impl RefUnwindSafe for Mutation
impl Send for Mutation
impl Sync for Mutation
impl Unpin for Mutation
impl UnwindSafe for Mutation
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more