From 53cde72ede57ed01543931dfa748910392ce86f0 Mon Sep 17 00:00:00 2001 From: Kiana Sheibani Date: Sun, 27 Aug 2023 16:44:18 -0400 Subject: [PATCH] Lightly refactor query code --- cli/src/queries.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/cli/src/queries.rs b/cli/src/queries.rs index ac03838..2e9497a 100644 --- a/cli/src/queries.rs +++ b/cli/src/queries.rs @@ -25,17 +25,16 @@ pub struct Timestamp(pub u64); // Query machinery -pub trait QueryUnwrap: QueryBuilder { +pub trait QueryUnwrap: 'static + QueryBuilder { type VarsUnwrapped; type Unwrapped; fn wrap_vars(vars: Self::VarsUnwrapped) -> Vars; - fn unwrap_response(response: GraphQlResponse) -> Option; } // Generic function for running start.gg queries -pub async fn run_query( +pub async fn run_query( vars: Builder::VarsUnwrapped, auth: &str, ) -> Option @@ -46,12 +45,12 @@ where { use cynic::http::SurfExt; - let query = Builder::build(>::wrap_vars(vars)); + let query = Builder::build(Builder::wrap_vars(vars)); let response = surf::post("https://api.start.gg/gql/alpha") .header("Authorization", String::from("Bearer ") + auth) .run_graphql(query) .await; - >::unwrap_response(response.unwrap()) + Builder::unwrap_response(response.unwrap()) }