Comments (6)
Thanks a lot @benjie ! Sorry about the "multi-bug" - I wasn't sure any one of them were significant enough to post about. I'll be happy to provide some PRs once I'm done with my current queue :)
from crystal.
- can be addressed using the
@graphile/simplify-inflection
plugin. See also https://postgraphile.org/postgraphile/next/inflection#advice
from crystal.
Point 1
Hi @FelixZY; thanks for the great reproduction! I trimmed it down a bit further so I wouldn't need to provide a bunch of envvars, and I had to tweak your seed.sql file as it missed the schema in a couple places, but it was quite easy to reproduce your issue.
It was a simple one, smart comments must be the first things in a comment, but you had them as the last things. (See below for fixed SQL.) This was visible in GraphiQL as the smart tags were coming through into the documentation when you hovered over fields, whereas they should have been removed. Once I resolved this, I then faced the issue that you called your type profile_type
and we already generate a type ProfileType
to represent the possible types of the interface Profile
and that caused issues. Ideally we'd use the same enum, but we're not smart enough for that yet (please feel free to file a separate issue if you're so inclined). So I had to write a quick inflection plugin to rename the builtin type to ProfilePolyType; I suggest you replace that with something more suitable (or disable PgPolymorphismOnlyArgumentPlugin
):
import { PostGraphileAmberPreset } from "postgraphile/presets/amber";
import { PostGraphileRelayPreset } from "postgraphile/presets/relay";
import { makePgService } from "postgraphile/adaptors/pg";
const connectionString = `postgres:///felixzy`;
/** @type {GraphileConfig.Preset} */
const preset = {
extends: [PostGraphileAmberPreset, PostGraphileRelayPreset],
pgServices: [
makePgService({
connectionString,
superuserConnectionString: connectionString,
pubsub: true,
schemas: ["dansdata"],
}),
],
gather: {
pgStrictFunctions: true,
installWatchFixtures: true,
},
schema: {
dontSwallowErrors: true,
jsonScalarAsString: false,
pgForbidSetofFunctionsToReturnNull: true,
},
grafserv: {
graphiql: true,
graphqlOverGET: false,
watch: true,
},
grafast: {
explain: true,
},
+ plugins: [
+ {
+ name: "RenamePolymorphismOnlyTypePlugin",
+ inflection: {
+ replace: {
+ pgPolymorphismEnumType(prev, options, pgCodec) {
+ return this.upperCamelCase(`${this._codecName(pgCodec)}-poly-type`);
+ },
+ },
+ },
+ },
+ ],
};
export default preset;
Here's the SQL I used:
DROP SCHEMA if EXISTS "dansdata" CASCADE;
CREATE SCHEMA "dansdata";
CREATE TYPE dansdata.profile_type AS ENUM ('individual');
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 $$
@interface mode:relational type:type
@type individual references:individuals
@name Profile
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 $$
@name Individual
Represents an individual person.
$$;
Once you get this working, submitting some examples to the documentation would be appreciated!
Point 2
You should consider using @graphile/simplify-inflection; but you're right that's a super weird naming issue. Please file a separate issue about it ❤️ Filed as #2082 (In general, each issue should be filed in a separate issue; it makes them easier to track and address.)
Point 3
Hopefully @graphile/simplify-inflection will address that.
Point 4
I didn't think polymorphic types supported any CRUD mutations; if they do then this is a bug, please file it as a separate issue filed as #2083.
Point 5
I think so; please use a plugin like:
crystal/postgraphile/postgraphile/graphile.config.ts
Lines 85 to 102 in 91e87ab
TypeScript should give you some guidance. If you get it working, I'd love it if you could contribute an example back to the docs.
Closing this since issue 1 is dealt with, please file any separate issues as separate issues ❤️
from crystal.
4
I didn't think polymorphic types supported any CRUD mutations; if they do then this is a bug
I don't know if they do - based on your feedback on 1., I probably did not configure polymorphism properly.
from crystal.
Ah 🤦♂️ I should have thought of that! Closing #2083; please re-open if it does turn out to be an issue.
from crystal.
For future reference: the PgPolymorphismOnlyArgumentPlugin
has description "Adds the 'only' argument to polymorphic relations to limit to only the given types"
. See also
from crystal.
Related Issues (20)
- 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
- Grafast not reusing operation plans from previous requests? HOT 1
- RFC: stable object step
- Rename of functions with same name but different signatures HOT 1
- Apply filters on custom resolvers HOT 1
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.