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-22Lines changed: 9 additions & 22 deletions
Display the source diff
Display the rich diff
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.
0 commit comments