Skip to content

Commit 583d94a

Browse files
committed
Handle all keywords as field names in codegen
Closes #94
1 parent 09b69a9 commit 583d94a

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

graphql_query_derive/src/shared.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,15 @@ pub(crate) fn render_object_field(
3535

3636
let description = description.map(|s| quote!(#[doc = #s]));
3737

38-
if field_name == "type" {
38+
let reserved = &[
39+
"abstract", "alignof", "as", "become", "box", "break", "const", "continue", "crate", "do",
40+
"else", "enum", "extern", "false", "final", "fn", "for", "if", "impl", "in", "let", "loop",
41+
"macro", "match", "mod", "move", "mut", "offsetof", "override", "priv", "proc", "pub",
42+
"pure", "ref", "return", "Self", "self", "sizeof", "static", "struct", "super", "trait",
43+
"true", "type", "typeof", "unsafe", "unsized", "use", "virtual", "where", "while", "yield",
44+
];
45+
46+
if reserved.contains(&field_name) {
3947
let name_ident = Ident::new(&format!("{}_", field_name), Span::call_site());
4048
return quote! {
4149
#description

0 commit comments

Comments
 (0)