Skip to content

Commit c9f3045

Browse files
authored
Merge pull request #236 from graphql-rust/no-skeptic
Migrate to 2018 edition and away from skeptic
2 parents b851d85 + 4e08828 commit c9f3045

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+142
-315
lines changed

.travis.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ before_script:
1515
- if [ "$TRAVIS_RUST_VERSION" = "beta" ]; then (sudo apt-get update) fi
1616
- if [ "$TRAVIS_RUST_VERSION" = "beta" ]; then (sudo apt-get install -y nodejs) fi
1717
- if [ "$TRAVIS_RUST_VERSION" = "beta" ]; then (npm i -g prettier) fi
18-
- if [ "$TRAVIS_RUST_VERSION" = "stable" ]; then (rustup component add rustfmt-preview clippy-preview) fi
18+
- if [ "$TRAVIS_RUST_VERSION" = "stable" ]; then (rustup component add rustfmt clippy) fi
1919
- if [ "$TRAVIS_RUST_VERSION" = "stable" ]; then (rustup target add wasm32-unknown-unknown) fi
2020
- if [ "$TRAVIS_RUST_VERSION" = "stable" ]; then (cargo install -f wasm-bindgen-cli) fi
2121
script:
2222
- if [ "$TRAVIS_RUST_VERSION" = "stable" ]; then (cargo fmt --all -- --check) fi
2323
- if [ "$TRAVIS_RUST_VERSION" = "stable" ]; then (cargo clippy -- -D warnings) fi
2424
- if [ "$TRAVIS_RUST_VERSION" = "beta" ]; then (prettier --debug-check -l './**/*.json' './**/*.graphql') fi
2525
- cargo test --all
26-
# - cargo build --manifest-path=./examples/github/Cargo.toml
27-
# - cargo build --manifest-path=./examples/web/Cargo.toml
26+
- cargo build --manifest-path=./examples/github/Cargo.toml
27+
- cargo build --manifest-path=./examples/web/Cargo.toml
2828
- if [ "$TRAVIS_RUST_VERSION" = "stable" ]; then (xvfb-run cargo test --manifest-path=./graphql_client_web/Cargo.toml --target wasm32-unknown-unknown) fi

CHANGELOG.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
77

88
## Unreleased
99

10-
This release sees the switch to the Rust 2018 edition and is only compatible with Rust 1.31.0 and later.
10+
This release sees the switch to the Rust 2018 edition - it is
11+
only compatible with Rust 1.31.0 and later.
1112

1213
## 0.7.1
1314

README.md

+9-22
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,8 @@ A typed GraphQL client library for Rust.
3333

3434
- We now have everything we need to derive Rust types for our query. This is achieved through a procedural macro, as in the following snippet:
3535

36-
```rust,skt-empty-main
37-
extern crate serde;
38-
#[macro_use]
39-
extern crate serde_derive;
40-
#[macro_use]
41-
extern crate graphql_client;
36+
```rust
37+
use graphql_client::GraphQLQuery;
4238

4339
// The paths are relative to the directory where your `Cargo.toml` is located.
4440
// Both json and the GraphQL schema language are supported as sources for the schema
@@ -60,12 +56,7 @@ A typed GraphQL client library for Rust.
6056

