lesspub_schema/
lib.rs

1#![allow(non_snake_case)]
2
3#[cynic::schema("lesswrong")]
4pub mod schema {}
5
6use cynic::{InputObject, QueryFragment, QueryVariables, impl_scalar};
7use nestify::nest;
8use serde::{Deserialize, Serialize};
9use serde_with::chrono::{DateTime, Utc};
10impl_scalar!(DateTime<Utc>, schema::Date);
11impl_scalar!(FMCrossPost, schema::JSON);
12impl_scalar!(TableOfContents, schema::JSON);
13
14nest! {
15    #[derive(QueryVariables, Clone, Debug)]
16    pub struct SingleSequenceArguments {
17        pub input: Option<
18            #[derive(InputObject, Clone, Debug)]
19            pub struct SingleSequenceInput {
20                pub selector: Option<
21                    #[derive(InputObject, Clone, Debug)]
22                    pub struct SelectorInput {
23                        pub _id: Option<String>,
24                        #[cynic(skip_serializing_if="Option::is_none")]
25                        pub documentId: Option<String>,
26                    }
27                >,
28                #[cynic(skip_serializing_if="Option::is_none")]
29                pub allowNull: Option<bool>,
30            }
31        >
32    }
33}
34
35nest! {
36    #[derive(QueryFragment, Serialize, Clone, Debug)]
37    #[cynic(graphql_type = "Query", variables = "SingleSequenceArguments")]
38    pub struct SingleSequenceQuery {
39        #[arguments(input: $input)]
40        pub sequence: Option<
41            #[derive(QueryFragment, Serialize, Clone, Debug)]
42            pub struct SingleSequenceOutput {
43                pub result: Option<
44                    #[derive(QueryFragment, Serialize, Clone, Debug)]
45                    pub struct Sequence {
46                        pub _id: Option<String>,
47                        pub schemaVersion: Option<f64>,
48                        pub createdAt: Option<DateTime<Utc>>,
49                        pub lastUpdated: Option<DateTime<Utc>>,
50                        pub userId: Option<String>,
51                        pub user: Option<User>,
52                        pub title: Option<String>,
53                        pub draft: Option<bool>,
54                        pub isDeleted: Option<bool>,
55                        pub hidden: Option<bool>,
56                        pub postsCount: Option<i32>,
57                        pub canonicalCollection: Option<
58                            #[derive(QueryFragment, Serialize, Clone, Debug)]
59                            pub struct Collection {
60                                pub _id: Option<String>,
61                                pub slug: Option<String>,
62                                pub title: Option<String>,
63                                pub gridImageId: Option<String>,
64                            }
65                        >,
66                        pub bannerImageId: Option<String>,
67                        pub gridImageId: Option<String>,
68                        pub chapters: Option<Vec<Option<
69                            #[derive(QueryFragment, Serialize, Clone, Debug)]
70                            pub struct Chapter {
71                                pub _id: Option<String>,
72                                pub schemaVersion: Option<f64>,
73                                pub createdAt: Option<DateTime<Utc>>,
74                                pub title: Option<String>,
75                                pub posts: Option<Vec<Option<Post>>>,
76                            }
77                        >>>,
78                    }
79                >,
80            }
81        >,
82    }
83}
84
85#[derive(QueryFragment, Serialize, Clone, Debug)]
86pub struct User {
87    pub username: Option<String>,
88    pub displayName: Option<String>,
89}
90
91nest! {
92    #[derive(QueryFragment, Serialize, Clone, Debug)]
93    pub struct Post {
94        pub _id: Option<String>,
95        pub schemaVersion: Option<f64>,
96        pub createdAt: Option<DateTime<Utc>>,
97        pub postedAt: Option<DateTime<Utc>>,
98        pub modifiedAt: Option<DateTime<Utc>>,
99        pub title: Option<String>,
100        pub status: Option<f64>,
101        pub userId: Option<String>,
102        pub user: Option<User>,
103        pub socialPreviewImageAutoUrl: Option<String>,
104        pub eventImageId: Option<String>,
105        pub sequence: Option<
106            #[derive(QueryFragment, Serialize, Clone, Debug)]
107            #[cynic(graphql_type = "Sequence")]
108            pub struct PostSequence {
109                pub bannerImageId: Option<String>,
110                pub gridImageId: Option<String>,
111                pub canonicalCollection: Option<Collection>
112            }
113        >,
114        pub fmCrosspost: Option<
115            #[derive(Serialize, Deserialize, Clone, Debug)]
116            pub struct FMCrossPost {
117                pub hostedHere: Option<bool>,
118                pub isCrosspost: bool,
119                pub foreignPostId: Option<String>,
120            }
121        >,
122        pub htmlBody: Option<String>,
123        pub tableOfContents: Option<
124            #[derive(Serialize, Deserialize, Clone, Debug)]
125            pub struct TableOfContents {
126                pub html: Option<String>,
127                pub sections: Vec<
128                    #[derive(Serialize, Deserialize, Clone, Debug)]
129                    pub struct ToCSection {
130                        pub title: Option<String>,
131                        pub anchor: Option<String>,
132                        pub level: Option<u16>,
133                        pub divider: Option<bool>,
134                    }
135                >,
136            }
137        >,
138    }
139}
140
141nest! {
142    #[derive(QueryFragment, Serialize, Clone, Debug)]
143    #[cynic(graphql_type = "Query")]
144    pub struct SequencesListQuery {
145        pub sequences: Option<
146            #[derive(QueryFragment, Serialize, Clone, Debug)]
147            pub struct MultiSequenceOutput {
148                pub results: Option<Vec<Option<
149                    #[derive(QueryFragment, Serialize, Clone, Debug)]
150                    #[cynic(graphql_type = "Sequence")]
151                    pub struct SequenceListInfo {
152                        pub _id: Option<String>,
153                        pub lastUpdated: Option<DateTime<Utc>>,
154                        pub postsCount: Option<i32>
155                    }
156                >>>,
157            }
158        >,
159    }
160}
161
162nest! {
163    #[derive(QueryVariables, Clone, Debug)]
164    pub struct PostArguments {
165        pub input: Option<
166            #[derive(InputObject, Clone, Debug)]
167            pub struct SinglePostInput {
168                pub selector: Option<SelectorInput>,
169                #[cynic(skip_serializing_if="Option::is_none")]
170                pub allowNull: Option<bool>,
171            }
172        >
173    }
174}
175
176nest! {
177    #[derive(QueryFragment, Serialize, Clone, Debug)]
178    #[cynic(graphql_type = "Query", variables = "PostArguments")]
179    pub struct PostQuery {
180        #[arguments(input: $input)]
181        pub post: Option<
182            #[derive(QueryFragment, Serialize, Clone, Debug)]
183            pub struct SinglePostOutput {
184                pub result: Option<Post>,
185            }
186        >,
187    }
188}