[][src]Module wundergraph::query_builder::mutations

This module contains all functionality that is needed to implement mutations

In general mutations should just work without any additional work that writing some struct definition and deriving basic diesel for them For special cases a manual implementation of one of the for exported traits is required

Insert

The easiest way to provide a single table insert mutation is to crate a struct with all corresponding fields that derive #[derive(Insertable, GrahpQLInputobject)]


#[derive(Insertable, GraphQLInputObject, Clone, Debug)]
#[table_name = "heros"]
pub struct NewHero {
   name: String,
   species: i32,
   home_world: Option<i32>,
}

For more complex cases like inserts that involve multiple tables at one implement HandleInsert and InsertHelper manually

Update

Similar to Insert operations the easiest way to provide a single table update mutation is to create a struct with all corresponding fields that derive #[derive(AsChangeset, GraphqlInputObject, Identifiable)]


#[derive(AsChangeset, GraphQLInputObject, Identifiable, Debug)]
#[table_name = "heros"]
pub struct HeroChangeset {
    id: i32,
    name: Option<String>,
    species: Option<i32>,
    home_world: Option<i32>,
}

Structs

DeletedCount

A struct representing the number of deleted entities

Traits

HandleBatchInsert

A trait to handle batch insert mutations for database entities

HandleDelete

A trait to handle delete mutations for database entities

HandleInsert

A trait to handle insert mutations for database entities

HandleUpdate

A trait to handle update mutations for database entities