graphile / crystal-pre-merge

Repository moved
https://github.com/graphile/crystal
39 stars 10 forks source link

Relay preset: issue with create mutation for composite PK each referencing polymorphic type #472

Closed benjie closed 10 months ago

benjie commented 11 months ago
CREATE TABLE dependency (
    block_id UUID NOT NULL REFERENCES block(id) ON DELETE CASCADE,
    dependency_id UUID NOT NULL REFERENCES block(id) ON DELETE CASCADE,
    primary key (block_id, dependency_id)
);

COMMENT ON TABLE dependency IS E'@behavior -update';

create index on dependency (block_id);
create index on dependency (dependency_id);

(Where block is an @interface mode:relational polymorphic type)

Results in a create mutation but without the blockId and dependencyId inputs. This is likely because the relay preset removes these fields, instead preferring to use a NodeID - but the NodeID cannot be found since the referenced type is polymorphic.

See also #468

I'm starting to think that we should have a standard way of getting the NodeID spec from a polymorphic type. Not sure what that would look like, but doing it would allow all these different cases to be handled via central logic.

Context: https://discord.com/channels/489127045289476126/498852330754801666/1139344820884733982

Reported by: @sgrove

benjie commented 11 months ago

Solve https://github.com/benjie/crystal/issues/473 first!