Skip to content

Commit f044487

Browse files
committed
Remove the lifetime parameter from GraphQLQuery
It makes it easier to work with async clients, since the 'de lifetime is scoped to the deserializer.
1 parent a6d949e commit f044487

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

CHANGELOG.md

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

1212
- The CLI can now optionally format the generated code with rustfmt (enable the `rustfmt` feature).
1313

14+
### Changed
15+
16+
- (BREAKING) GraphQLQuery does not take a lifetime parameter anymore. This makes it easier to work with futures in async client, since futures expect everything they capture to have the 'static lifetime.
17+
1418
## 0.5.1 (2018-10-07)
1519

1620
### Added

graphql_client/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,11 @@ use itertools::Itertools;
6969
/// Ok(())
7070
/// }
7171
/// ```
72-
pub trait GraphQLQuery<'de> {
72+
pub trait GraphQLQuery {
7373
/// The shape of the variables expected by the query. This should be a generated struct most of the time.
7474
type Variables: serde::Serialize;
7575
/// The top-level shape of the response data (the `data` field in the GraphQL response). In practice this should be generated, since it is hard to write by hand without error.
76-
type ResponseData: serde::Deserialize<'de>;
76+
type ResponseData: for<'de> serde::Deserialize<'de>;
7777

7878
/// Produce a GraphQL query struct that can be JSON serialized and sent to a GraphQL API.
7979
fn build_query(variables: Self::Variables) -> QueryBody<Self::Variables>;

graphql_client_codegen/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ pub fn generate_module_token_stream(
170170
#schema_output
171171
}
172172

173-
impl<'de> ::graphql_client::GraphQLQuery<'de> for #struct_name {
173+
impl ::graphql_client::GraphQLQuery for #struct_name {
174174
type Variables = #module_name::Variables;
175175
type ResponseData = #module_name::ResponseData;
176176

0 commit comments

Comments
 (0)