Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(gatsby-transformer-remark): Allow remark subplugins to modify graphql types owned by parent plugin #15688

Merged

Conversation

stefanprobst
Copy link
Contributor

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. AFAICS gatsby-transformer-remark is the only plugin which has subplugins.

The approach in this PR is to forward gatsby-transformer-remark's createSchemaCustomization API call to its subplugins, so they have actions bound to gatsby-transformer-remark available. This makes it possible for subplugins to modify types owned by gatsby-transformer-remark.

We forward to a createSchemaCustomization function exported by the subplugin, which maybe is a bit weird because the exports object can already be a function (when the subplugin does not use setParserPlugins or mutateSource, which is most of them I think), but it's "just javascript" (i.e. we just stick it on module.exports.createSchemaCustomization).

Also:

  • move auxiliary type definitions (for headings, excerpt formats, wordcount) to createTypes, so they are in a central location and have better names that can be targetted by subplugin's createTypes calls.
  • removed a confusing comment that seems left over from ancient times (but maybe i misunderstood)

Related: #13972

@stefanprobst stefanprobst requested a review from a team as a code owner July 13, 2019 20:50
@freiksenet freiksenet merged commit 6959c6d into gatsbyjs:master Jul 15, 2019
@stefanprobst stefanprobst deleted the subplugins-schema-customization branch July 15, 2019 18:10
madmonkey pushed a commit to madmonkey/gatsby that referenced this pull request Jul 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants