Skip to content

Commit 3d6ba53

Browse files
committed
Fix last compiler errors
1 parent 8bea26a commit 3d6ba53

File tree

7 files changed

+26
-31
lines changed

7 files changed

+26
-31
lines changed

examples/github/examples/github.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use ::reqwest::blocking::Client;
12
use anyhow::*;
23
use graphql_client::*;
34
use log::*;
@@ -51,9 +52,7 @@ fn main() -> Result<(), anyhow::Error> {
5152
name: name.to_string(),
5253
});
5354

54-
let client = reqwest::blocking::Client::builder()
55-
.user_agent("graphql-rust/0.9.0")
56-
.build()?;
55+
let client = Client::builder().user_agent("graphql-rust/0.9.0").build()?;
5756

5857
let res = client
5958
.post("https://api.github.com/graphql")

examples/hasura/examples/hasura.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use ::reqwest::blocking::Client;
12
use graphql_client::*;
23
use log::*;
34
use prettytable::*;
@@ -28,7 +29,7 @@ fn main() -> Result<(), anyhow::Error> {
2829
update_columns: vec![Name, Status, SalesforceUpdatedAt],
2930
});
3031

31-
let client = reqwest::blocking::Client::new();
32+
let client = Client::new();
3233

3334
let res = client
3435
.post("https://localhost:8080/v1/graphql")

examples/web/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,5 @@ features = [
2828
"HtmlBodyElement",
2929
"HtmlDocument",
3030
"HtmlElement",
31+
"Window",
3132
]

graphql_client_cli/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ name = "graphql-client"
1212
path = "src/main.rs"
1313

1414
[dependencies]
15-
anyhow = "1.0"
1615
reqwest = { version = "^0.11", features = ["json", "blocking"] }
1716
graphql_client = { version = "0.9.0", path = "../graphql_client", default-features = false, features = ["graphql_query_derive"] }
1817
graphql_client_codegen = { path = "../graphql_client_codegen/", version = "0.9.0" }

graphql_client_cli/src/generate.rs

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
use anyhow::*;
21
use graphql_client_codegen::{
32
generate_module_token_stream, CodegenMode, GraphQLClientCodegenOptions,
43
};
@@ -21,7 +20,7 @@ pub(crate) struct CliCodegenParams {
2120
pub custom_scalars_module: Option<String>,
2221
}
2322

