You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The drawback of this is, that the type-safety does happen while executing the code not while compiling it. I wonder whether there are other solutions worth exploring.
For a union type we have the same "issue":
constresolveType=(input)=>{if(isTypeOfNote(input)){returnGraphQLNoteType;}elseif(isTypeOfImage(input)){returnGraphQLImageType;}thrownewError("Could not resolve type.");}
This is hard because we don't control the actual execution. If we do - then there is a way to make the resolution of an abstract output type to require the Value and its Object Type that it maps to.
Then you don't even need "resolveType" or "isTypeOf" at all!
For interfaces, the best thing to do is using
isTypeOf
.E.g.
With a library such as
io-ts
the stuff can be even "more" save:The drawback of this is, that the type-safety does happen while executing the code not while compiling it. I wonder whether there are other solutions worth exploring.
For a union type we have the same "issue":
I mentioned some more stuff related to this in #9
The text was updated successfully, but these errors were encountered: