-
-
Notifications
You must be signed in to change notification settings - Fork 675
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
Generic Type #245
Generic Type #245
Conversation
Templating
Codecov Report
@@ Coverage Diff @@
## master #245 +/- ##
==========================================
- Coverage 95.88% 89.51% -6.37%
==========================================
Files 67 69 +2
Lines 1045 1164 +119
Branches 183 214 +31
==========================================
+ Hits 1002 1042 +40
- Misses 42 121 +79
Partials 1 1
Continue to review full report at Codecov.
|
@OwenCalvin But I wasn't asking for help with generics - as you can see in #180, there's no "Help wanted" badge and I'm assigned to this issue to do this by my own. The proposed API is definitely not the one I would like to introduce. It's too complicated, missleading ( I have different design goals and feature implementations/bug solution in my head, so I can't accept your PR. I've placed and info in the readme long, long time ago to prevent this kind of situation:
But feel free to continue your work in your fork |
Okay no problem, I needed this so I made it :) |
Use Case:
I've made an example into examples/generic-type, with this you can see what is the goal of the feature.
Let suppose that you have multiple ObjectType, a QueryResponse class that is generic and has a dynamic type field :
My ObjectTypes:
My QueryResponse generic class that has a generic property items :
So now if you want to return a QueryResponse in a cars query (QueryResponse) and the same for a persons query (QueryResponse). So you do not need to redeclare a new class to type staticly items field.
You can use the new type-graphql generic typing feature in queries like this (Also usable as a ArgsType or InputType: see examples/generic-type):
Compiled queries