1- use crate :: query_helper:: placeholder:: FieldListExtractor ;
1+ use crate :: query_builder:: selection:: offset:: ApplyOffset ;
2+ use crate :: query_builder:: selection:: LoadingHandler ;
23use crate :: scalar:: WundergraphScalarValue ;
3- use crate :: { LoadingHandler , ApplyOffset } ;
44use diesel:: backend:: Backend ;
55use diesel:: query_builder:: QueryFragment ;
66use diesel:: QuerySource ;
7- use juniper:: { meta, FromInputValue , GraphQLType , Registry } ;
7+ use juniper:: { meta, GraphQLType , Registry } ;
88use std:: marker:: PhantomData ;
99
1010#[ derive( Debug ) ]
1111pub struct GraphqlWrapper < T , DB , Ctx > ( T , PhantomData < ( DB , Ctx ) > ) ;
1212
13- #[ derive( Debug ) ]
14- pub struct GraphqlOrderWrapper < T , DB , Ctx > ( PhantomData < ( T , DB , Ctx ) > ) ;
15-
1613impl < T , DB , Ctx > GraphQLType < WundergraphScalarValue > for GraphqlWrapper < T , DB , Ctx >
1714where
1815 DB : Backend + ApplyOffset + ' static ,
4340 }
4441}
4542
46- #[ derive( Debug ) ]
47- pub struct OrderTypeInfo < L , DB , Ctx > ( String , PhantomData < ( L , DB , Ctx ) > ) ;
48-
49- impl < L , DB , Ctx > Default for OrderTypeInfo < L , DB , Ctx >
50- where
51- DB : Backend + ApplyOffset + ' static ,
52- L :: Table : ' static ,
53- <L :: Table as QuerySource >:: FromClause : QueryFragment < DB > ,
54- L : LoadingHandler < DB , Ctx > ,
55- DB :: QueryBuilder : Default ,
56- {
57- fn default ( ) -> Self {
58- Self ( format ! ( "{}Columns" , L :: TYPE_NAME ) , PhantomData )
59- }
60- }
61-
62- impl < T , DB , Ctx > GraphQLType < WundergraphScalarValue > for GraphqlOrderWrapper < T , DB , Ctx >
63- where
64- DB : Backend + ApplyOffset + ' static ,
65- T :: Table : ' static ,
66- <T :: Table as QuerySource >:: FromClause : QueryFragment < DB > ,
67- T : LoadingHandler < DB , Ctx > ,
68- T :: FieldList : FieldListExtractor ,
69- <T :: FieldList as FieldListExtractor >:: Out : WundergraphGraphqlHelper < T , DB , Ctx > ,
70- DB :: QueryBuilder : Default ,
71- {
72- type Context = ( ) ;
73- type TypeInfo = OrderTypeInfo < T , DB , Ctx > ;
74-
75- fn name ( info : & Self :: TypeInfo ) -> Option < & str > {
76- Some ( & info. 0 )
77- }
78-
79- fn meta < ' r > (
80- info : & Self :: TypeInfo ,
81- registry : & mut Registry < ' r , WundergraphScalarValue > ,
82- ) -> meta:: MetaType < ' r , WundergraphScalarValue >
83- where
84- WundergraphScalarValue : ' r ,
85- {
86- use crate :: query_helper:: placeholder:: WundergraphFieldList ;
87-
88- <<T :: FieldList as FieldListExtractor >:: Out as WundergraphGraphqlHelper < T , DB , Ctx > >:: order_meta :: <
89- Self ,
90- _ ,
91- > (
92- info,
93- |index| {
94- T :: FieldList :: map_table_field ( index, |index| T :: FIELD_NAMES [ index] )
95- . expect ( "Field is there" )
96- } ,
97- registry,
98- )
99- }
100- }
101-
102- impl < T , DB , Ctx > FromInputValue < WundergraphScalarValue > for GraphqlOrderWrapper < T , DB , Ctx > {
103- fn from_input_value ( _: & juniper:: InputValue < WundergraphScalarValue > ) -> Option < Self > {
104- Some ( Self ( PhantomData ) )
105- }
106- }
107-
10843pub trait WundergraphGraphqlMapper < DB , Ctx > {
10944 type GraphQLType : GraphQLType < WundergraphScalarValue , TypeInfo = ( ) > ;
11045
@@ -130,15 +65,6 @@ pub trait WundergraphGraphqlHelper<L, DB, Ctx> {
13065 ) -> meta:: MetaType < ' r , WundergraphScalarValue >
13166 where
13267 T : GraphQLType < WundergraphScalarValue , TypeInfo = ( ) > ;
133-
134- fn order_meta < ' r , T , F > (
135- info : & T :: TypeInfo ,
136- name : F ,
137- registry : & mut Registry < ' r , WundergraphScalarValue > ,
138- ) -> meta:: MetaType < ' r , WundergraphScalarValue >
139- where
140- T : GraphQLType < WundergraphScalarValue > + FromInputValue < WundergraphScalarValue > ,
141- F : Fn ( usize ) -> & ' static str ;
14268}
14369
14470macro_rules! wundergraph_graphql_helper_impl {
@@ -184,28 +110,6 @@ macro_rules! wundergraph_graphql_helper_impl {
184110 }
185111 meta:: MetaType :: Object ( ty)
186112 }
187-
188- fn order_meta<' r, Type , Fun >(
189- info: & Type :: TypeInfo ,
190- names: Fun ,
191- registry: & mut Registry <' r, WundergraphScalarValue >,
192- ) -> meta:: MetaType <' r, WundergraphScalarValue >
193- where
194- Type : GraphQLType <WundergraphScalarValue > + FromInputValue <WundergraphScalarValue >,
195- Fun : Fn ( usize ) -> & ' static str ,
196- {
197- use juniper:: meta:: EnumValue ;
198- let values = [
199- $(
200- EnumValue :: new( names( $idx) ) ,
201- ) *
202- ] ;
203- let e = registry. build_enum_type:: <Type >(
204- info,
205- & values,
206- ) ;
207- meta:: MetaType :: Enum ( e)
208- }
209113 }
210114 ) *
211115 } ;
0 commit comments