Open annitya opened 3 years ago
What I can think of now as a workaround is to use graphql-fields
library to parse the client's query and resolve the fields manually ahead of time. Then just return the fields as properties of root object, so they are available to other field resolvers in root object.
A bit of extra work and complexity, but definitely a solid suggestion I will consider using. Atm we are just refetching the object manually. This of course has the drawback that none of the resolvers are run for the re-fetched object.
Our project has a lot of async-resolvers. This makes it difficult to build an optimal graph because we are unable to use an async-fields for further resolutions. Discussion here
A gist with a code-example can be seen here
I would very much like to have a dependsOn annotation looking something like this The annotation would make sure that the dependee-resolver would be run first and its promise resolved.
I tried using this library, but was unable to make it work. I also tried hacking it together myself using promises, but was unable to do so.