-
Notifications
You must be signed in to change notification settings - Fork 65
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
Better return types for .__type__.name
and polymorphic queries if possible
#454
Comments
This would be fantastic! Being able to return discriminated unions here would be very beneficial for applications using something like tRPC, which lets you then have discriminated unions on your frontend. |
Invaluable! Eliminates redundant checking just to satisfy the parser! |
This would be incredibly useful! Right now the returned types for a polymorphic link are quite difficult to work with. Any chance this could get attention again? |
No timeline on this yet, but it's on my radar to try to bring the linked PR current against |
Ping |
Describe the proposed feature
A clear and concise description of the syntax, what you want to happen, and why it's needed.
Part 1.
__type__.name
Currently the return type of
.__type__.name
is juststring
. We know the name of the object type that's being selected, so it should be possible to infer this as the correct string literal (or union of string literals if it's a parent type).Part 2. Polymorphic queries
Currently a query like this:
gets a return type like:
While this is technically correct, it would be more useful if we could return a discriminated union. I think it might be possible for the querybuilder to automatically insert the typename in the shape, and return a type like so:
The text was updated successfully, but these errors were encountered: