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
Copy file name to clipboardExpand all lines: README.md
+10-21Lines changed: 10 additions & 21 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -33,12 +33,9 @@ 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
+
useserde::{Serialize, Deserialize};
38
+
usegraphql_client::GraphQLQuery;
42
39
43
40
// The paths are relative to the directory where your `Cargo.toml` is located.
44
41
// 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.
60
57
61
58
* 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
59
63
-
```rust,skt-empty-main
64
-
extern crate failure;
65
-
#[macro_use]
66
-
extern crate graphql_client;
67
-
extern crate reqwest;
68
-
60
+
```rust
69
61
usegraphql_client::{GraphQLQuery, Response};
70
62
71
63
#[derive(GraphQLQuery)]
@@ -95,9 +87,8 @@ A typed GraphQL client library for Rust.
95
87
96
88
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
89
98
-
```rust,skt-empty-main
99
-
#[macro_use]
100
-
extern crate graphql_client;
90
+
```rust
91
+
usegraphql_client::GraphQLQuery;
101
92
102
93
#[derive(GraphQLQuery)]
103
94
#[graphql(
@@ -117,9 +108,8 @@ The generated code will reference the scalar types as defined in the server sche
117
108
The generated code has support for [`@deprecated`](http://facebook.github.io/graphql/June2018/#sec-Field-Deprecation)
118
109
field annotations. You can configure how deprecations are handled via the `deprecated` argument in the `GraphQLQuery` derive:
119
110
120
-
```rust,skt-empty-main
121
-
#[macro_use]
122
-
extern crate graphql_client;
111
+
```rust
112
+
usegraphql_client::GraphQLQuery;
123
113
124
114
#[derive(GraphQLQuery)]
125
115
#[graphql(
@@ -145,9 +135,8 @@ You can write multiple operations in one query document (one `.graphql` file). Y
145
135
146
136
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.
0 commit comments