From 17c139f69455c8e6e8e34a717ee08ad780e3f19f Mon Sep 17 00:00:00 2001 From: Kiana Sheibani Date: Sun, 27 Aug 2023 03:11:23 -0400 Subject: [PATCH] Fix ID bug --- Cargo.lock | 77 +++++++++++++++++++++++++++++++++ cli/Cargo.toml | 1 + cli/src/queries.rs | 8 ++++ cli/src/queries/search_games.rs | 3 +- 4 files changed, 88 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index d629597..d989fae 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -303,6 +303,7 @@ dependencies = [ "dirs", "futures", "schema", + "serde", "surf", ] @@ -522,6 +523,27 @@ dependencies = [ "generic-array", ] +[[package]] +name = "dirs" +version = "5.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44c45a9d03d6676652bcb5e724c7e988de1acad23a711b5217ab9cbecbec2225" +dependencies = [ + "dirs-sys", +] + +[[package]] +name = "dirs-sys" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "520f05a5cbd335fae5a99ff7a6ab8627577660ee5cfd6a94a6a929b52ff0321c" +dependencies = [ + "libc", + "option-ext", + "redox_users", + "windows-sys", +] + [[package]] name = "discard" version = "1.0.4" @@ -605,6 +627,21 @@ dependencies = [ "percent-encoding", ] +[[package]] +name = "futures" +version = "0.3.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23342abe12aba583913b2e62f22225ff9c950774065e4bfb61a19cd9770fec40" +dependencies = [ + "futures-channel", + "futures-core", + "futures-executor", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] + [[package]] name = "futures-channel" version = "0.3.28" @@ -612,6 +649,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "955518d47e09b25bbebc7a18df10b81f0c766eaf4c4f1cccef2fca5f2a4fb5f2" dependencies = [ "futures-core", + "futures-sink", ] [[package]] @@ -620,6 +658,17 @@ version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4bca583b7e26f571124fe5b7561d49cb2868d79116cfa0eefce955557c6fee8c" +[[package]] +name = "futures-executor" +version = "0.3.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccecee823288125bd88b4d7f565c9e58e41858e47ab72e8ea2d64e93624386e0" +dependencies = [ + "futures-core", + "futures-task", + "futures-util", +] + [[package]] name = "futures-io" version = "0.3.28" @@ -670,9 +719,11 @@ version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "26b01e40b772d54cf6c6d721c1d1abd0647a0106a12ecaa1c186273392a69533" dependencies = [ + "futures-channel", "futures-core", "futures-io", "futures-macro", + "futures-sink", "futures-task", "memchr", "pin-project-lite", @@ -1020,6 +1071,12 @@ dependencies = [ "vcpkg", ] +[[package]] +name = "option-ext" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" + [[package]] name = "ouroboros" version = "0.15.6" @@ -1245,6 +1302,26 @@ dependencies = [ "rand_core 0.5.1", ] +[[package]] +name = "redox_syscall" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" +dependencies = [ + "bitflags", +] + +[[package]] +name = "redox_users" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b" +dependencies = [ + "getrandom 0.2.10", + "redox_syscall", + "thiserror", +] + [[package]] name = "ref-cast" version = "1.0.20" diff --git a/cli/Cargo.toml b/cli/Cargo.toml index 48ec65c..06c414c 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -13,6 +13,7 @@ cynic = { version = "3.2", features = ["http-surf"] } surf = "2" dirs = "5.0" futures = "0.3" +serde = "1.0" [build-dependencies] cynic-codegen = "3.2" diff --git a/cli/src/queries.rs b/cli/src/queries.rs index a6af99c..d7706cf 100644 --- a/cli/src/queries.rs +++ b/cli/src/queries.rs @@ -1,2 +1,10 @@ pub mod search_games; + +use schema::schema; + +/// 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 a +/// new scalar type that serializes to u64. +#[derive(cynic::Scalar, Debug)] +pub struct ID(u64); diff --git a/cli/src/queries/search_games.rs b/cli/src/queries/search_games.rs index e08c055..7b62a00 100644 --- a/cli/src/queries/search_games.rs +++ b/cli/src/queries/search_games.rs @@ -1,5 +1,6 @@ use schema::schema; +use super::ID; // VARIABLES @@ -24,6 +25,6 @@ pub struct VideogameConnection { #[derive(cynic::QueryFragment, Debug)] pub struct Videogame { - pub id: Option + pub id: Option, pub name: Option, }