1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
//! 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)]`
//! ```rust
//! # #[macro_use]
//! # extern crate diesel;
//! # #[macro_use]
//! # extern crate juniper;
//! # table! {
//! #    heros {
//! #        id -> Integer,
//! #        name -> Text,
//! #        species -> Nullable<Integer>,
//! #        home_world -> Nullable<Integer>,
//! #    }
//! # }
//!
//! #[derive(Insertable, GraphQLInputObject, Clone, Debug)]
//! #[table_name = "heros"]
//! pub struct NewHero {
//!    name: String,
//!    species: i32,
//!    home_world: Option<i32>,
//! }
//! # fn main() {}
//! ```
//!
//! For more complex cases like inserts that involve multiple tables at one
//! implement [`HandleInsert`](trait.HandleInsert.html) and
//! [`InsertHelper`](trait.InsertHelper.html) 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)]`
//! ```rust
//! # #[macro_use]
//! # extern crate diesel;
//! # #[macro_use]
//! # extern crate juniper;
//! # table! {
//! #    heros {
//! #        id -> Integer,
//! #        name -> Text,
//! #        species -> Nullable<Integer>,
//! #        home_world -> Nullable<Integer>,
//! #    }
//! # }
//!
//! #[derive(AsChangeset, GraphQLInputObject, Identifiable, Debug)]
//! #[table_name = "heros"]
//! pub struct HeroChangeset {
//!     id: i32,
//!     name: Option<String>,
//!     species: Option<i32>,
//!     home_world: Option<i32>,
//! }
//! # fn main() {}
//! ```

mod delete;
mod insert;
mod update;

#[doc(inline)]
pub use self::delete::{DeletedCount, HandleDelete};
#[doc(inline)]
pub use self::insert::{HandleBatchInsert, HandleInsert};
#[doc(inline)]
pub use self::update::HandleUpdate;

#[doc(hidden)]
pub use self::delete::handle_delete;
#[doc(hidden)]
pub use self::insert::{handle_batch_insert, handle_insert};
#[doc(hidden)]
pub use self::update::handle_update;