-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Input polymorphism #415
Comments
Could you please elaborate on this? I'm not able to follow your example to understand how the interface type is actually used. Could you share a more realistic example that better illustrates the problem that is limiting and why you think this is the preferable solution over #395 or #488? |
@jayhasyee your concerns resonated with me, so I raised them in #488. However, I did eventually come to the conclusion that spec-class support for disambiguating identifiers are worth the changes. Check out this scenario to see if you agree. |
We have begun building a single RFC document for this feature, please see: The goal of this document is to consolidate all related ideas to help move the proposal forward, so we decided to close all overlapping issues including this one. If you want to add something to the discussion please feel free to submit PR against the RFC document. |
I know there are some related issue, but almost all of them propose only Input Union types.
I think GraphQL is very powerful at the really complex data models, but the complex data models are usually designed to strongly polymorph. The greatest lack of feature in GraphQL is the input polymorphism. This is missing painfully and GraphQL really needs this feature.
I recommend a more generic way without modifying the syntax. This needs only to enhance the validator and the parser.
The main issue about input polymorphism is resolving types. Okay, but this issue is solved already at the output types. We can use
interface
orunion
to perform polymorph types at output types, but why can't we do that at inputs?The most of proposals deal with special properties, such as
__typename
or__inputname
, but I think they aren't necessary, because we can useresolveType
andisTypeOf
methods at interfaces and unions. Using these methods allows developers to implement their own type resolving, and using them should be required as in the regular interfaces and unions.or
Then we should implement
resolveType
atProductInput
:Or we can implement
isTypeOf
for the children:or if we don't want to use
type
property:This enhancement won't break the existing syntax and semantic. It only needs to update the validator and the parser. They have to confirm and parse interfaces or unions as inputs, if these type resolver methods are available.
What do you think?
Sorry for opening a new issue, but I think this proposal is different from the others, because it considers this issue more generally.
The text was updated successfully, but these errors were encountered: