graphile / crystal-pre-merge

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

Add a type registry for behaviors #347

Closed benjie closed 1 month ago

benjie commented 1 year ago

Currently overhauling the behavior system, and it would be nice if the behaviors auto-completed. Because they're currently feature flag strings (+insert -update -single +list) they don't; but if we made them into lists instead then they could: ['insert', '-update', '-single', 'list']. If we can have this grow via declaration merging then we can let plugins define their own behaviors and still have them auto-complete.

Further, the registry would allow us to figure out which behaviors are relevant to which types, which may help when debugging - e.g. not showing noisy 'connection' behaviors when looking at the int4 codec.

We might even use object properties like [b.insert, b._update, b._single, b.list] or similar so that we can get TSDoc comments on hover.

benjie commented 1 year ago

Also this:

https://github.com/benjie/postgraphile-private/blob/efcf239e3ccf1b231ebbe4e42dc06077d530bb37/graphile-build/graphile-build-pg/src/plugins/PgRBACPlugin.ts#L176-L181

a registry would allow to specify dependencies (e.g. -select implies -single -list -connection).

jemgillam commented 1 year ago

We don't have time to do this before release, so let's handle it afterwards in a less strict way.

benjie commented 1 year ago

If someone wants to take this on, that would be delightful, so I'm moving it back to RC. I'd be happy to discuss implementation and even collaborate a bit on it; mostly the concern is lack of time.