From 73b5e4fc43c92ebdd9db5619f822dac3928cccf2 Mon Sep 17 00:00:00 2001 From: Kiana Sheibani Date: Thu, 2 Nov 2023 15:16:35 -0400 Subject: [PATCH] Move scalar definitions to separate file --- src/queries.rs | 36 ++---------------------------------- src/queries/scalars.rs | 30 ++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 34 deletions(-) create mode 100644 src/queries/scalars.rs diff --git a/src/queries.rs b/src/queries.rs index d260646..4a6ead7 100644 --- a/src/queries.rs +++ b/src/queries.rs @@ -4,6 +4,8 @@ use std::path::Path; use std::thread::sleep; use std::time::Duration; +pub mod scalars; +pub use scalars::*; pub mod search_games; pub use search_games::*; pub mod tournament_events; @@ -40,40 +42,6 @@ pub fn get_auth_token(config_dir: &Path) -> Option { } } -pub mod scalars { - use schema::schema; - - // Types - - // HACK: Unfortunately, start.gg seems to use integers for its ID type, whereas - // cynic always assumes that IDs are strings. To get around that, we define new - // scalar types that deserialize to u64. - - #[derive(cynic::Scalar, Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] - #[cynic(graphql_type = "ID")] - pub struct VideogameId(pub u64); - - #[derive(cynic::Scalar, Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] - #[cynic(graphql_type = "ID")] - pub struct EventId(pub u64); - - #[derive(cynic::Scalar, Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] - #[cynic(graphql_type = "ID")] - pub struct EntrantId(pub u64); - - #[derive(cynic::Scalar, Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] - #[cynic(graphql_type = "ID")] - pub struct PlayerId(pub u64); - - #[derive(cynic::Scalar, Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] - #[cynic(graphql_type = "ID")] - pub struct SetId(pub u64); - - #[derive(cynic::Scalar, Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] - pub struct Timestamp(pub u64); -} -pub use scalars::*; - // Query machinery pub trait QueryUnwrap: 'static + QueryBuilder { diff --git a/src/queries/scalars.rs b/src/queries/scalars.rs new file mode 100644 index 0000000..5a8fa25 --- /dev/null +++ b/src/queries/scalars.rs @@ -0,0 +1,30 @@ +use schema::schema; + +// Types + +// HACK: Unfortunately, start.gg seems to use integers for its ID type, whereas +// cynic always assumes that IDs are strings. To get around that, we define new +// scalar types that deserialize to u64. + +#[derive(cynic::Scalar, Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] +#[cynic(graphql_type = "ID")] +pub struct VideogameId(pub u64); + +#[derive(cynic::Scalar, Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] +#[cynic(graphql_type = "ID")] +pub struct EventId(pub u64); + +#[derive(cynic::Scalar, Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] +#[cynic(graphql_type = "ID")] +pub struct EntrantId(pub u64); + +#[derive(cynic::Scalar, Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] +#[cynic(graphql_type = "ID")] +pub struct PlayerId(pub u64); + +#[derive(cynic::Scalar, Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] +#[cynic(graphql_type = "ID")] +pub struct SetId(pub u64); + +#[derive(cynic::Scalar, Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] +pub struct Timestamp(pub u64);