-
Notifications
You must be signed in to change notification settings - Fork 93
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
Validation errors and @NonNull
return types, in combination with @Source
#2198
Comments
Wow, that's an interesting edge case! The |
The spec (https://spec.graphql.org/draft/#sel-FANTNJBABJyxE):
I think this means that the behavior of SmallRye GraphQL is correct according to the spec, isn't it? |
That part is according to the spec, but what about the following two paragraphs:
In this case, a field error has already been added to the errors list (the bean validation error), so the
I'm not sure if this propagation is handled correctly. The end result certainly looks like what I would expect, i.e. I suppose that if the additional error was suppressed, everything would be fine. |
Hmmm... It may be argued that the two errors do not belong to the same field, the nullability error a path |
You are right it seems a bit odd that the nullability error is there. It's added by |
It may also be argued that the
I might be reading this wrong, but to me it suggests that this field error belongs to the field, not the field argument. |
I experimented a little bit with the path constructed in
Indeed, the spec says:
So, arguably, this is a (minor) spec-compliance issue. If I use the |
Ok, so you think the problem is that we generate a wrong path for the error and it should be |
I'd be happy to provide a PR. However, one issue that needs discussion is what to do with all the constraint violations. Right now, an error is created for each violation, and since each error has a different path, they all show up in the response. If I change the path, only a single violation will show up (since they would all have the same path). One option would be to gather all violations in a single field error. So, there would be a single error with path |
Yeah but we should make sure we don't just 'drop' the information about which argument was invalid, we still should convey that somewhere, if it's no longer going to be in the So, I could imagine that all validation errors for the same field would be merged together into a single Does this make sense? |
Makes perfect sense. Additionally, there is a list of source locations pointing to the errors (eg. line X, column Y). I guess this list should contain the locations of all arguments that had violations. |
Yes. It won't contain the explicit mapping between locations and particular constraint violations, but following the required response format, I guess it's the best we can do |
Fixed via #2201 |
I'm facing an issue similar to 1921, but concerning methods annotated with
@Source
. Suppose we have a snippet similar to the following:In case the input is invalid, the API returns, in addition to the expected validation errors, an error concerning the nullability of the field:
According to the error message, it seems that there is a problem with the process of bubbling-up null from the child field to the parent, until a nullable field is found. I'm not sure if this is something I should somehow handle in my own methods, or if it should be handled by smallrye-graphql.
I have uploaded a reproducer (using Quarkus version 3.14.4).
The text was updated successfully, but these errors were encountered: