What should I return if I have a resolver that should return, say, a list of users -
- but the some of the users in the list may not be valid?
(e.g. the data from the DB does not pass whatever validation rules we have set up)
I should know this… But I cannot think of the solution : )
If even a single invalid user is unacceptable (I imagine it should not ever be acceptable) then simply return {:error, list_of_invalid_user_changesets}
from your resolver.
1 Like
Good pt.
But, I am sure there is a better fitting ans…
I mean I can return a partially failed Map with errors, I am sure I should be able to do so with a list…
In that case:
{:ok, %{
succeeded_users: [... list of User structs...],
failed_users: [...list of changesets or traversed errors...]
}}
However then the burden on processing both falls to your frontend.
1 Like