Add wrap mode to resolvers-composition transform #1928
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.
As per the title, this PR introduces "wrap" mode to the resolvers-composition transform.
This is in order to make this transform work on GraphQL sources.
The PR is related to #1891.
I tested the changes and updated and extended the documentation.
I introduced a new syntax for the transform but also kept backward compatibility with the previous syntax, this is in line with other transforms that support both "bare" and "wrap" modes.
The new syntax is as follow, note the new "mode" property, and the array that is now wrapped under "compositions" property:
Important thing to note:
This transform didn't support "wrap" mode prior to this PR. However, the convention established for transforms is to work in "wrap" mode by default.
This means that now that the transform supports "wrap", I made this the default mode; hence if "mode" property is not specified, then "wrap" will be applied by default.
This is consistent with other transforms that support both modes, however, it might have undesired effects for users that are currently using this transform.
Potentially we could make default mode for this transform to be "bare", to avoid a change in behavior for existing users; however, that would become inconsistent with other transforms.
I believe we need to stick to the decision made to operate in "wrap" by default.
Once agreed, I will add the changeset and specify the potentially breaking behavior (not breaking changes in terms of API though).