Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow cfg attributes in graphql_object #1280

Open
soerenmeier opened this issue Aug 18, 2024 · 1 comment
Open

allow cfg attributes in graphql_object #1280

soerenmeier opened this issue Aug 18, 2024 · 1 comment
Labels
enhancement Improvement of existing features or bugfix

Comments

@soerenmeier
Copy link
Contributor

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.

@soerenmeier soerenmeier added the enhancement Improvement of existing features or bugfix label Aug 18, 2024
@soerenmeier
Copy link
Contributor Author

Might be related to #600.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improvement of existing features or bugfix
Projects
None yet
Development

No branches or pull requests

1 participant