[−][src]Macro wundergraph::mutation_object
Macro to register the main mutation object
Annotated example
#[macro_use] #[derive(WundergraphEntity, Identifiable)] #[table_name = "heros"] pub struct Hero { id: i32, name: String, species: HasOne<i32, Species>, } #[derive(Insertable, GraphQLInputObject)] #[table_name = "heros"] pub struct NewHero { name: String, species: i32, } #[derive(AsChangeset, Identifiable, GraphQLInputObject)] #[table_name = "heros"] pub struct HeroChangeset { id: i32, name: String, } wundergraph::mutation_object! { // The main mutation object. The provided name // maps directly to the generated struct which // could be used then as juniper GraphQL struct /// An optional doc comment describing the main mutation object /// Rendered as GraphQL description Mutation { // Register mutations for a wundergraph GraphQL entity // // Each field has a set of optional arguments: // * insert: Specifies the used insert handler. // Possible values: a struct implementing // HandleInsert and HandleBatchInsert // If not set or set to false no insert mutation is // generated for the current entity // * update: Specifies the used update handler. // Possible values: a struct implementing // HandleUpdate. // If not set or set to false no update mutation is // generated for the current entity // * delete: Specifies the used delete handler. // Possible values: true, false or a struct implementing // HandleDelete. // If not set or set to fals no delete mutation is generatet, // if set to true a default delete mutation based on the // primary keys is generated // // At least on of the arguments in required Hero(insert = NewHero, update = HeroChangeset, delete = true), Species(insert = false, update = false, delete = true) } }