[Question]/[FR] Single Table Inheritance in GraphQL
There were multiple discussions (e.g. https://github.com/api-platform/core/issues/1071) dealing with STI in REST, but I wasn't able to find anything about GraphQL support for that.
Currently I have a single entity which has various external IDs assigned to it in a single collection. These IDs are typed using STI. When calling using REST I get a result similar to this:
{
"@context": "/api/contexts/AbstractExternalId",
"@id": "/api/foo/ba95f76a-6b97-420a-bbfa-fd8c9bf45263/external_ids",
"@type": "hydra:Collection",
"hydra:member": [
{
"@id": "/api/specific_external_id/a4869b6e-fb83-4148-b287-129177b54636",
"@type": "SpecificExternalId",
"externalId": "1225004351",
"id": "a4869b6e-fb83-4148-b287-129177b54636",
"someDate": "2016-02-22T15:00:00-03:00",
}
],
"hydra:totalItems": 1
}
Is there any way to achieve this in GraphQL? From what I see the GraphiQL sees only the AbstractExternalId which:
- Makes impossible to access fields defined by children
- Distinguish which type of the child I'm dealing with
- Filter by type
Is this my missconfiguration somewhere or STI is only supported for REST?
Edit: So far to get at least the information about type userland method can be added to a trait and to all children which looks similar to:
/**
* @ApiProperty()
* @Groups({"GraphQLQuery"})
*/
public function getStiType(): string
{
$class = \get_class($this);
return \substr($class, strrpos($class, '\\')+1);
}
but obviously that's not a solution ;)
Did you ever get a proper solution to this? This seems like a major limitation to be honest
three years later... is this issue considered for resolution? Or are there alternative ways to get the fields of the children?
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.