From 7fda8a97c321c4c3fab0d663a31b878823d12a010dada8a2cdb477d02dd56b62 Mon Sep 17 00:00:00 2001 From: Tyler Beckman Date: Wed, 16 Oct 2024 01:44:57 -0600 Subject: [PATCH] fix response typing on graphqlclient trait --- src/graphql/mod.rs | 19 +++++++------------ src/main.rs | 1 - 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/src/graphql/mod.rs b/src/graphql/mod.rs index 2783c19..85819f1 100644 --- a/src/graphql/mod.rs +++ b/src/graphql/mod.rs @@ -1,6 +1,5 @@ use anyhow::Context as _; use graphql_client::GraphQLQuery; -use serde::Deserialize; pub mod create_submission; pub mod get_course_assignments; @@ -8,11 +7,8 @@ pub mod get_courses; const CANVAS_GRAPHQL_URL: &str = "https://elearning.mines.edu/api/graphql"; -#[derive(Deserialize, Debug)] -pub struct GraphQLResponse { - pub data: T::ResponseData -} - +/// A trait that allows .send_query to be used on HTTP Clients (only implemented +/// for reqwest because thats whats used here and this isn't a library) pub trait GraphQLClient { /// Sends a GraphQL query using this HTTP Client. The query is /// specified using generics, which can be explicitly specified @@ -20,18 +16,17 @@ pub trait GraphQLClient { async fn send_query( &self, variables: T::Variables, - authorization: &str - ) -> anyhow::Result>; + authorization: &str, + ) -> anyhow::Result>; } impl GraphQLClient for reqwest::Client { async fn send_query( &self, variables: T::Variables, - token: &str - ) -> anyhow::Result> { - self - .post(CANVAS_GRAPHQL_URL) + token: &str, + ) -> anyhow::Result> { + self.post(CANVAS_GRAPHQL_URL) .bearer_auth(token) .json(&T::build_query(variables)) .send() diff --git a/src/main.rs b/src/main.rs index d35462e..1cff695 100644 --- a/src/main.rs +++ b/src/main.rs @@ -5,7 +5,6 @@ use graphql::{ GraphQLClient as _, }; -use graphql_client::GraphQLQuery; use types::user::CanvasUser; mod command;