feat(gatsby-transformer-remark): Allow remark subplugins to modify graphql types owned by parent plugin #15688
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.
The schema customization APIs allow modifying existing types only by plugins that own that type, or from a user's
gatsby-node.js
. This is an issue for "subplugins", which should be allowed to modify types owned by the parent plugin, but currently can't. AFAICSgatsby-transformer-remark
is the only plugin which has subplugins.The approach in this PR is to forward
gatsby-transformer-remark
'screateSchemaCustomization
API call to its subplugins, so they have actions bound togatsby-transformer-remark
available. This makes it possible for subplugins to modify types owned bygatsby-transformer-remark
.We forward to a
createSchemaCustomization
function exported by the subplugin, which maybe is a bit weird because theexports
object can already be a function (when the subplugin does not usesetParserPlugins
ormutateSource
, which is most of them I think), but it's "just javascript" (i.e. we just stick it onmodule.exports.createSchemaCustomization
).Also:
createTypes
calls.Related: #13972