Skip to content

Commit 372786e

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

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
1111

1212
- (breaking) Control over which types custom scalars deserialize to is given to the user: you now have to provide type aliases for the custom scalars in the scope of the struct under derive.
1313
- (breaking) Support for multi-operations documents. You can select a particular operation by naming the struct under derive after it. In case there is no match, we revert to the current behaviour: select the first operation.
14+
- Support arbitrary derives on the generated response types via the `response_derives` option on the `graphql` attribute.
1415

1516
## [0.3.0] - 2018-07-24
1617

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)