core icon indicating copy to clipboard operation
core copied to clipboard

Entity inheritance to GraphQL interface

Open calbro7 opened this issue 3 years ago • 3 comments

I like the approach of GraphQLite: if Cat and Dog both inherit from some Animal class (stored in the database using either single table inheritance or class table inheritance), then the GraphQL schema generated will have an AnimalInterface which is then implemented by Cat and Dog. This allows one to perform queries like:

animals {
    id
    ... on Cat {
        someCatSpecificField
    }
    ... on Dog {
        someDogSpecificField
    }
}

to fetch all Animals along with their implementation-specific fields. Unless I'm missing something, this is not possible with API Platform? My application makes use of inheritance a lot so annoyingly it's pretty much just this issue that is ruling out API Platform.

calbro7 avatar Jan 11 '22 19:01 calbro7

Hi, Did you find a way ? I tried a lot by my side but I wasn't able to make it work, this is so much needed !

lenybernard avatar Dec 15 '23 13:12 lenybernard

same problem here. Has anyone found a solution for that ?

cuberinooo avatar Jan 19 '24 14:01 cuberinooo

Also very interested. Will try to hack something as soon as I find where to start

kstefanini avatar Jun 11 '24 14:06 kstefanini