Skip to content

allow cfg attributes in graphql_object #1280

Description

@soerenmeier

Is your feature request related to a problem? Please describe.
I would like to enable a graphql field only if a cargo feature is set. #[cfg(feature = "myfeature")].

Describe the solution you'd like

#[graphql_object]
impl User {
    #[cfg(feature = "address")]
    fn address(&self) -> Address {
        todo!()
    }
}

Describe alternatives you've considered
As a workaround i now have two different impl blocks.

#[cfg(not(feature = "address"))]
#[graphql_object]
impl User {
    ...
}

#[cfg(feature = "address")]
#[graphql_object]
impl User {
    ...

    fn address(&self) -> Address {
        todo!()
    }
}

Thanks for considering this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementImprovement of existing features or bugfix

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions