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

Resolve issues around plugin ordering; add more build hooks #233

Merged
merged 15 commits into from
Mar 16, 2023

Conversation

benjie
Copy link
Member

@benjie benjie commented Mar 16, 2023

Previously calling resolvePresets([preset]) (even if you threw away the result) could result in future use of the preset having different plugin ordering. This was due to a bug in the sorting algorithm that caused mutation of the plugin's declared before/after/provides - this is now accomplished in an immutable way.

Once resolved, this revealed a number of other issues related to plugin ordering:

  • If PgRBACPlugin ran before PgSmartCommentsPlugin then its behaviors would be overwritten. This is due to PgSmartCommentsPlugin feeling that it "owns" tags (which it did, really) but PgRBACPlugin writing to tags. One solution would have been to make sure PgRBACPlugin ran after "smart-tags", but a cleaner solution was to simply extract the tags logic from PgSmartCommentsPlugin and instead put it in all the relevant places. This guarantees that tags are there from the start.
  • Related, PgV4NoIgnoreIndexesPlugin was for some reason previously omitting fields that it shouldn't have been. Haven't digged into the reasoning why, but happy that these fields are no longer incorrectly omitted. Most likely it's because the tags object was shared rather than being cloned for each use.
  • PgMutationUpdateDeletePlugin was sometimes running before the table types were defined, resulting in it refusing to register the input types for update operations (since the patch type didn't yet exist). This is resolved by ensuring it comes after PgTablesPlugin.

One major feature in this PR is that we now have the GraphQLObjectType_fields_field_args_arg and GraphQLInterfaceType_fields_field_args_arg hooks and they are used to process every field arg. The plugins that were manipulating individual args (rather than adding them) have been ported to use these hooks, and this should eradicate another class of plugin ordering bugs (it also simplified the code in these places).

@benjie benjie merged commit 3196ea2 into planning Mar 16, 2023
@benjie benjie deleted the fix-plugin-ordering-issues branch March 16, 2023 17:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant