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

Custom IValidationErrorsHandler union types? #90

Closed
leebenson opened this issue Dec 27, 2022 · 2 comments
Closed

Custom IValidationErrorsHandler union types? #90

leebenson opened this issue Dec 27, 2022 · 2 comments

Comments

@leebenson
Copy link

Thanks for a great helper lib!

I'd like to build an error handler that returns strongly typed errors rather than the free-for-all that is a top-level errors field.

Generally, if I was doing this manually, it'd look something like:

union SomeResponse = TSuccessType | ValidationErrors

I assume I could just attach the strongly typed error to context.Result, but I'm curious how to update Hot Chocolate's interpretation of the method return type so that it's refactored as a union of T | ValidationErrors rather than just T. Do you know if there any good way to do that I'm overlooking?

Thanks in advance for any pointers. I think a helper there would make a good addition to the library.

@glen-84
Copy link

glen-84 commented Feb 16, 2023

Might be relevant: ChilliCream/graphql-platform#5549 (comment).

@benmccallum
Copy link
Owner

benmccallum commented Apr 11, 2023

Thanks for the kind words @leebenson . Sorry I haven't got back to you.

I'm going to close this in favour of #77 which I hope will solve this. Essentially we'll support a ValidationError out of the 6a error convention union. I'll start up the discussion over there shortly and we can all review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants