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

Consider allowing passthrough execution to resolver/mutation even if validator fails #69

Open
oising opened this issue Oct 27, 2021 · 4 comments
Labels
enhancement New feature or request
Milestone

Comments

@oising
Copy link

oising commented Oct 27, 2021

Use case: Sometimes you may want to treat the validation as a partial failure, and allow the mutation/resolver to execute anyway, so a payload can be returned. Might I suggest using an extension method on IResolverContext to allow the method to see the result(s) for each input type, and make its own decisions on how to proceed.

There is a related issue with Strawberry Shake - if the payload for the mutation is non-nullable, fairybread will cause a null to flow through and causes a null ref exception in the deserializer, if validation fails.

I don't mind doing the work, but just wanted your advice on this. Returning an error/errors and a payload doesn't seem to be against the graphql spec.

@oising oising changed the title Considering allow passthrough execution to resolver/mutation even if validator fails Consider allowing passthrough execution to resolver/mutation even if validator fails Oct 27, 2021
@benmccallum
Copy link
Owner

I think it's worth potentially making the error result handler (which typically just adds the errors to the response with context.ReportError) actually return a bool for whether next should be called or not.

That way someone can fully swap our the handler of errors to do what they want, e.g. still let some of it through or whatever.

It might not handle what you were talking about in slack, but I think it's a valid use case for everyone.

Would be a breaking change, so will schedule in next milestone unless it's useful earlier.

@benmccallum benmccallum added this to the 9.0.0 milestone Dec 9, 2021
@oising
Copy link
Author

oising commented Dec 9, 2021

That sounds useful, @benmccallum -- I gave up on trying to modify the behaviour to fit my needs, but we're still using fairybread. Mutations with an array of inputs will fail the entire batch if one is bad, but that's easy to manage on the client with a resubmit of the entire batch.

@benmccallum benmccallum modified the milestones: 9.0.0, 9.1.0 Jun 10, 2022
@benmccallum benmccallum added the enhancement New feature or request label Jun 17, 2022
@oising
Copy link
Author

oising commented Jun 20, 2022

Did you figure out an approach to use?

@benmccallum
Copy link
Owner

@oising , I think I had a plan in my last comment above; which was more about making the handling a bit more flexible if you wanted it to not abort entirely. Just haven't had time to go and make the change :P

@benmccallum benmccallum modified the milestones: 10.0.0, 11.0.0 Apr 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants