You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- if [ "$TRAVIS_RUST_VERSION" = "stable" ]; then (xvfb-run cargo test --manifest-path=./graphql_client_web/Cargo.toml --target wasm32-unknown-unknown) fi
Copy file name to clipboardExpand all lines: README.md
+9-22
Original file line number
Diff line number
Diff line change
@@ -33,12 +33,8 @@ A typed GraphQL client library for Rust.
33
33
34
34
- 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:
35
35
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
+
usegraphql_client::GraphQLQuery;
42
38
43
39
// The paths are relative to the directory where your `Cargo.toml` is located.
44
40
// 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.
60
56
61
57
* 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:
62
58
63
-
```rust,skt-empty-main
64
-
extern crate failure;
65
-
#[macro_use]
66
-
extern crate graphql_client;
67
-
extern crate reqwest;
68
-
59
+
```rust
69
60
usegraphql_client::{GraphQLQuery, Response};
70
61
71
62
#[derive(GraphQLQuery)]
@@ -95,9 +86,8 @@ A typed GraphQL client library for Rust.
95
86
96
87
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:
97
88
98
-
```rust,skt-empty-main
99
-
#[macro_use]
100
-
extern crate graphql_client;
89
+
```rust
90
+
usegraphql_client::GraphQLQuery;
101
91
102
92
#[derive(GraphQLQuery)]
103
93
#[graphql(
@@ -117,9 +107,8 @@ The generated code will reference the scalar types as defined in the server sche
117
107
The generated code has support for [`@deprecated`](http://facebook.github.io/graphql/June2018/#sec-Field-Deprecation)
118
108
field annotations. You can configure how deprecations are handled via the `deprecated` argument in the `GraphQLQuery` derive:
119
109
120
-
```rust,skt-empty-main
121
-
#[macro_use]
122
-
extern crate graphql_client;
110
+
```rust
111
+
usegraphql_client::GraphQLQuery;
123
112
124
113
#[derive(GraphQLQuery)]
125
114
#[graphql(
@@ -145,15 +134,13 @@ You can write multiple operations in one query document (one `.graphql` file). Y
145
134
146
135
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.
Copy file name to clipboardExpand all lines: graphql_client/src/lib.rs
+19-24
Original file line number
Diff line number
Diff line change
@@ -2,13 +2,18 @@
2
2
//!
3
3
//! 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.
4
4
5
-
#![deny(warnings)]
6
5
#![deny(missing_docs)]
6
+
#![deny(rust_2018_idioms)]
7
+
#![deny(warnings)]
7
8
8
-
use serde;
9
+
#[allow(unused_imports)]
9
10
#[macro_use]
10
-
externcrate serde_derive;
11
-
pubuse graphql_query_derive;
11
+
externcrate graphql_query_derive;
12
+
13
+
#[doc(hidden)]
14
+
pubuse graphql_query_derive::*;
15
+
16
+
use serde::*;
12
17
13
18
#[cfg(test)]
14
19
use serde_json::json;
@@ -19,21 +24,17 @@ pub use graphql_query_derive::*;
19
24
use std::collections::HashMap;
20
25
use std::fmt::{self,Display};
21
26
27
+
doc_comment::doctest!("../../README.md");
28
+
22
29
/// A convenience trait that can be used to build a GraphQL request body.
23
30
///
24
31
/// This will be implemented for you by codegen in the normal case. It is implemented on the struct you place the derive on.
25
32
///
26
33
/// Example:
27
34
///
28
35
/// ```
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;
37
38
///
38
39
/// #[derive(GraphQLQuery)]
39
40
/// #[graphql(
@@ -127,12 +128,9 @@ impl Display for PathFragment {
0 commit comments