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 contents: Option<
67                            #[derive(QueryFragment, Serialize, Clone, Debug)]
68                            pub struct Revision {
69                                pub _id: Option<String>,
70                                pub html: Option<String>,
71                            }
72                        >,
73                        pub bannerImageId: Option<String>,
74                        pub gridImageId: Option<String>,
75                        pub chapters: Option<Vec<Option<
76                            #[derive(QueryFragment, Serialize, Clone, Debug)]
77                            pub struct Chapter {
78                                pub _id: Option<String>,
79                                pub schemaVersion: Option<f64>,
80                                pub createdAt: Option<DateTime<Utc>>,
81                                pub title: Option<String>,
82                                pub posts: Option<Vec<Option<Post>>>,
83                            }
84                        >>>,
85                    }
86                >,
87            }
88        >,
89    }
90}
91
92#[derive(QueryFragment, Serialize, Clone, Debug)]
93pub struct User {
94    pub username: Option<String>,
95    pub displayName: Option<String>,
96}
97
98nest! {
99    #[derive(QueryFragment, Serialize, Clone, Debug)]
100    pub struct Post {
101        pub _id: Option<String>,
102        pub schemaVersion: Option<f64>,
103        pub createdAt: Option<DateTime<Utc>>,
104        pub postedAt: Option<DateTime<Utc>>,
105        pub modifiedAt: Option<DateTime<Utc>>,
106        pub title: Option<String>,
107        pub status: Option<f64>,
108        pub userId: Option<String>,
109        pub user: Option<User>,
110        pub socialPreviewImageAutoUrl: Option<String>,
111        pub eventImageId: Option<String>,
112        pub sequence: Option<
113            #[derive(QueryFragment, Serialize, Clone, Debug)]
114            #[cynic(graphql_type = "Sequence")]
115            pub struct PostSequence {
116                pub bannerImageId: Option<String>,
117                pub gridImageId: Option<String>,
118                pub canonicalCollection: Option<Collection>
119            }
120        >,
121        pub fmCrosspost: Option<
122            #[derive(Serialize, Deserialize, Clone, Debug)]
123            pub struct FMCrossPost {
124                pub hostedHere: Option<bool>,
125                pub isCrosspost: bool,
126                pub foreignPostId: Option<String>,
127            }
128        >,
129        pub htmlBody: Option<String>,
130        pub tableOfContents: Option<
131            #[derive(Serialize, Deserialize, Clone, Debug)]
132            pub struct TableOfContents {
133                pub html: Option<String>,
134                pub sections: Vec<
135                    #[derive(Serialize, Deserialize, Clone, Debug)]
136                    pub struct ToCSection {
137                        pub title: Option<String>,
138                        pub anchor: Option<String>,
139                        pub level: Option<u16>,
140                        pub divider: Option<bool>,
141                    }
142                >,
143            }
144        >,
145    }
146}
147
148nest! {
149    #[derive(QueryFragment, Serialize, Clone, Debug)]
150    #[cynic(graphql_type = "Query")]
151    pub struct SequencesListQuery {
152        pub sequences: Option<
153            #[derive(QueryFragment, Serialize, Clone, Debug)]
154            pub struct MultiSequenceOutput {
155                pub results: Option<Vec<Option<
156                    #[derive(QueryFragment, Serialize, Clone, Debug)]
157                    #[cynic(graphql_type = "Sequence")]
158                    pub struct SequenceListInfo {
159                        pub _id: Option<String>,
160                        pub lastUpdated: Option<DateTime<Utc>>,
161                        pub postsCount: Option<i32>
162                    }
163                >>>,
164            }
165        >,
166    }
167}
168
169nest! {
170    #[derive(QueryVariables, Clone, Debug)]
171    pub struct PostArguments {
172        pub input: Option<
173            #[derive(InputObject, Clone, Debug)]
174            pub struct SinglePostInput {
175                pub selector: Option<SelectorInput>,
176                #[cynic(skip_serializing_if="Option::is_none")]
177                pub allowNull: Option<bool>,
178            }
179        >
180    }
181}
182
183nest! {
184    #[derive(QueryFragment, Serialize, Clone, Debug)]
185    #[cynic(graphql_type = "Query", variables = "PostArguments")]
186    pub struct PostQuery {
187        #[arguments(input: $input)]
188        pub post: Option<
189            #[derive(QueryFragment, Serialize, Clone, Debug)]
190            pub struct SinglePostOutput {
191                pub result: Option<Post>,
192            }
193        >,
194    }
195}