From f6bbed879ef835553705201f47aadf997a284fe7 Mon Sep 17 00:00:00 2001 From: Avery Harnish Date: Fri, 20 Aug 2021 11:43:42 -0500 Subject: [PATCH] fix(rover-client): send request body as string (#751) --- crates/rover-client/src/blocking/client.rs | 12 ++++++------ crates/rover-client/src/blocking/studio_client.rs | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/crates/rover-client/src/blocking/client.rs b/crates/rover-client/src/blocking/client.rs index b6e6e0f93..85c6f6e19 100644 --- a/crates/rover-client/src/blocking/client.rs +++ b/crates/rover-client/src/blocking/client.rs @@ -43,7 +43,7 @@ impl GraphQLClient { ) -> Result { let header_map = build_headers(header_map)?; let request_body = self.get_request_body::(variables)?; - let response = self.execute(&request_body, header_map)?; + let response = self.execute(request_body, header_map)?; GraphQLClient::handle_response::(response) } @@ -57,7 +57,7 @@ impl GraphQLClient { pub(crate) fn execute( &self, - request_body: &str, + request_body: String, header_map: HeaderMap, ) -> Result { tracing::trace!(request_headers = ?header_map); @@ -67,7 +67,7 @@ impl GraphQLClient { .client .post(&self.graphql_endpoint) .headers(header_map.clone()) - .json(request_body) + .body(request_body.clone()) .send() .map_err(backoff::Error::Permanent)?; @@ -247,7 +247,7 @@ mod tests { let client = ReqwestClient::new(); let graphql_client = GraphQLClient::new(&server.url(success_path), client).unwrap(); - let response = graphql_client.execute("{}", HeaderMap::new()); + let response = graphql_client.execute("{}".to_string(), HeaderMap::new()); let mock_hits = success_mock.hits(); @@ -268,7 +268,7 @@ mod tests { let graphql_client = GraphQLClient::new(&server.url(internal_server_error_path), client).unwrap(); - let response = graphql_client.execute("{}", HeaderMap::new()); + let response = graphql_client.execute("{}".to_string(), HeaderMap::new()); let mock_hits = internal_server_error_mock.hits(); @@ -288,7 +288,7 @@ mod tests { let client = ReqwestClient::new(); let graphql_client = GraphQLClient::new(&server.url(not_found_path), client).unwrap(); - let response = graphql_client.execute("{}", HeaderMap::new()); + let response = graphql_client.execute("{}".to_string(), HeaderMap::new()); let mock_hits = not_found_mock.hits(); diff --git a/crates/rover-client/src/blocking/studio_client.rs b/crates/rover-client/src/blocking/studio_client.rs index bbd4dfc3f..36fdd058a 100644 --- a/crates/rover-client/src/blocking/studio_client.rs +++ b/crates/rover-client/src/blocking/studio_client.rs @@ -41,7 +41,7 @@ impl StudioClient { ) -> Result { let header_map = self.build_studio_headers()?; let request_body = self.client.get_request_body::(variables)?; - let response = self.client.execute(&request_body, header_map)?; + let response = self.client.execute(request_body, header_map)?; GraphQLClient::handle_response::(response) }