TypeScript Resolvers: Easier way to get possible resolve types for interfaces #6443
Open
Labels
core
Related to codegen core/cli
help wanted
Extra attention is needed
kind/enhancement
New feature or request
Is your feature request related to a problem? Please describe.
If you have an interface
Document
and multiple types implementing it, sayArticle
,Thesis
andOther
, then the typescript resolvers generated looks similar toAs one can see, the implementing types are listed explicitly in the definition of the
__resolveType
function. Thus, they cannot easily be reused, which is mildly annoying if you want/need to use another function to return exactly one of the options (say because you need to parse or check other data to determine which of the types should be returned). A function like this would currently be annotated likeThis is prone to break in the future if other types implementing the interface are added, and leads to code duplication.
Describe the solution you'd like
Extract the possible type names to a separate type. Maybe even auto-generating something like
so that one can easily iterate over the possible types.
Describe alternatives you've considered
I'm currently using the following code as a work-around.
The text was updated successfully, but these errors were encountered: