Skip to content

Commit dfe55ec

Browse files
Add option to disable ssl verification on introspect-schema command
1 parent 32cd3c7 commit dfe55ec

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-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: 2 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,7 @@ 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().danger_accept_invalid_certs(no_ssl).build()?;
3738

3839
let mut req_builder = client.post(location).headers(construct_headers());
3940

graphql_client_cli/src/main.rs

Lines changed: 6 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,8 @@ 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(&schema_location, output, authorization, headers, no_ssl),
8388
Cli::Generate {
8489
variables_derives,
8590
response_derives,

0 commit comments

Comments
 (0)