fix wildcard rules are not reusable #1459
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.
Summary:
Fixes #1358
Fixes #1341
(slightly different problems with the same root cause)
When using wildcard rules, it was not possible to reuse the same object that had the
'*'
key defined in it.Cause:
Line 142:
delete rules['*']
was modifying the argument to the function (which is sort of an anti-pattern for this kind of reason) and was causing subsequent uses of the same object to not have the wildcard rule for their own usage.The issue that I was facing was that if you attempt to apply the middleware to a schema two or more times, it only has the wildcard rules for the first invocation. I've determined that the line above is the root cause of both issues.
Testing:
I have added a test (a copy of the wildcard test, but with a double usage to cause the error to occur). It was correctly failing prior to the fix, and began passing after the fix was added.