3 ms·
> Another problem GraphQL hasn't tackled (afaik) is polymorphism. You can say "hey give me this person" or "give me this company", but what if you want a custom
by maktouch 9y ago
> Another problem GraphQL hasn't tackled (afaik) is polymorphism. You can say "hey give me this person" or "give me this company", but what if you want a customer that can be either a person or a company?
http://graphql.org/learn/schema/#interfaces http://graphql.org/learn/schema/#interfaces
searchPersonOrCompany(name: "abc") {
... on User {
first_name
last_name
}
... on Company {
business_name
}
}
As for the undetermined depths problem -- I agree to an extent.
GraphQL can't return depths without you querying for it unless one of the field is a JSON blob.. but at the same time, I like that it does that.
In your example of menu w/ submenus, I think I would prefer to load the first 2 level, then preload level 3 when level 2 is activated, and preload level 5 when level 4 is activated, and so on.
Apollo makes this quite easy.
- penagwin 9y agoAre you saying to request each level as needed? That's a lot of round trips, especially if levels need to be opened on mouseover or something.
- sorenbs 9y agoNah, just query for as many levels as you think you might need up front.
- pier25 9y agoWell today I learned a couple things. Thanks for the example and ideas.