-
-
Notifications
You must be signed in to change notification settings - Fork 13
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
Mutation Without Input Bypasses NotEmpty Validation #57
Comments
Hey! FairyBread doesn't validate an argument that is Firstly, to me, it seems a bit bizarre to allow the passing of a null here, so I'd first change it to: That way HotChocolate will actually validate it to the graphql spec and client tooling will show that null isn't allowed. One scenario where null could be allowed but you sometimes want to validate it isn't null, would be a property within the input type where null is allowed conditionally with
(with a validator that allows That brings me to how I see this. I think the design of your mutation field is could be improved. Keen to see what @michaelstaib or @PascalSenn think. To me you should always have a single, top-level arg called
Aside: This is actually sort of related to an open issue #56 about supporting auto-validation of arrays of T, if there's a validator for T, which I'm thinking about rejecting as it fails into a similar problem. Unique, non-null, top-level input type per mutation name is the way to go. |
Awesome, thank you @benmccallum . That lead me to find the attribute to perform this code side: Non-null Attribute . As for the mutation design, I'm always open to hearing different points of view. So again, thank you for you speedy response and input. If the other peeps have input too, I'm all ears. |
Here is my basic validation:
Issue 1: If I change from List<> to IEnumerable<> or T[], then this validation never seems to fire.
Issue 2: If I neglect to add the input as part of my request, then I'll be able to enter my endpoint which appears to bypass my validation.
The validation appears to work when I pass a mutation as follows:
But fails to perform validation with the following mutations:
or
or
Is there something wrong with what I'm doing or is there an issue with FluentValidation, FairyBread, or even HotChocolate?
Versions:
The text was updated successfully, but these errors were encountered: