Extend documentation with a guide for plan resolvers (#244)#2985
Open
msotnikov wants to merge 1 commit intographile:mainfrom
Open
Extend documentation with a guide for plan resolvers (#244)#2985msotnikov wants to merge 1 commit intographile:mainfrom
msotnikov wants to merge 1 commit intographile:mainfrom
Conversation
|
This file contains hidden or 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
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.
Description
Addresses graphile/crystal-pre-merge#244 — general recommendations when writing plan resolvers.
Documentation:
grafast/website/grafast/plan-resolvers/best-practices.md) covering the four recommendations from the issue:getRaw(["path", "to", "value"])or$-prefixed destructuring instead of shallow extraction followed by lambda transformslambda— comparison table, guidance on when lambda is appropriate vs when to create a step class, worked example of a custom steptry/catchin plan resolvers — why imperative error handling doesn't fit the declarative model, with examples usinginhibitOnNull()andtrap()insteadlambda.mdpointing users towardloadOne/loadMany, custom steps, andsideEffect()before they reach for lambdaplan-resolvers/index.mdxRuntime warning:
NODE_ENV=development),lambda()now emits aconsole.warnwhen called with an anonymous (unnamed) callback function, since such callbacks cannot be deduplicated. The warning fires once perunique callback reference (tracked via
WeakSet).Performance impact
No impact in production. In development mode, a single
WeakSetlookup is added perlambda()call (negligible).Security impact
None.
Checklist
yarn lint:fixpasses.yarn testpasses.RELEASE_NOTES.mdfile (if one exists).