Require query variables to be Copy

This commit is contained in:
Kiana Sheibani 2023-10-02 20:34:54 -04:00
parent 23ecce06d5
commit 07f95ddd17
Signed by: toki
GPG key ID: 6CB106C25E86A9F7
5 changed files with 7 additions and 7 deletions

View file

@ -77,7 +77,7 @@ pub trait QueryUnwrap<Vars>: 'static + QueryBuilder<Vars> {
// Generic function for running start.gg queries // Generic function for running start.gg queries
pub fn run_query<Builder, Vars>(vars: Vars, auth_token: &str) -> Option<Builder::Unwrapped> pub fn run_query<Builder, Vars>(vars: Vars, auth_token: &str) -> Option<Builder::Unwrapped>
where where
Vars: Clone, Vars: Copy,
Builder: QueryUnwrap<Vars>, Builder: QueryUnwrap<Vars>,
Vars: Serialize, Vars: Serialize,
for<'de> Builder: Deserialize<'de>, for<'de> Builder: Deserialize<'de>,
@ -87,14 +87,14 @@ where
let mut response = reqwest::blocking::Client::new() let mut response = reqwest::blocking::Client::new()
.post("https://api.start.gg/gql/alpha") .post("https://api.start.gg/gql/alpha")
.header("Authorization", String::from("Bearer ") + auth_token) .header("Authorization", String::from("Bearer ") + auth_token)
.run_graphql(Builder::build(vars.clone())); .run_graphql(Builder::build(vars));
for _ in 1..10 { for _ in 1..10 {
sleep(Duration::from_secs(2)); sleep(Duration::from_secs(2));
response = reqwest::blocking::Client::new() response = reqwest::blocking::Client::new()
.post("https://api.start.gg/gql/alpha") .post("https://api.start.gg/gql/alpha")
.header("Authorization", String::from("Bearer ") + auth_token) .header("Authorization", String::from("Bearer ") + auth_token)
.run_graphql(Builder::build(vars.clone())); .run_graphql(Builder::build(vars));
if response.is_ok() { if response.is_ok() {
break; break;
} }

View file

@ -6,7 +6,7 @@ pub type Teams<T> = Vec<Vec<T>>;
// Variables // Variables
#[derive(cynic::QueryVariables, Debug, Clone)] #[derive(cynic::QueryVariables, Debug, Copy, Clone)]
pub struct EventSetsVars { pub struct EventSetsVars {
pub event: EventId, pub event: EventId,
pub page: i32, pub page: i32,

View file

@ -4,7 +4,7 @@ use schema::schema;
// Variables // Variables
#[derive(cynic::QueryVariables, Debug, Clone)] #[derive(cynic::QueryVariables, Debug, Copy, Clone)]
pub struct PlayerInfoVars { pub struct PlayerInfoVars {
pub id: PlayerId, pub id: PlayerId,
} }

View file

@ -4,7 +4,7 @@ use schema::schema;
// Variables // Variables
#[derive(cynic::QueryVariables, Debug, Clone)] #[derive(cynic::QueryVariables, Debug, Copy, Clone)]
pub struct VideogameSearchVars<'a> { pub struct VideogameSearchVars<'a> {
pub name: &'a str, pub name: &'a str,
} }

View file

@ -5,7 +5,7 @@ use schema::schema;
// Variables // Variables
#[derive(cynic::QueryVariables, Debug, Clone)] #[derive(cynic::QueryVariables, Debug, Copy, Clone)]
pub struct TournamentEventsVars<'a> { pub struct TournamentEventsVars<'a> {
// HACK: This should really be an optional variable, but there seems to be a // HACK: This should really be an optional variable, but there seems to be a
// server-side bug that completely breaks everything when this isn't passed. // server-side bug that completely breaks everything when this isn't passed.