Open FelixZY opened 5 months ago
The [documentation]() currently describes the from
field like this:
from
: - the name of the GraphQL type we're applying the reference to when using polymorphism
Based on #1876 and #1874, it seems like a better description might be:
from
: - the name of the GraphQL type we're applying the reference to when using single-table (mode:single
) polymorphism
I think what you're asking for is essentially inheritance. Interfaces in GraphQL do not perform inheritance - they just describe the interface that is expected, and it's up to the implementations to then provide fields matching the interface. Currently I'm following the GraphQL pattern. That said, for relational tables, there is effectively inheritance so I can see the value in that; feel free to work on a PR for it (for relational and single table interfaces only).
This is a feature that could be added long after v5.0.0 ships since there's already a solution, so it will be at the very bottom of my TODO list to fix myself.
Feature description
Note: I'm talking about "derived tables" as in "derived class" from OOP, not as in PostgreSQL table inheritance
I have a
Profile
type which can concretely be an instance ofIndividual
orOrganization
. Each profile can also be a member of one or more organizations (OrganizationMember
). I therefore wish to define this property on the base table (using@ref
and@refVia
):However, this does not work. Instead, I must define the property on each of my derived tables as well (Postgraphile is kind enough to throw an error if I don't so at least I won't forget):
It would be really nice if Postgraphile was able to infer the relationship based on the base table only. It would reduce code duplication and reduce the risk of bugs.
More complete SQL
Supporting development
I [tick all that apply]: