Comments (3)
Contrary to what I said yesterday, point 1 isn't actually a bug. Refs shouldn't inherit behaviors from the relations, they're explicit - e.g. you might @behavior -*
a organization_members
join table, but use a ref to allow going straight from organization to members.
So actually the bug was just point 2, which is fixed in #2149
from crystal.
Reproduction code:
DROP SCHEMA if EXISTS "dansdata" cascade;
CREATE SCHEMA "dansdata";
set search_path to dansdata;
--------------------------------------------------------------------------------
CREATE TYPE dansdata.profile_type AS ENUM('individual', 'organization');
comment on type dansdata.profile_type is '@name TypeOfProfile';
CREATE TABLE dansdata.profiles (
id UUID DEFAULT gen_random_uuid () PRIMARY KEY,
type dansdata.profile_type NOT NULL,
name TEXT NOT NULL
);
comment ON TABLE dansdata.profiles IS
E'@interface mode:relational type:type\n'
'@type individual references:individuals\n'
'@type organization references:organizations\n'
'@name Profile\n'
'\n'
'Represents an entity with profile data.';
CREATE TABLE dansdata.individuals (
id UUID PRIMARY KEY REFERENCES dansdata.profiles (id) ON DELETE cascade
);
comment ON TABLE dansdata.individuals IS E'@name Individual\nRepresents an individual person.';
CREATE TABLE dansdata.organizations (
id UUID PRIMARY KEY REFERENCES dansdata.profiles (id) ON DELETE cascade
);
comment ON TABLE dansdata.organizations IS E'@name Organization\n\nRepresents an organization.';
--------------------------------------------------------------------------------
CREATE
OR REPLACE function dansdata.create_individual (name TEXT) returns dansdata.individuals AS $$
WITH "profile" AS (
INSERT INTO dansdata.profiles("type", "name") VALUES ('individual', name) RETURNING *
) INSERT INTO dansdata.individuals("id") (SELECT id from "profile") RETURNING *;
$$ language sql volatile strict security invoker;
CREATE
OR REPLACE function dansdata.create_organization (name TEXT) returns dansdata.organizations AS $$
WITH "profile" AS (
INSERT INTO dansdata.profiles("type", "name") VALUES ('organization', name) RETURNING *
) INSERT INTO dansdata.organizations("id") (SELECT id from "profile") RETURNING *;
$$ language sql volatile strict security invoker;
from crystal.
The bug is related to this code:
crystal/graphile-build/graphile-build-pg/src/plugins/PgPolymorphismPlugin.ts
Lines 591 to 598 in f762ee3
Specifically the behaviors coming out of that are ''
(which is not unexpected given how behaviors work); however, we are expecting the -single
behavior to come out of it; the one that is added here:
We know it's added because the relationship is not added to the interface type; and yet it is still added (via refs, incorrectly) to the child types.
Really there's two bugs here:
- The ref behaviors aren't correctly being influenced by the parts that make up the ref (see the
TODO
linked above - yes we're doing this the wrong way) - These specific refs, independent of behaviours, shouldn't be added in the first place.
Solving either one of these bugs will fix the issue, but both should be solved.
from crystal.
Related Issues (20)
- GraphQL resolver emulation should cascade
- Should `__FlagStep` be isSyncAndSafe?
- Change how `__Flag` be represented in plan diagrams?
- Plan diagrams: `::sideeffectplan` and `::unbatchedPlan` conflict HOT 1
- RBAC enhancements: don't fetch column if not allowed to fetch column
- Rewrite OutputPlans, they're a mess
- `fieldArgs.getRaw` and related methods should throw if called out of turn
- Unable to pass FieldArg as parameter for resource .get() HOT 7
- Latest `grafast` depends on `graphile-config` but doesn't list dependency
- Foreign Key on Composite Type HOT 4
- PageInfo implemented incorrectly? HOT 6
- Hono adaptor HOT 4
- How to omit a class and specific field HOT 3
- pgUnionAll.single() throws an error when the list is empty HOT 2
- Grafast processFragment does not permit use of string arguments
- Use `@graphile/logger` for logging
- Improve pgSelectSingleFromRecord $record argument type
- How to Modify the Result of a PgSelectStep HOT 5
- How to get inflected database data in makeExtendSchemaPlugin? HOT 1
- "Expected a PgSelectSingleStep [...] however we received 'Access'" from custom plugin HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from crystal.