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

Enforcing constraints for @ArgsType fields of type enum #740

Closed
mithi opened this issue Oct 25, 2020 · 2 comments
Closed

Enforcing constraints for @ArgsType fields of type enum #740

mithi opened this issue Oct 25, 2020 · 2 comments
Labels
Question ❔ Not future request, proposal or bug issue Solved ✔️ The issue has been solved

Comments

@mithi
Copy link

mithi commented Oct 25, 2020

Can the documentation include if this is possible or not?

Given an enum

enum Direction {
  UP
  DOWN
  LEFT
  RIGHT
}

And I'd like to use it as a field in my @ArgsType, but I don't want anyone to be able to select the DOWN direction..
Is there a way to enforce this? How?

@ArgsType()
class DirectionWithoutDownArgs {
  @Field(type => Direction)  
  direction: Direction; // should NOT be able to select DOWN
}

Thank you so much in advance!

@MichalLytek
Copy link
Owner

You just need to create enum without DOWN value, as simple as that 😉

@MichalLytek MichalLytek added the Question ❔ Not future request, proposal or bug issue label Oct 25, 2020
@mithi mithi closed this as completed Oct 25, 2020
@mithi
Copy link
Author

mithi commented Oct 25, 2020

@MichalLytek MichalLytek added the Solved ✔️ The issue has been solved label Oct 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Question ❔ Not future request, proposal or bug issue Solved ✔️ The issue has been solved
Projects
None yet
Development

No branches or pull requests

2 participants