-
-
Notifications
You must be signed in to change notification settings - Fork 7
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
Remove "implicit apply" behavior #355
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
benjie
force-pushed
the
no-implicit-apply
branch
2 times, most recently
from
June 7, 2023 12:38
75f8860
to
c4da7e7
Compare
…rgs/input fields has been removed. Previously we would track the fieldArgs that you accessed (via `.get()`, `.getRaw()` or `.apply()`) and those that you _did not access_ would automatically have their `applyPlan` called, if they had one. This isn't likely to be particularly useful for pure Gra*fast* users (unless they want to adopt this pattern) but it's extremely useful for plugin-based schemas as it allows plugins to add arguments that can influence their field's plan _without having to wrap the field's plan resolver function_. This is fairly critical, otherwise each behavior added (`first:`, `condition:`, `orderBy:`, `filter:`, `ignoreArchived:`, etc etc) would wrap the plan resolver with another function layer, and they would get _messy_. However, implicit is rarely good. And it turns out that it severely limited what I wanted to do for improving the `fieldArgs` APIs. I decided to remove this implicit functionality by making it more explicit, so now args/input fields can specify the relevant `autoApplyAfterParent{Plan,SubscribePlan,InputPlan,ApplyPlan}: true` property and we'll only apply them at a single level. From a user perspective, little has changed. From a plugin author perspective, if you were relying on the implicit `applyPlan` then you should now add the relevant `autoApply*` property next to your `applyPlan` method.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Previously we would track the fieldArgs that you accessed (via
.get()
,.getRaw()
or.apply()
) and those that you did not access would automatically have theirapplyPlan
called, if they had one. This isn't likely to be particularly useful for pure Grafast users (unless they want to adopt this pattern) but it's extremely useful for plugin-based schemas as it allows plugins to add arguments that can influence their field's plan without having to wrap the field's plan resolver. This is fairly critical, otherwise each behavior added (first:
,condition:
,orderBy:
,filter:
,ignoreArchived:
, etc etc) would wrap the plan resolver another layer, and they would get messy.However, implicit is rarely good. And it turns out that it severely limited what I wanted to do for improving the
fieldArgs
APIs - e.g. adding$
accessor shortcuts so instead of:You could just do:
After a (long!) chat with @ab-pm and a reasonable amount of experimentation, I landed on this solution.
TODO:
$
shortcuts, add them in a fresh PR that also improves the types