Skip to content

Commit 046d7af

Browse files
authored
Merge pull request #383 from o0Ignition0o/igni/response_derives_path
Support Paths in response derives.
2 parents d2224b1 + f175e85 commit 046d7af

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

graphql_client/tests/more_derives.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use graphql_client::*;
44
#[graphql(
55
schema_path = "tests/more_derives/schema.graphql",
66
query_path = "tests/more_derives/query.graphql",
7-
response_derives = "Debug, PartialEq, PartialOrd"
7+
response_derives = "Debug, PartialEq, std::cmp::PartialOrd"
88
)]
99
pub struct MoreDerives;
1010

graphql_client_codegen/src/codegen.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,11 @@ fn generate_scalar_definitions<'a, 'schema: 'a>(
165165
}
166166

167167
fn render_derives<'a>(derives: impl Iterator<Item = &'a str>) -> impl quote::ToTokens {
168-
let idents = derives.map(|s| Ident::new(s, Span::call_site()));
168+
let idents = derives.map(|s| {
169+
syn::parse_str::<syn::Path>(s)
170+
.map_err(|e| format!("couldn't parse {} as a derive Path: {}", s, e))
171+
.unwrap()
172+
});
169173

170174
quote!(#[derive(#(#idents),*)])
171175
}

0 commit comments

Comments
 (0)