Skip to content

Commit

Permalink
chore: updates introspector-gadget (#1386)
Browse files Browse the repository at this point in the history
  • Loading branch information
EverlastingBugstopper authored Oct 25, 2022
1 parent cebc9b7 commit b05464d
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 51 deletions.
6 changes: 2 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ apollo-federation-types = { git = "https://github.com/apollographql/federation-r
billboard = { git = "https://github.com/EverlastingBugstopper/billboard.git", branch = "main" }

# https://github.com/apollographql/introspector-gadget
introspector-gadget = "0.1"
introspector-gadget = "0.2"

# https://github.com/EverlastingBugstopper/awc
saucer = { git = "https://github.com/EverlastingBugstopper/awc.git", rev = "fd8df605e39fdbdf4985f255a7390afccc2600cd" }
Expand Down
10 changes: 5 additions & 5 deletions crates/rover-client/src/blocking/studio_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ use introspector_gadget::error::RoverClientError as IntrospectorGadgetError;
use houston::{Credential, CredentialOrigin};

use graphql_client::GraphQLQuery;
use reqwest::blocking::Client as ReqwestClient;
use reqwest::header::{HeaderMap, HeaderValue};
use reqwest::{blocking::Client as ReqwestClient, Error as ReqwestError};

/// Represents a client for making GraphQL requests to Apollo Studio.
pub struct StudioClient {
Expand All @@ -28,13 +28,13 @@ impl StudioClient {
version: &str,
is_sudo: bool,
client: ReqwestClient,
) -> Result<StudioClient, ReqwestError> {
Ok(StudioClient {
) -> StudioClient {
StudioClient {
credential,
client: GraphQLClient::new(graphql_endpoint, client)?,
client: GraphQLClient::new(graphql_endpoint, client),
version: version.to_string(),
is_sudo,
})
}
}

/// Client method for making a GraphQL request to Apollo Studio.
Expand Down
37 changes: 0 additions & 37 deletions crates/rover-client/tests/client.rs
Original file line number Diff line number Diff line change
@@ -1,42 +1,5 @@
use reqwest::blocking::Client;
const STUDIO_PROD_API_ENDPOINT: &str = "https://api.apollographql.com/graphql";

pub(crate) fn get_client() -> Client {
Client::builder()
.gzip(true)
.brotli(true)
.build()
.expect("Could not create reqwest Client")
}

#[cfg(test)]
mod tests {
use super::*;
use houston::{Credential, CredentialOrigin};
use rover_client::blocking::{GraphQLClient, StudioClient};

use crate::STUDIO_PROD_API_ENDPOINT;

#[test]
fn it_can_build_client() {
assert!(GraphQLClient::new(STUDIO_PROD_API_ENDPOINT, get_client()).is_ok(),);
}

#[test]
fn it_can_build_studio_client() {
assert!(StudioClient::new(
Credential {
api_key: "api:key:here".to_string(),
origin: CredentialOrigin::EnvVar,
},
"0.1.0",
STUDIO_PROD_API_ENDPOINT,
false,
get_client(),
)
.is_ok());
}

#[test]
fn schema_at_stable_path() {
// this path must remain stable as we upload it as part of our release process
Expand Down
2 changes: 1 addition & 1 deletion src/command/graph/introspect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ impl Introspect {
}

pub fn exec(&self, client: &Client, should_retry: bool) -> Result<String> {
let client = GraphQLClient::new(self.opts.endpoint.as_ref(), client.clone())?;
let client = GraphQLClient::new(self.opts.endpoint.as_ref(), client.clone());

// add the flag headers to a hashmap to pass along to rover-client
let mut headers = HashMap::new();
Expand Down
2 changes: 1 addition & 1 deletion src/command/subgraph/introspect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ impl Introspect {
}

pub fn exec(&self, client: &Client, should_retry: bool) -> Result<String> {
let client = GraphQLClient::new(self.opts.endpoint.as_ref(), client.clone())?;
let client = GraphQLClient::new(self.opts.endpoint.as_ref(), client.clone());

// add the flag headers to a hashmap to pass along to rover-client
let mut headers = HashMap::new();
Expand Down
2 changes: 1 addition & 1 deletion src/command/supergraph/resolve_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ pub(crate) fn resolve_supergraph_yaml(
// given a federated introspection URL, use subgraph introspect to
// obtain SDL and add it to subgraph_definition.
let client =
GraphQLClient::new(subgraph_url.as_ref(), client_config.get_reqwest_client()?)?;
GraphQLClient::new(subgraph_url.as_ref(), client_config.get_reqwest_client()?);

let introspection_response = introspect::run(
SubgraphIntrospectInput {
Expand Down
2 changes: 1 addition & 1 deletion src/utils/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,6 @@ impl StudioClientConfig {
&self.version,
self.is_sudo,
self.get_reqwest_client()?,
)?)
))
}
}

0 comments on commit b05464d

Please sign in to comment.