lesspub-schema 1.0.1

Partial Cynic GraphQL schema for LessWrong and EA Forums
Documentation
#![allow(non_snake_case)]

#[cynic::schema("lesswrong")]
pub mod schema {}

use cynic::{InputObject, QueryFragment, QueryVariables, impl_scalar};
use nestify::nest;
use serde::{Deserialize, Serialize};
use serde_with::chrono::{DateTime, Utc};
impl_scalar!(DateTime<Utc>, schema::Date);
impl_scalar!(FMCrossPost, schema::JSON);
impl_scalar!(TableOfContents, schema::JSON);

nest! {
    #[derive(QueryVariables, Clone, Debug)]
    pub struct SingleSequenceArguments {
        pub input: Option<
            #[derive(InputObject, Clone, Debug)]
            pub struct SingleSequenceInput {
                pub selector: Option<
                    #[derive(InputObject, Clone, Debug)]
                    pub struct SelectorInput {
                        pub _id: Option<String>,
                        #[cynic(skip_serializing_if="Option::is_none")]
                        pub documentId: Option<String>,
                    }
                >,
                #[cynic(skip_serializing_if="Option::is_none")]
                pub allowNull: Option<bool>,
            }
        >
    }
}

nest! {
    #[derive(QueryFragment, Serialize, Clone, Debug)]
    #[cynic(graphql_type = "Query", variables = "SingleSequenceArguments")]
    pub struct SingleSequenceQuery {
        #[arguments(input: $input)]
        pub sequence: Option<
            #[derive(QueryFragment, Serialize, Clone, Debug)]
            pub struct SingleSequenceOutput {
                pub result: Option<
                    #[derive(QueryFragment, Serialize, Clone, Debug)]
                    pub struct Sequence {
                        pub _id: Option<String>,
                        pub schemaVersion: Option<f64>,
                        pub createdAt: Option<DateTime<Utc>>,
                        pub lastUpdated: Option<DateTime<Utc>>,
                        pub userId: Option<String>,
                        pub user: Option<User>,
                        pub title: Option<String>,
                        pub draft: Option<bool>,
                        pub isDeleted: Option<bool>,
                        pub hidden: Option<bool>,
                        pub postsCount: Option<i32>,
                        pub canonicalCollection: Option<
                            #[derive(QueryFragment, Serialize, Clone, Debug)]
                            pub struct Collection {
                                pub _id: Option<String>,
                                pub slug: Option<String>,
                                pub title: Option<String>,
                                pub gridImageId: Option<String>,
                            }
                        >,
                        pub contents: Option<
                            #[derive(QueryFragment, Serialize, Clone, Debug)]
                            pub struct Revision {
                                pub _id: Option<String>,
                                pub html: Option<String>,
                            }
                        >,
                        pub bannerImageId: Option<String>,
                        pub gridImageId: Option<String>,
                        pub chapters: Option<Vec<Option<
                            #[derive(QueryFragment, Serialize, Clone, Debug)]
                            pub struct Chapter {
                                pub _id: Option<String>,
                                pub schemaVersion: Option<f64>,
                                pub createdAt: Option<DateTime<Utc>>,
                                pub title: Option<String>,
                                pub posts: Option<Vec<Option<Post>>>,
                            }
                        >>>,
                    }
                >,
            }
        >,
    }
}

#[derive(QueryFragment, Serialize, Clone, Debug)]
pub struct User {
    pub username: Option<String>,
    pub displayName: Option<String>,
}

nest! {
    #[derive(QueryFragment, Serialize, Clone, Debug)]
    pub struct Post {
        pub _id: Option<String>,
        pub schemaVersion: Option<f64>,
        pub createdAt: Option<DateTime<Utc>>,
        pub postedAt: Option<DateTime<Utc>>,
        pub modifiedAt: Option<DateTime<Utc>>,
        pub title: Option<String>,
        pub status: Option<f64>,
        pub userId: Option<String>,
        pub user: Option<User>,
        pub socialPreviewImageAutoUrl: Option<String>,
        pub eventImageId: Option<String>,
        pub sequence: Option<
            #[derive(QueryFragment, Serialize, Clone, Debug)]
            #[cynic(graphql_type = "Sequence")]
            pub struct PostSequence {
                pub bannerImageId: Option<String>,
                pub gridImageId: Option<String>,
                pub canonicalCollection: Option<Collection>
            }
        >,
        pub fmCrosspost: Option<
            #[derive(Serialize, Deserialize, Clone, Debug)]
            pub struct FMCrossPost {
                pub hostedHere: Option<bool>,
                pub isCrosspost: bool,
                pub foreignPostId: Option<String>,
            }
        >,
        pub htmlBody: Option<String>,
        pub tableOfContents: Option<
            #[derive(Serialize, Deserialize, Clone, Debug)]
            pub struct TableOfContents {
                pub html: Option<String>,
                pub sections: Vec<
                    #[derive(Serialize, Deserialize, Clone, Debug)]
                    pub struct ToCSection {
                        pub title: Option<String>,
                        pub anchor: Option<String>,
                        pub level: Option<u16>,
                        pub divider: Option<bool>,
                    }
                >,
            }
        >,
    }
}

nest! {
    #[derive(QueryFragment, Serialize, Clone, Debug)]
    #[cynic(graphql_type = "Query")]
    pub struct SequencesListQuery {
        pub sequences: Option<
            #[derive(QueryFragment, Serialize, Clone, Debug)]
            pub struct MultiSequenceOutput {
                pub results: Option<Vec<Option<
                    #[derive(QueryFragment, Serialize, Clone, Debug)]
                    #[cynic(graphql_type = "Sequence")]
                    pub struct SequenceListInfo {
                        pub _id: Option<String>,
                        pub lastUpdated: Option<DateTime<Utc>>,
                        pub postsCount: Option<i32>
                    }
                >>>,
            }
        >,
    }
}

nest! {
    #[derive(QueryVariables, Clone, Debug)]
    pub struct PostArguments {
        pub input: Option<
            #[derive(InputObject, Clone, Debug)]
            pub struct SinglePostInput {
                pub selector: Option<SelectorInput>,
                #[cynic(skip_serializing_if="Option::is_none")]
                pub allowNull: Option<bool>,
            }
        >
    }
}

nest! {
    #[derive(QueryFragment, Serialize, Clone, Debug)]
    #[cynic(graphql_type = "Query", variables = "PostArguments")]
    pub struct PostQuery {
        #[arguments(input: $input)]
        pub post: Option<
            #[derive(QueryFragment, Serialize, Clone, Debug)]
            pub struct SinglePostOutput {
                pub result: Option<Post>,
            }
        >,
    }
}