File tree Expand file tree Collapse file tree 1 file changed +4
-7
lines changed
docs/book/content/types/objects Expand file tree Collapse file tree 1 file changed +4
-7
lines changed Original file line number Diff line number Diff line change @@ -105,24 +105,21 @@ struct Database {
105105 requested_count : HashMap <i32 , i32 >,
106106}
107107
108- impl juniper :: Context for Database {}
109-
110108struct User {
111109 id : i32 ,
112- name : String ,
113- times_requested : i32 ,
110+ name : String
114111}
115112
116- #[graphql_object(context = RwLock <Database >)]
113+ #[graphql_object(context= RwLock <Database >)]
117114impl User {
118- async fn times_requested <'db >(& self , context : & 'db RwLock <Database >) -> Vec < & ' db User > {
115+ async fn times_requested <'db >(& self , context : & 'db RwLock <Database >) -> i32 {
119116 // Acquire a mutable reference and await if async RwLock is used,
120117 // which is necessary if context consists async operations like
121118 // querying remote databases.
122119 // If context is immutable use .read() on RwLock.
123120 let mut context = context . write (). await ;
124121 // Preform a mutable operation.
125- context . requested_count. entry (self . id). and_modify (| e | { * e += 1 }). or_insert (1 )
122+ context . requested_count. entry (self . id). and_modify (| e | { * e += 1 }). or_insert (1 ). clone ()
126123 }
127124
128125 fn name (& self ) -> & str {
You can’t perform that action at this time.
0 commit comments