6157
* We now need to create the complete payload that we are going to send to the server. For convenience, the [GraphQLQuery trait](https://docs.rs/graphql_client/latest/graphql_client/trait.GraphQLQuery.html), is implemented for the struct under derive, so a complete query body can be created this way:
6258

63-
```rust,skt-empty-main
64-
extern crate failure;
65-
#[macro_use]
66-
extern crate graphql_client;
67-
extern crate reqwest;
68-
59+
```rust
6960
use graphql_client::{GraphQLQuery, Response};
7061

7162
#[derive(GraphQLQuery)]
@@ -95,9 +86,8 @@ A typed GraphQL client library for Rust.
9586

9687
The generated response types always derive `serde::Deserialize` but you may want to print them (`Debug`), compare them (`PartialEq`) or derive any other trait on it. You can achieve this with the `response_derives` option of the `graphql` attribute. Example:
9788

98-
```rust,skt-empty-main
99-
#[macro_use]
100-
extern crate graphql_client;
89+
```rust
90+
use graphql_client::GraphQLQuery;
10191

10292
#[derive(GraphQLQuery)]
10393
#[graphql(
@@ -117,9 +107,8 @@ The generated code will reference the scalar types as defined in the server sche
117107
The generated code has support for [`@deprecated`](http://facebook.github.io/graphql/June2018/#sec-Field-Deprecation)
118108
field annotations. You can configure how deprecations are handled via the `deprecated` argument in the `GraphQLQuery` derive:
119109

120-
```rust,skt-empty-main
121-
#[macro_use]
122-
extern crate graphql_client;
110+
```rust
111+
use graphql_client::GraphQLQuery;
123112

124113
#[derive(GraphQLQuery)]
125114
#[graphql(
@@ -145,15 +134,13 @@ You can write multiple operations in one query document (one `.graphql` file). Y
145134

146135
Note that the struct and the operation in the GraphQL file *must* have the same name. We enforce this to make the generated code more predictable.
147136

148-
```rust,skt-empty-main
149-
#[macro_use]
150-
extern crate graphql_client;
137+
```rust
138+
use graphql_client::GraphQLQuery;
151139

152140
#[derive(GraphQLQuery)]
153141
#[graphql(
154142
schema_path = "tests/unions/union_schema.graphql",
155143
query_path = "tests/unions/union_query.graphql",
156-
selected_operation = "SearchQuery"
157144
)]
158145
pub struct UnionQuery;
159146
```

examples/example_module/Cargo.toml

-9
This file was deleted.

examples/example_module/src/custom_scalars.rs

-3
This file was deleted.

examples/example_module/src/lib.rs

-17
This file was deleted.

examples/github/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
name = "graphql_query_github_example"
33
version = "0.1.0"
44
authors = ["Tom Houlé <[email protected]>"]
5+
edition = "2018"
56

67
[dependencies]
78
failure = "*"

examples/github/src/main.rs

+5-18
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,8 @@
1-
extern crate dotenv;
2-
extern crate envy;
3-
#[macro_use]
4-
extern crate failure;
5-
extern crate graphql_client;
6-
#[macro_use]
7-
extern crate log;
8-
extern crate env_logger;
9-
extern crate reqwest;
10-
extern crate serde;
11-
extern crate serde_json;
12-
#[macro_use]
13-
extern crate serde_derive;
14-
extern crate structopt;
15-
#[macro_use]
16-
extern crate prettytable;
17-
1+
use failure::*;
182
use graphql_client::*;
3+
use log::*;
4+
use prettytable::*;
5+
use serde::*;
196
use structopt::StructOpt;
207

218
type URI = String;
@@ -51,7 +38,7 @@ fn main() -> Result<(), failure::Error> {
5138
dotenv::dotenv().ok();
5239
env_logger::init();
5340

54-
let config: Env = envy::from_env()?;
41+
let config: Env = envy::from_env().context("while reading from environment")?;
5542

5643
let args = Command::from_args();
5744

examples/web/Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ lto = "thin"
1111
crate-type = ["cdylib"]
1212

1313
[dependencies]
14+
graphql_client = { path = "../../graphql_client" }
1415
graphql_client_web = { path = "../../graphql_client_web" }
1516
wasm-bindgen = "0.2.12"
16-
serde = "1.0.67"
17-
serde_derive = "1.0.67"
17+
serde = { version = "1.0.67", features = ["derive"] }
1818
serde_json = "1.0.22"
1919
lazy_static = "1.0.1"
2020
js-sys = "0.3.6"

examples/web/src/lib.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
use futures::Future;
2+
use graphql_client_web::*;
23
use lazy_static::*;
34
use std::cell::RefCell;
45
use std::sync::Mutex;
5-
66
use wasm_bindgen::prelude::*;
77
use wasm_bindgen_futures::future_to_promise;
88

9-
use graphql_client_web::*;
10-
119
#[derive(GraphQLQuery)]
1210
#[graphql(
1311
schema_path = "schema.json",

graphql_client/Cargo.toml

+4-7
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,10 @@ edition = "2018"
1111

1212
[dependencies]
1313
failure = "0.1"
14-
graphql_query_derive = {path = "../graphql_query_derive", version = "0.7.1" }
15-
serde = "^1.0.78"
16-
serde_derive = "1.0"
14+
graphql_query_derive = { path = "../graphql_query_derive", version = "0.7.1" }
15+
serde = { version = "^1.0.78", features = ["derive"] }
1716
serde_json = "1.0"
18-
19-
[build-dependencies]
20-
skeptic = "0.13.4"
17+
doc-comment = "0.3.1"
2118

2219
[dev-dependencies]
23-
skeptic = "0.13.4"
20+
reqwest = "*"

graphql_client/build.rs

-6
This file was deleted.

graphql_client/src/lib.rs

+19-24
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,18 @@
22
//!
33
//! The main interface to this library is the custom derive that generates modules from a GraphQL query and schema. See the docs for the [`GraphQLQuery`] trait for a full example.
44
5-
#![deny(warnings)]
65
#![deny(missing_docs)]
6+
#![deny(rust_2018_idioms)]
7+
#![deny(warnings)]
78

8-
use serde;
9+
#[allow(unused_imports)]
910
#[macro_use]
10-
extern crate serde_derive;
11-
pub use graphql_query_derive;
11+
extern crate graphql_query_derive;
12+
13+
#[doc(hidden)]
14+
pub use graphql_query_derive::*;
15+
16+
use serde::*;
1217

1318
#[cfg(test)]
1419
use serde_json::json;
@@ -19,21 +24,17 @@ pub use graphql_query_derive::*;
1924
use std::collections::HashMap;
2025
use std::fmt::{self, Display};
2126

27+
doc_comment::doctest!("../../README.md");
28+
2229
/// A convenience trait that can be used to build a GraphQL request body.
2330
///
2431
/// This will be implemented for you by codegen in the normal case. It is implemented on the struct you place the derive on.
2532
///
2633
/// Example:
2734
///
2835
/// ```
29-
/// extern crate failure;
30-
/// #[macro_use]
31-
/// extern crate graphql_client;
32-
/// #[macro_use]
33-
/// extern crate serde_derive;
34-
/// #[macro_use]
35-
/// extern crate serde_json;
36-
/// extern crate serde;
36+
/// use graphql_client::*;
37+
/// use serde_json::json;
3738
///
3839
/// #[derive(GraphQLQuery)]
3940
/// #[graphql(
@@ -127,12 +128,9 @@ impl Display for PathFragment {
127128
///
128129
///
129130
/// ```
130-
/// # extern crate failure;
131-
/// # #[macro_use]
132-
/// # extern crate serde_json;
133-
/// # extern crate graphql_client;
134-
/// # #[macro_use]
135-
/// # extern crate serde_derive;
131+
/// # use serde_json::json;
132+
/// # use serde::Deserialize;
133+
/// # use graphql_client::GraphQLQuery;
136134
/// #
137135
/// # #[derive(Debug, Deserialize, PartialEq)]
138136
/// # struct ResponseData {
@@ -236,12 +234,9 @@ impl Display for Error {
236234
/// [Spec](https://github.com/facebook/graphql/blob/master/spec/Section%207%20--%20Response.md)
237235
///
238236
/// ```
239-
/// # extern crate failure;
240-
/// # #[macro_use]
241-
/// # extern crate serde_json;
242-
/// # extern crate graphql_client;
243-
/// # #[macro_use]
244-
/// # extern crate serde_derive;
237+
/// # use serde_json::json;
238+
/// # use serde::Deserialize;
239+
/// # use graphql_client::GraphQLQuery;
245240
/// #
246241
/// # #[derive(Debug, Deserialize, PartialEq)]
247242
/// # struct User {

graphql_client/tests/alias.rs

+2-7
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
1-
#[macro_use]
2-
extern crate graphql_client;
3-
4-
#[macro_use]
5-
extern crate serde_derive;
6-
#[macro_use]
7-
extern crate serde_json;
1+
use graphql_client::*;
2+
use serde_json::*;
83

94
#[derive(GraphQLQuery)]
105
#[graphql(

graphql_client/tests/custom_scalars.rs

+2-7
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
1-
#[macro_use]
2-
extern crate graphql_client;
3-
extern crate serde;
4-
#[macro_use]
5-
extern crate serde_derive;
6-
#[macro_use]
7-
extern crate serde_json;
1+
use graphql_client::*;
2+
use serde_json::json;
83

94
use std::net::Ipv4Addr;
105

graphql_client/tests/deprecation.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
#[macro_use]
2-
extern crate graphql_client;
3-
extern crate serde;
4-
#[macro_use]
5-
extern crate serde_derive;
1+
use graphql_client::*;
62

73
#[derive(GraphQLQuery)]
84
#[graphql(

graphql_client/tests/fragments.rs

+2-7
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
1-
#[macro_use]
2-
extern crate graphql_client;
3-
extern crate serde;
4-
#[macro_use]
5-
extern crate serde_derive;
6-
#[macro_use]
7-
extern crate serde_json;
1+
use graphql_client::*;
2+
use serde_json::json;
83

94
#[derive(GraphQLQuery)]
105
#[graphql(

graphql_client/tests/input_object_variables.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
1-
#[macro_use]
2-
extern crate graphql_client;
3-
#[macro_use]
4-
extern crate serde_derive;
5-
extern crate serde;
6-
extern crate serde_json;
1+
use graphql_client::*;
72

83
#[derive(GraphQLQuery)]
94
#[graphql(

graphql_client/tests/interfaces.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
1-
#[macro_use]
2-
extern crate graphql_client;
3-
#[macro_use]
4-
extern crate serde_derive;
5-
extern crate serde;
6-
extern crate serde_json;
1+
use graphql_client::*;
72

83
const RESPONSE: &'static str = include_str!("interfaces/interface_response.json");
94

graphql_client/tests/introspection.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
1-
#[macro_use]
2-
extern crate graphql_client;
3-
#[macro_use]
4-
extern crate serde_derive;
5-
extern crate serde;
6-
extern crate serde_json;
1+
use graphql_client::*;
72

83
#[derive(GraphQLQuery)]
94
#[graphql(

0 commit comments

Comments
 (0)