leetcode_core/graphql/query/
editor_data.rs1use super::GQLLeetcodeRequest;
2use serde::Serialize;
3
4const QUERY: &str = r#"
5query questionEditorData($titleSlug: String!) {
6 question(titleSlug: $titleSlug) {
7 questionId
8 titleSlug
9 questionFrontendId
10 content
11 codeSnippets {
12 lang
13 langSlug
14 code
15 }
16 envInfo
17 enableRunCode
18 }
19}
20"#;
21
22#[derive(Serialize)]
23#[serde(rename_all = "camelCase")]
24struct Variables {
25 title_slug: String,
26}
27
28#[derive(Serialize)]
29#[serde(rename_all = "camelCase")]
30pub struct Query {
31 query: &'static str,
32 variables: Variables,
33}
34
35impl Query {
36 pub fn new(title_slug: String) -> Self {
37 Self {
38 query: QUERY,
39 variables: Variables { title_slug },
40 }
41 }
42}
43
44impl GQLLeetcodeRequest for Query {
45 type T = crate::types::editor_data::QuestionData;
46
47 fn use_cache(&self) -> bool {
48 true
49 }
50}