How to return multiple errors without data? #1046
-
Hi everyone, I'm looking for a possibility of returning a list of errors in a proper graphqls way (without unions between success/failure responses). I started using the example provided by the doc but the data field is required, not providing it or providing a null returns an additional error on graphql
Is there any good way of returning just errors during mutations which don't require data structure? as I said, I managed to get it working via unions but I prefer a solution similar to DataFetcherResult |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 12 replies
-
If the top level field is marked as non-nullable then attempting to return a null value is a critical error as it violates the type safety guarantee of the GraphQL. If you want to return |
Beta Was this translation helpful? Give feedback.
-
@kamilgregorczyk Try not setting DataFetcherResult.newResult<LoginResult>()
.error(
newErrorException()
.message("test message")
.build()
).build() |
Beta Was this translation helpful? Give feedback.
@kamilgregorczyk Try not setting
data
at all