Skip to content

Commit d15796b

Browse files
committed
WIP: Remove most uses of extern crate
Also removes the dependency on skeptic. TODO: - Document how to require serde now.
1 parent b851d85 commit d15796b

Some content is hidden

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

51 files changed

+91
-248
lines changed

README.md

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,9 @@ 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 serde::{Serialize, Deserialize};
38+
use graphql_client::GraphQLQuery;
4239

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

6158
* 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:
6259

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

7163
#[derive(GraphQLQuery)]
@@ -95,9 +87,8 @@ A typed GraphQL client library for Rust.
9587

9688
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:
9789

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

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

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

124114
#[derive(GraphQLQuery)]
125115
#[graphql(
@@ -145,9 +135,8 @@ You can write multiple operations in one query document (one `.graphql` file). Y
145135

146136
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.
147137

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

152141
#[derive(GraphQLQuery)]
153142
#[graphql(

examples/example_module/src/lib.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
1-
extern crate serde;
2-
#[macro_use]
3-
extern crate serde_derive;
4-
#[macro_use]
5-
extern crate graphql_client;
6-
1+
use graphql_client::*;
72
pub mod custom_scalars;
83

94
use custom_scalars::*;

examples/github/src/main.rs

Lines changed: 4 additions & 17 deletions
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;

examples/web/Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ crate-type = ["cdylib"]
1313
[dependencies]
1414
graphql_client_web = { path = "../../graphql_client_web" }
1515
wasm-bindgen = "0.2.12"
16-
serde = "1.0.67"
17-
serde_derive = "1.0.67"
16+
serde = { version = "1.0.67", features = ["derive"] }
1817
serde_json = "1.0.22"
1918
lazy_static = "1.0.1"
2019
js-sys = "0.3.6"

examples/web/src/lib.rs

Lines changed: 1 addition & 3 deletions
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

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,5 @@ edition = "2018"
1212
[dependencies]
1313
failure = "0.1"
1414
graphql_query_derive = {path = "../graphql_query_derive", version = "0.7.1" }
15-
serde = "^1.0.78"
16-
serde_derive = "1.0"
15+
serde = { version = "^1.0.78", features = ["derive"] }
1716
serde_json = "1.0"
18-
19-
[build-dependencies]
20-
skeptic = "0.13.4"
21-
22-
[dev-dependencies]
23-
skeptic = "0.13.4"

graphql_client/build.rs

Lines changed: 0 additions & 6 deletions
This file was deleted.

graphql_client/src/lib.rs

Lines changed: 10 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,10 @@
44
55
#![deny(warnings)]
66
#![deny(missing_docs)]
7+
#![deny(rust_2018_idioms)]
78

8-
use serde;
9-
#[macro_use]
10-
extern crate serde_derive;
119
pub use graphql_query_derive;
10+
use serde::*;
1211

1312
#[cfg(test)]
1413
use serde_json::json;
@@ -26,14 +25,8 @@ use std::fmt::{self, Display};
2625
/// Example:
2726
///
2827
/// ```
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;
28+
/// use graphql_client::*;
29+
/// use serde_json::json;
3730
///
3831
/// #[derive(GraphQLQuery)]
3932
/// #[graphql(
@@ -127,12 +120,9 @@ impl Display for PathFragment {
127120
///
128121
///
129122
/// ```
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;
123+
/// # use serde_json::json;
124+
/// # use serde::Deserialize;
125+
/// # use graphql_client::GraphQLQuery;
136126
/// #
137127
/// # #[derive(Debug, Deserialize, PartialEq)]
138128
/// # struct ResponseData {
@@ -236,12 +226,9 @@ impl Display for Error {
236226
/// [Spec](https://github.com/facebook/graphql/blob/master/spec/Section%207%20--%20Response.md)
237227
///
238228
/// ```
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;
229+
/// # use serde_json::json;
230+
/// # use serde::Deserialize;
231+
/// # use graphql_client::GraphQLQuery;
245232
/// #
246233
/// # #[derive(Debug, Deserialize, PartialEq)]
247234
/// # struct User {

graphql_client/tests/alias.rs

Lines changed: 2 additions & 7 deletions
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

Lines changed: 2 additions & 7 deletions
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

0 commit comments

Comments
 (0)