You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to attach a computed column to a polymorphic table with postgraphile 5.0.0-beta.20. The column only shows up on the specific types, but not the interface, so querying it requires a call-out for each type.
Steps to reproduce
Create a minimal schema as follows:
BEGIN;
CREATETYPEbase_typeAS ENUM ( 'A', 'B' );
CREATETABLEbase (
id BIGSERIALPRIMARY KEY,
type base_type NOT NULL
);
COMMENT ON TABLE base IS $$
@interface mode:single type:type
@type A name:VarA
@type B name:VarB
$$;
CREATEFUNCTIONbase_common(b base)
RETURNS INTEGERAS $$
SELECT42;
$$ LANGUAGE sql STABLE STRICT;
INSERT INTO base ( type ) VALUES ( 'A' );
INSERT INTO base ( type ) VALUES ( 'A' );
INSERT INTO base ( type ) VALUES ( 'B' );
COMMIT;
I expected this query to work, to allow me to access the common field.
query {
allBases {
nodes {
idtypecommon
}
}
}
Actual results
The above query caused the error message: Cannot query field \"common\" on type \"Base\". Did you mean to use an inline fragment on \"VarA\" or \"VarB\"?
I was able to access the common field with the following query. This is much more verbose, and makes adding additional polymorphic types a lot more difficult for my API consumers.
query {
allBases {
nodes {
idtype...onVarA {
common
}
...onVarB {
common
}
}
}
}
Additional context
Operating System: Linux (NixOS 23.11, but I doubt this is relevant).
node --version: v18.18.2
postgres --version: postgres (PostgreSQL) 15.5
postgraphile: 5.0.0-beta.20
Note: I've removed all the irrelevant parts of my schema to create a minimal working example. I understand that, as shown, there's no need for polymorphism, but it is required in my actual schema.
Thanks!
The text was updated successfully, but these errors were encountered:
Summary
I'm trying to attach a computed column to a polymorphic table with postgraphile 5.0.0-beta.20. The column only shows up on the specific types, but not the interface, so querying it requires a call-out for each type.
Steps to reproduce
Create a minimal schema as follows:
I launched postgraphile as follows:
npx postgraphile --preset postgraphile/presets/amber --connection <redacted>
Expected results
I expected this query to work, to allow me to access the
common
field.Actual results
The above query caused the error message:
Cannot query field \"common\" on type \"Base\". Did you mean to use an inline fragment on \"VarA\" or \"VarB\"?
I was able to access the
common
field with the following query. This is much more verbose, and makes adding additional polymorphic types a lot more difficult for my API consumers.Additional context
node --version
: v18.18.2postgres --version
: postgres (PostgreSQL) 15.5postgraphile
:5.0.0-beta.20
Note: I've removed all the irrelevant parts of my schema to create a minimal working example. I understand that, as shown, there's no need for polymorphism, but it is required in my actual schema.
Thanks!
The text was updated successfully, but these errors were encountered: