Skip to content

Commit 9fb5108

Browse files
committed
feat: added locale codes query
1 parent 4d77eaa commit 9fb5108

4 files changed

Lines changed: 51 additions & 17 deletions

File tree

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
use serde::Deserialize;
2+
use serde::Serialize;
3+
4+
use super::LocaleCodeDefinition;
5+
6+
const LOCALE_CODES_QUERY: &str = "
7+
{
8+
locale_codes: __type(name: \"LocaleCode\") {
9+
enumValues {
10+
name
11+
}
12+
}
13+
}
14+
";
15+
16+
graphql_query_builder! {
17+
LocaleCodesRequest,
18+
LocaleCodesRequestBody,
19+
Variables,
20+
LOCALE_CODES_QUERY,
21+
LocaleCodesResponseBody,
22+
LocaleCodesResponseData,
23+
FetchLocaleCodes,
24+
FetchActionLocaleCodes
25+
}
26+
27+
#[derive(Debug, Clone, Default, Serialize, Deserialize, PartialEq, Eq)]
28+
pub struct Variables {}
29+
30+
#[derive(Debug, Clone, Default, Serialize, Deserialize, PartialEq, Eq)]
31+
pub struct LocaleCodesResponseData {
32+
pub locale_codes: LocaleCodeDefinition,
33+
}

thoth-app/src/models/locale/mod.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
use serde::Deserialize;
2+
use serde::Serialize;
3+
use thoth_api::model::locale::LocaleCode;
4+
5+
#[derive(Debug, Clone, Default, Serialize, Deserialize, PartialEq, Eq)]
6+
#[serde(rename_all = "camelCase")]
7+
pub struct LocaleCodeDefinition {
8+
pub enum_values: Vec<LocaleCodeValues>,
9+
}
10+
11+
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
12+
#[serde(rename_all = "camelCase")]
13+
pub struct LocaleCodeValues {
14+
pub name: LocaleCode,
15+
}
16+
17+
pub mod locale_codes_query;

thoth-app/src/models/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ pub mod imprint;
185185
pub mod institution;
186186
pub mod issue;
187187
pub mod language;
188+
pub mod locale;
188189
pub mod location;
189190
pub mod price;
190191
pub mod publication;

thoth-app/src/models/title/mod.rs

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,3 @@
1-
use serde::Deserialize;
2-
use serde::Serialize;
3-
use thoth_api::model::language::LanguageRelation;
4-
use thoth_api::model::locale::LocaleCode;
5-
6-
#[derive(Debug, Clone, Default, Serialize, Deserialize, PartialEq, Eq)]
7-
#[serde(rename_all = "camelCase")]
8-
pub struct LocaleCodeDefinition {
9-
pub enum_values: Vec<LocaleCodeValues>,
10-
}
11-
12-
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
13-
#[serde(rename_all = "camelCase")]
14-
pub struct LocaleCodeValues {
15-
pub name: LocaleCode,
16-
}
17-
181
pub mod create_title_mutation;
192
pub mod delete_title_mutation;
203
pub mod update_title_mutation;

0 commit comments

Comments
 (0)