Skip to content

Commit ad6d701

Browse files
committed
Document customized derives on responses
1 parent b35b0de commit ad6d701

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ A typed GraphQL client library for Rust.
1313
- Works in the browser (WebAssembly)
1414
- Subscriptions support (serialization-deserialization only at the moment)
1515
- Copies documentation from the GraphQL schema to the generated Rust code
16+
- Arbitrary derives on the generated responses
1617

1718
## Getting started
1819

@@ -74,6 +75,21 @@ A typed GraphQL client library for Rust.
7475

7576
[A complete example using the GitHub GraphQL API is available](https://github.com/tomhoule/graphql-client/tree/master/examples/github), as well as sample [rustdoc output](https://www.tomhoule.com/docs/example_module/).
7677

78+
## Deriving specific traits on the response
79+
80+
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:
81+
82+
```rust
83+
#[derive(GraphQLQuery)]
84+
#[graphql(
85+
schema_path = "src/search_schema.graphql",
86+
query_path = "src/search_query.graphql"
87+
query_path = "src/search_query.graphql",
88+
response_derives = "Serialize,PartialEq",
89+
)]
90+
struct SearchQuery;
91+
```
92+
7793
## Examples
7894

7995
See the examples directory in this repository.

0 commit comments

Comments
 (0)