1- #![ feature( trace_macros) ]
21#![ deny( missing_debug_implementations, missing_copy_implementations) ]
3- #![ cfg_attr( feature = "cargo-clippy" , allow( renamed_and_removed_lints) ) ]
4- #![ cfg_attr( feature = "cargo-clippy" , warn( clippy) ) ]
5- // Clippy lints
6- #![ cfg_attr( feature = "cargo-clippy" , allow( type_complexity) ) ]
7- #![ cfg_attr(
8- feature = "cargo-clippy" ,
9- warn(
10- wrong_pub_self_convention,
11- used_underscore_binding,
12- use_self,
13- use_debug,
14- unseparated_literal_suffix,
15- unnecessary_unwrap,
16- unimplemented,
17- single_match_else,
18- shadow_unrelated,
19- option_map_unwrap_or_else,
20- option_map_unwrap_or,
21- needless_continue,
22- mutex_integer,
23- needless_borrow,
24- items_after_statements,
25- filter_map,
26- expl_impl_clone_on_copy,
27- else_if_without_else,
28- doc_markdown,
29- default_trait_access,
30- option_unwrap_used,
31- result_unwrap_used,
32- print_stdout,
33- wrong_pub_self_convention,
34- mut_mut,
35- non_ascii_literal,
36- similar_names,
37- unicode_not_nfc,
38- enum_glob_use,
39- if_not_else,
40- items_after_statements,
41- used_underscore_binding
42- )
2+ #![ warn(
3+ clippy:: option_unwrap_used,
4+ clippy:: result_unwrap_used,
5+ clippy:: print_stdout,
6+ clippy:: wrong_pub_self_convention,
7+ clippy:: mut_mut,
8+ clippy:: non_ascii_literal,
9+ clippy:: similar_names,
10+ clippy:: unicode_not_nfc,
11+ clippy:: enum_glob_use,
12+ clippy:: if_not_else,
13+ clippy:: items_after_statements,
14+ clippy:: used_underscore_binding,
15+ clippy:: cargo_common_metadata,
16+ clippy:: dbg_macro,
17+ clippy:: doc_markdown,
18+ clippy:: filter_map,
19+ clippy:: map_flatten,
20+ clippy:: match_same_arms,
21+ clippy:: needless_borrow,
22+ clippy:: needless_pass_by_value,
23+ clippy:: option_map_unwrap_or,
24+ clippy:: option_map_unwrap_or_else,
25+ clippy:: redundant_clone,
26+ clippy:: result_map_unwrap_or_else,
27+ clippy:: unnecessary_unwrap,
28+ clippy:: unseparated_literal_suffix,
29+ clippy:: wildcard_dependencies
30+
4331) ]
4432
4533#[ macro_use]
4634extern crate diesel;
4735#[ macro_use]
4836extern crate juniper;
49- extern crate failure;
50- extern crate indexmap;
51- extern crate wundergraph;
37+
38+ use wundergraph;
5239
5340use diesel:: backend:: Backend ;
5441use diesel:: deserialize:: { self , FromSql } ;
@@ -62,13 +49,13 @@ use std::io::Write;
6249use wundergraph:: query_helper:: { HasMany , HasOne } ;
6350use wundergraph:: scalar:: WundergraphScalarValue ;
6451use wundergraph:: WundergraphContext ;
65- use wundergraph:: { BoxedQuery , LoadingHandler , QueryModifier , ApplyOffset } ;
52+ use wundergraph:: { ApplyOffset , BoxedQuery , LoadingHandler , QueryModifier } ;
6653use wundergraph:: { WundergraphEntity , WundergraphValue } ;
6754
6855pub mod mutations;
6956use self :: mutations:: * ;
7057
71- #[ derive( Debug , Copy , Clone , AsExpression , FromSqlRow , GraphQLEnum , WundergraphValue ) ]
58+ #[ derive( Debug , Copy , Clone , AsExpression , FromSqlRow , GraphQLEnum , WundergraphValue , Eq , PartialEq , Hash ) ]
7259#[ sql_type = "SmallInt" ]
7360pub enum Episode {
7461 NEWHOPE = 1 ,
8168 DB : Backend ,
8269 i16 : ToSql < SmallInt , DB > ,
8370{
84- fn to_sql < W : Write > ( & self , out : & mut serialize:: Output < W , DB > ) -> serialize:: Result {
71+ fn to_sql < W : Write > ( & self , out : & mut serialize:: Output < ' _ , W , DB > ) -> serialize:: Result {
8572 ( * self as i16 ) . to_sql ( out)
8673 }
8774}
@@ -141,7 +128,7 @@ table! {
141128}
142129
143130#[ derive( Clone , Debug , Identifiable , Queryable , WundergraphEntity ) ]
144- #[ primary_key( hero_id) ]
131+ #[ primary_key( hero_id, episode ) ]
145132#[ table_name = "appears_in" ]
146133pub struct AppearsIn {
147134 hero_id : HasOne < i32 , Hero > ,
@@ -150,7 +137,7 @@ pub struct AppearsIn {
150137
151138#[ derive( Clone , Debug , Queryable , Eq , PartialEq , Hash , WundergraphEntity , Identifiable ) ]
152139#[ table_name = "friends" ]
153- #[ primary_key( hero_id) ]
140+ #[ primary_key( hero_id, friend_id ) ]
154141pub struct Friend {
155142 #[ wundergraph( skip) ]
156143 hero_id : i32 ,
@@ -210,9 +197,13 @@ pub struct Species {
210197}
211198
212199wundergraph:: query_object! {
200+ /// Global query object for the schema
213201 Query {
202+ /// Access to Heros
214203 Hero ,
204+ /// Access to Species
215205 Species ,
206+ /// Access to HomeWorlds
216207 HomeWorld ,
217208 }
218209}
@@ -247,9 +238,8 @@ where
247238 _select : & LookAheadSelection < ' _ , WundergraphScalarValue > ,
248239 query : BoxedQuery < ' a , T , DB , Self > ,
249240 ) -> Result < BoxedQuery < ' a , T , DB , Self > , Error > {
250- dbg ! ( T :: TYPE_NAME ) ;
251241 match T :: TYPE_NAME {
252- // "Heros" => Err(Error::from_boxed_compat(String::from("Is user").into())),
242+ // "Heros" => Err(Error::from_boxed_compat(String::from("Is user").into())),
253243 _ => Ok ( query) ,
254244 }
255245 }
0 commit comments