Skip to content

Commit c51e866

Browse files
committed
Dump introspection JSON responses directly
The CLI is not at a point where it can produce useful error messages. Credit goes to @djc for the bug report and the solution (see #83).
1 parent f48f311 commit c51e866

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

graphql_client_cli/src/main.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use structopt::StructOpt;
1616
#[graphql(
1717
schema_path = "src/introspection_schema.graphql",
1818
query_path = "src/introspection_query.graphql",
19-
response_derives = "Serialize",
19+
response_derives = "Serialize"
2020
)]
2121
struct IntrospectionQuery;
2222

@@ -86,10 +86,6 @@ fn introspect_schema(location: String, output: Option<PathBuf>) -> Result<(), fa
8686
println!("Something else happened. Status: {:?}", res.status());
8787
}
8888

89-
let json: graphql_client::GraphQLResponse<introspection_query::ResponseData> = res.json()?;
90-
let json = serde_json::to_string(&json)?;
91-
92-
write!(out, "{}", json)?;
93-
94-
Ok(())
89+
let json: serde_json::Value = res.json()?;
90+
Ok(serde_json::to_writer_pretty(out, &json)?)
9591
}

0 commit comments

Comments
 (0)