1+ use async_graphql:: { SimpleObject , Object } ;
2+ use super :: generated:: { Suppliers , PaginationResult } ;
3+
4+ // Manual GraphQL Object implementation for Suppliers
5+ // This is needed because dsync's hardcoded GraphQL template assumes a "text" field
6+ // which doesn't exist in the suppliers table
7+ #[ Object ]
8+ impl Suppliers {
9+ async fn id ( & self ) -> async_graphql:: ID {
10+ async_graphql:: ID ( self . id . to_string ( ) )
11+ }
12+
13+ async fn name ( & self ) -> & String {
14+ & self . name
15+ }
16+
17+ async fn address ( & self ) -> & String {
18+ & self . address
19+ }
20+
21+ async fn city ( & self ) -> & String {
22+ & self . city
23+ }
24+
25+ async fn state ( & self ) -> & String {
26+ & self . state
27+ }
28+
29+ async fn zip_code ( & self ) -> & String {
30+ & self . zip_code
31+ }
32+
33+ async fn country ( & self ) -> & String {
34+ & self . country
35+ }
36+
37+ async fn contact_name ( & self ) -> & String {
38+ & self . contact_name
39+ }
40+
41+ async fn contact_email ( & self ) -> & String {
42+ & self . contact_email
43+ }
44+
45+ async fn contact_phone ( & self ) -> & String {
46+ & self . contact_phone
47+ }
48+
49+ async fn website ( & self ) -> & Option < String > {
50+ & self . website
51+ }
52+
53+ async fn created_at ( & self ) -> & chrono:: DateTime < chrono:: Utc > {
54+ & self . created_at
55+ }
56+
57+ async fn updated_at ( & self ) -> & chrono:: DateTime < chrono:: Utc > {
58+ & self . updated_at
59+ }
60+ }
61+
62+ // Manual GraphQL SimpleObject implementation for PaginationResult<Suppliers>
63+ // This is needed because dsync disabled GraphQL generation for suppliers
64+ #[ derive( SimpleObject ) ]
65+ #[ graphql( name = "SupplierPaginationResult" ) ]
66+ pub struct SupplierPaginationResult {
67+ /// Resulting items that are from the current page
68+ pub items : Vec < Suppliers > ,
69+ /// The count of total items there are
70+ pub total_items : i64 ,
71+ /// Current page, 0-based index
72+ pub page : i64 ,
73+ /// Size of a page
74+ pub page_size : i64 ,
75+ /// Number of total possible pages, given the `page_size` and `total_items`
76+ pub num_pages : i64 ,
77+ }
78+
79+ impl From < PaginationResult < Suppliers > > for SupplierPaginationResult {
80+ fn from ( result : PaginationResult < Suppliers > ) -> Self {
81+ Self {
82+ items : result. items ,
83+ total_items : result. total_items ,
84+ page : result. page ,
85+ page_size : result. page_size ,
86+ num_pages : result. num_pages ,
87+ }
88+ }
89+ }
0 commit comments