cas::graphql::mutation

Struct Mutation

Source
pub struct Mutation;
Expand description

Mutation struct

Implementations§

Source§

impl Mutation

Source

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": "***"
    }
  }
}'
Source

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": "***",
    }
  }
}'
Source

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": "***"
    }
  }
}'
Source

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
  }
}'
Source

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"
    }
  }
}'
Source

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"
    }
  }
}
Source

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

Source§

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 more
Source§

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
§

fn collect_all_fields<'a>( &'a self, ctx: &ContextBase<'a, &'a Positioned<SelectionSet>>, fields: &mut Fields<'a>, ) -> Result<(), ServerError>
where Self: Send + Sync,

Collect all the fields of the container that are queried in the selection set. Read more
Source§

impl OutputType for Mutation

Source§

fn type_name() -> Cow<'static, str>

Type the name.
Source§

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>

Resolve an output value to async_graphql::Value.
§

fn qualified_type_name() -> String

Qualified typename.
§

fn introspection_type_name(&self) -> Cow<'static, str>

Introspection type name Read more
Source§

impl ObjectType for Mutation

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more