Skip to content

Commit 34bbd67

Browse files
authored
Merge pull request #328 from danielharbor/master
Allow disabling ssl verification on schema introspection
2 parents 32cd3c7 + c32f963 commit 34bbd67

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

graphql_client_cli/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,13 @@ cargo install graphql_client_cli --force
1414
Get the schema from a live GraphQL API. The schema is printed to stdout.
1515
1616
USAGE:
17-
graphql-client introspect-schema [OPTIONS] <schema_location>
17+
graphql-client introspect-schema [FLAGS] [OPTIONS] <schema_location>
1818
1919
FLAGS:
2020
-h, --help Prints help information
2121
-V, --version Prints version information
22+
--no-ssl Set this option to disable ssl certificate verification. Default value is false.
23+
ssl verification is turned on by default.
2224
2325
OPTIONS:
2426
--authorization <authorization> Set the contents of the Authorizaiton header.

graphql_client_cli/src/introspect_schema.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ pub fn introspect_schema(
1919
output: Option<PathBuf>,
2020
authorization: Option<String>,
2121
headers: Vec<Header>,
22+
no_ssl: bool,
2223
) -> anyhow::Result<()> {
2324
use std::io::Write;
2425

@@ -33,7 +34,9 @@ pub fn introspect_schema(
3334
operation_name: introspection_query::OPERATION_NAME,
3435
};
3536

36-
let client = reqwest::Client::new();
37+
let client = reqwest::Client::builder()
38+
.danger_accept_invalid_certs(no_ssl)
39+
.build()?;
3740

3841
let mut req_builder = client.post(location).headers(construct_headers());
3942

graphql_client_cli/src/main.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ enum Cli {
2828
/// --header 'X-Name: Value'
2929
#[structopt(long = "header")]
3030
headers: Vec<introspect_schema::Header>,
31+
/// Disable ssl verification.
32+
/// Default value is false.
33+
#[structopt(long = "no-ssl")]
34+
no_ssl: bool,
3135
},
3236
#[structopt(name = "generate")]
3337
Generate {
@@ -79,7 +83,14 @@ fn main() -> anyhow::Result<()> {
7983
output,
8084
authorization,
8185
headers,
82-
} => introspect_schema::introspect_schema(&schema_location, output, authorization, headers),
86+
no_ssl,
87+
} => introspect_schema::introspect_schema(
88+
&schema_location,
89+
output,
90+
authorization,
91+
headers,
92+
no_ssl,
93+
),
8394
Cli::Generate {
8495
variables_derives,
8596
response_derives,

0 commit comments

Comments
 (0)