Eliminate circular dependency in validation rules #1263
Merged
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.
validation/validate.js
depends on all of the rules, and all of the rules depend onValidationContext
, which was previously exported byvalidation/validate.js
.This moves
ValidationContext
out ofvalidate.js
to resolve this.Circular dependencies are fine, but they tend to slow down flow, since it moves more work to the merging phase, and the merging phase isn't as fast as the inference phase. As a result, this should make flow marginally faster (in this case, only a fraction of a second faster).
This does have a minor breaking change:
graphql/validatation/validate
no longer exportsValidationContext
, butgraphql/validation
still does. I can add an export tovalidate.js
to preserve that behavior, but it's a minor change to a non-public API, and graphql-js has broken these things in the past.I understand if you're not interested in merging this, since this is such a tiny speedup, but I personally just wanted to see if this could have any benefits.
Before (cycle shown via logfile generated with
node_modules/.bin/flow server --profile
):After: