[TypeScript] Ensure all queries are implemented #7865
Unanswered
SimonSimCity
asked this question in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm working using a schema-first approach and was asking myself how I can ensure all queries, mentioned in the graphql interface, are implemented. If you have a way, please share it, here's mine:
My graphql I organised in groups which I call modules. Here's an example of the module
main
:All modules are now put together in a collective resolvers-file:
This allows me to write the queries I want to implement in this file ("hello" and maybe others as well) and use the generated types. I'll also be informed if this query does not exist anymore, in which case I'd get an ESLint error on the
Pick<T, P>
type definition, because the properties must exist on the type.All this is good and nicely provided by the generated types of this library. Now to the part where I struggled:
When I merge the modules together and try to find out which queries are defined in the graphql files but not yet implemented, I couldn't find any type I could use there. If there is, please let me know! This is how I defined my own types to ensure every type is resolvable and every query is defined. These type definitions should work independently of if
optionalResolveType
is en- or disabled:If there is an easier way, please let me know! If this is a good way of solving this problem, it would be nice if either those types would be implemented in the generated file or if it could be added to a best-practice section or something ...
Beta Was this translation helpful? Give feedback.
All reactions