Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stage 1 of behavior overhaul #2160

Merged
merged 51 commits into from
Sep 27, 2024
Merged

Stage 1 of behavior overhaul #2160

merged 51 commits into from
Sep 27, 2024

Conversation

benjie
Copy link
Member

@benjie benjie commented Aug 17, 2024

Description

  1. graphile-config plugin hooks can now register arrays of hooks, in case they need the hook to be called multiple times at different priorities. (Prior to this you had to write multiple plugins and combine them via a preset.)
  2. Behaviors now have a registry, should help to spot mistakes.

Lots to do:

  • Validate behaviors against the registry
  • Implement new behavior system that "multiplies" by the "preferences" before applying overrides
  • Remove all the addBehaviorToTags usage
  • Generate documentation from the registry
  • Integrate registry with graphile CLI for custom per-project docs
  • Note that this is a breaking change, and advise on migration strategies (shouldn't need much, hopefully most people won't be impacted)

At the end of this:

My personal notes: https://docs.google.com/document/d/1rNOhd4n5Ml75SXobUrPFBRd5Fe_TD2o0a_6SETDeOC8/edit

Performance impact

Security impact

Checklist

  • My code matches the project's code style and yarn lint:fix passes.
  • I've added tests for the new feature, and yarn test passes.
  • I have detailed the new feature in the relevant documentation.
  • I have added this feature to 'Pending' in the RELEASE_NOTES.md file (if one exists).
  • If this is a breaking change I've explained why.

Copy link

changeset-bot bot commented Aug 17, 2024

🦋 Changeset detected

Latest commit: 2dfc10f

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 17 packages
Name Type
graphile-build Patch
graphile-build-pg Patch
postgraphile Patch
graphile Patch
graphile-config Patch
graphile-utils Patch
pgl Patch
@localrepo/grafast-bench Patch
@dataplan/pg Patch
grafast Patch
@grafserv/persisted Patch
grafserv Patch
ruru Patch
@dataplan/json Patch
ruru-components Patch
@localrepo/grafast-website Patch
graphile-export Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

…s a centralized registry of

known behaviors and applies behaviors in a more careful and nuanced way,
removing many hacks and workarounds, and ultimately meaning that
`defaultBehavior: "-*"` should now operate correctly.

Technically this is a breaking change because the order in which behaviors are
applied has changed, and so a different behavior might ultimately "win". This
shows up in places where there is ambiguity, for example if you add
`@filterable` to a function that you don't have execute permissions on, that
function will now show up in the schema since user overrides (smart tags) "win"
versus inferred behaviors such as introspected permissions; this wasn't the
case before. Hopefully most users will not notice any difference, and for those
who do, the `graphile behavior debug` CLI may be able to help you figure out
what's going on.

Be sure to print your schema before and after this update and look for changes;
if there are changes then you likely need to fix the relevant behaviors/smart
tags. (Hopefully there's no changes for you!)
@benjie benjie marked this pull request as ready for review September 26, 2024 16:20
…ized it; this is incorrect since if you just want the build object you don't necessarily want to register all of the GraphQL types (and potentially discover naming conflicts) at that moment. Introduced new `schemaBuilder.initBuild(schemaBuilder.createBuild(input))` API to explicitly handle initing if you need an initialized build object.
…ing debugging behaviors when naming conflicts occur in the schema.
@benjie benjie merged commit b48850b into main Sep 27, 2024
36 checks passed
@benjie benjie deleted the behavior-overhaul branch September 27, 2024 11:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

V5: forbid addBehaviorToTags (or at least use it less) Add a type registry for behaviors
1 participant