api-platform / core

The server component of API Platform: hypermedia and GraphQL APIs in minutes
https://api-platform.com
MIT License
2.4k stars 856 forks source link

Entity inheritance to GraphQL interface #6117

Open calbro7 opened 2 years ago

calbro7 commented 2 years ago

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.

lenybernard commented 8 months ago

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 !

cuberinooo commented 7 months ago

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

kstefanini commented 2 months ago

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