graphql-client icon indicating copy to clipboard operation
graphql-client copied to clipboard

Attribute #[allow(non_camel_case_types)] for enums

Open acelot opened this issue 5 years ago • 1 comments

My graphql scheme contains enums with capital letters values and graphql-client cli generates such code:

#[derive(Eq, PartialEq)]
pub enum PagesSortType {
    #[doc = ""]
    ID_ASC,
    #[doc = ""]
    ID_DESC,
    #[doc = ""]
    MODIFIED_AT_ASC,
    #[doc = ""]
    MODIFIED_AT_DESC,
    Other(String),
}

Rust compiler throws warnings:

warning: variant `MODIFIED_AT_DESC` should have an upper camel case name
   --> src/services/pages.rs:417:9
    |
417 |         MODIFIED_AT_DESC,
    |         ^^^^^^^^^^^^^^^^ help: convert the identifier to upper camel case: `ModifiedAtDesc`

Perhaps it’s worth adding an #[allow(non_camel_case_types)] attribute for all enums or making it possible to specify which attributes you want to add yourself via cli argument --variables-attributes for example.

acelot avatar Jun 12 '20 08:06 acelot

Sounds like a useful improvement — let's think about how to expose this in this issue.

tomhoule avatar Jun 25 '21 09:06 tomhoule