How to change field return type in middleware #829
mvarendorff
started this conversation in
General
Replies: 2 comments 5 replies
Sounds like you need to fix your DI and register a |
1 reply
|
Also, this sounds like a really bad idea. Validation errors should be thrown with exceptions and included in the error response object. |
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
For a new requirement, I am trying to add an additional type as union to the existing results, i.e. if the code says that a mutation resolver returns
FooPayload, I want the schema to say that resolver returnsFooPayload | BarPayload. How would I best go about this?I discovered
FieldMiddlewareInterfaceand my initial instinct was to do something like akin to thishowever this fails in our Symfony setup because no service of type
RecursiveTypeMapperInterfaceis registered. I tried various combinations of TypeMappers but could not find any that were registered. I also tried my luck withTypeMapperFactoryhowever that in turn requires me to have access to an instance ofFactoryContextwhich I don't have either.Am I on the completely wrong track here? Is this even possible or intended to be possible presently?
A little context as to what I am trying to achieve: We recently quite painfully learned that our current validation concept is not valid per the GraphQL Spec (long story...) and we now landed on wanting to return validation errors as part of the payload as a potential path forward. For that, I am to prototype how to centralize this process to avoid having validation logic explicitly present on each of several dozen mutation resolvers, this experiment being one of them.
All reactions