leetcode_core/graphql/query/
question_content.rs

1use super::GQLLeetcodeRequest;
2use serde::Serialize;
3
4const QUERY: &str = r#"
5query questionContent($titleSlug: String!) {
6  question(titleSlug: $titleSlug) {
7    content
8    titleSlug
9  }
10}
11"#;
12
13#[derive(Serialize)]
14#[serde(rename_all = "camelCase")]
15struct Variables {
16    title_slug: String,
17}
18
19#[derive(Serialize)]
20#[serde(rename_all = "camelCase")]
21pub struct Query {
22    query: &'static str,
23    variables: Variables,
24}
25
26impl Query {
27    pub fn new(title_slug: String) -> Self {
28        Self {
29            query: QUERY,
30            variables: Variables { title_slug },
31        }
32    }
33}
34
35impl GQLLeetcodeRequest for Query {
36    type T = crate::types::question_content::Data;
37
38    fn use_cache(&self) -> bool {
39        true
40    }
41}