24-
pub(crate) fn generate_code(params: CliCodegenParams) -> Result<()> {
23+
pub(crate) fn generate_code(params: CliCodegenParams) {
2524
let CliCodegenParams {
2625
variables_derives,
2726
response_derives,
@@ -63,12 +62,8 @@ pub(crate) fn generate_code(params: CliCodegenParams) -> Result<()> {
6362
}
6463

6564
if let Some(custom_scalars_module) = custom_scalars_module {
66-
let custom_scalars_module = syn::parse_str(&custom_scalars_module).with_context(|| {
67-
format!(
68-
"Invalid custom scalars module path: {}",
69-
custom_scalars_module
70-
)
71-
})?;
65+
let custom_scalars_module =
66+
syn::parse_str(&custom_scalars_module).expect("Invalid custom scalar module path");
7267

7368
options.set_custom_scalars_module(custom_scalars_module);
7469
}
@@ -85,18 +80,17 @@ pub(crate) fn generate_code(params: CliCodegenParams) -> Result<()> {
8580
let query_file_name: ::std::ffi::OsString = query_path
8681
.file_name()
8782
.map(ToOwned::to_owned)
88-
.ok_or_else(|| format_err!("Failed to find a file name in the provided query path."))?;
83+
.ok_or_else(|| "Failed to find a file name in the provided query path.".to_owned())
84+
.unwrap();
8985

9086
let dest_file_path: PathBuf = output_directory
9187
.map(|output_dir| output_dir.join(query_file_name).with_extension("rs"))
9288
.unwrap_or_else(move || query_path.with_extension("rs"));
9389

9490
log::info!("Writing generated query to {:?}", dest_file_path);
9591

96-
let mut file = File::create(dest_file_path)?;
97-
write!(file, "{}", generated_code)?;
98-
99-
Ok(())
92+
let mut file = File::create(dest_file_path).unwrap();
93+
write!(file, "{}", generated_code).unwrap();
10094
}
10195

10296
fn format(code: &str) -> String {

graphql_client_cli/src/introspect_schema.rs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
use anyhow::*;
21
use graphql_client::GraphQLQuery;
32
use reqwest::header::{HeaderMap, HeaderValue, ACCEPT, CONTENT_TYPE};
43
use std::path::PathBuf;
@@ -20,11 +19,11 @@ pub fn introspect_schema(
2019
authorization: Option<String>,
2120
headers: Vec<Header>,
2221
no_ssl: bool,
23-
) -> anyhow::Result<()> {
22+
) {
2423
use std::io::Write;
2524

2625
let out: Box<dyn Write> = match output {
27-
Some(path) => Box::new(::std::fs::File::create(path)?),
26+
Some(path) => Box::new(::std::fs::File::create(path).unwrap()),
2827
None => Box::new(std::io::stdout()),
2928
};
3029

@@ -36,7 +35,8 @@ pub fn introspect_schema(
3635

3736
let client = reqwest::blocking::Client::builder()
3837
.danger_accept_invalid_certs(no_ssl)
39-
.build()?;
38+
.build()
39+
.unwrap();
4040

4141
let mut req_builder = client.post(location).headers(construct_headers());
4242

@@ -48,7 +48,7 @@ pub fn introspect_schema(
4848
req_builder = req_builder.bearer_auth(token.as_str());
4949
};
5050

51-
let res = req_builder.json(&request_body).send()?;
51+
let res = req_builder.json(&request_body).send().unwrap();
5252

5353
if res.status().is_success() {
5454
// do nothing
@@ -58,9 +58,8 @@ pub fn introspect_schema(
5858
println!("Something else happened. Status: {:?}", res.status());
5959
}
6060

61-
let json: serde_json::Value = res.json()?;
62-
serde_json::to_writer_pretty(out, &json)?;
63-
Ok(())
61+
let json: serde_json::Value = res.json().unwrap();
62+
serde_json::to_writer_pretty(out, &json).unwrap();
6463
}
6564

6665
fn construct_headers() -> HeaderMap {
@@ -77,12 +76,12 @@ pub struct Header {
7776
}
7877

7978
impl FromStr for Header {
80-
type Err = anyhow::Error;
79+
type Err = String;
8180

8281
fn from_str(input: &str) -> Result<Self, Self::Err> {
8382
// error: colon required for name/value pair
8483
if !input.contains(':') {
85-
return Err(format_err!(
84+
return Err(format!(
8685
"Invalid header input. A colon is required to separate the name and value. [{}]",
8786
input
8887
));
@@ -95,15 +94,15 @@ impl FromStr for Header {
9594

9695
// error: field name must be
9796
if name.is_empty() {
98-
return Err(format_err!(
97+
return Err(format!(
9998
"Invalid header input. Field name is required before colon. [{}]",
10099
input
101100
));
102101
}
103102

104103
// error: no whitespace in field name
105104
if name.split_whitespace().count() > 1 {
106-
return Err(format_err!(
105+
return Err(format!(
107106
"Invalid header input. Whitespace not allowed in field name. [{}]",
108107
input
109108
));

graphql_client_cli/src/main.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![allow(clippy::redundant_clone)] // in structopt generated code
2+
13
use env_logger::fmt::{Color, Style, StyledValue};
24
use log::Level;
35

@@ -73,7 +75,7 @@ enum Cli {
7375
},
7476
}
7577

76-
fn main() -> anyhow::Result<()> {
78+
fn main() {
7779
set_env_logger();
7880

7981
let cli = Cli::from_args();

0 commit comments

Comments
 (0)