Replies: 3 comments 2 replies
-
Excerpt from my notes:
|
Beta Was this translation helpful? Give feedback.
-
All of these are "Should I add this thing (field, argument, etc)?" except for the JWT one, which is "What shape should this thing be?" But defining the context is tricky |
Beta Was this translation helpful? Give feedback.
-
Imagine we have a many to many relationship between User and Forum, so we might have: create table users ( ... );
create table forums ( ... );
create table forum_users (
id int primary key,
user_id int not null references users,
forum_id int not null references forums,
unique (user_id, forum_id)
); Looking at this many to many join table, PostGraphile will currently generate (depending on settings, plugins, etc):
This is generated from:
We want to give users the flexibility to easily control which of these entities (fields, enum values, arguments, etc) is generated. For example:
When doing this, we should factor in that the behaviour can come from (from least to most specific):
It would be nice to combine all these. |
Beta Was this translation helpful? Give feedback.
-
In PostGraphile v5 we've moved away from the introspection-based approach of V4 to a DataSource oriented approach. This gives us a lot more control over what happens and why and how to change it. Essentially we think that the schema build process can be based on these 4 topics:
Smart tags/smart comments should be factored into the production of the above, and generally shouldn't leak through to the schema build phase. Except sometimes they do/should... maybe? This separation is not at all clear to me yet.
Currently "behavior" is very loosely defined and has been done in a very ad-hoc manner without a central repository of behavior strings or meanings. If you search over the codebase you'll see it being used in a decent number of ways, from a quick scan I see at least the following:
Already this has a number of issues:
By "poor cohesion" I mean that behaviours typically interact. Take an example of a "user_emails" table - at the root you might want cursor pagination so admins can page over the huge number of emails across your codebase (this would be the
all
andconnection
behavior on theuser_emails
source); but when it comes to getting the list of emails for a particular user, you probably just want a straight array without pagination (type User { emails: [UserEmail!] }
) - this would correlate with thelist
behaviour. So it's clear the behaviour is dependent on context, one way to think of this is that the source should haveall:connection
and the relationship should havelist
behaviours - i.e. the source should allowall
, and when it does so it should useconnection
(and notlist
); the relationship should just use thelist
directly (no connection).We also have the concept of "default behaviors" - these are the behaviors that should apply if the source/relationship/type/etc have not defined a behavior. Currently these are defined in a per-plugin basis - you request the behavior for the relevant entity, and if it does not have one then you locally treat it as having your plugin's defaults. But what this means is that if you do add a behavior to something explicitly, then all the other defaults get immediately turned off. This seems sub-optimal. I've been considering an explicit syntax such as
-all
or-connection
to disable the given behavior versus the defaults.When we try and combine these default behaviors we get interesting interactions, for example if you have
-all all:connection
does that result in all being disabled or not? I think it's equivalent to-all:* +all:connection
- i.e. disable allall
behaviours, except enable theall:connection
behavior. But I'm not sure if this is too confusing, and I'm also not sure if it covers all eventualities.So my current thinking is:
all:connection
) and we should know which behaviours can be nested in which other behaviorsAnyway, I've rambled enough... what do you think? How do you want to define the behaviors of your schema?
Beta Was this translation helpful? Give feedback.
All reactions