Skip to content

Commit

Permalink
shouldOnCreateNode -> unstable_shouldOnCreateNode
Browse files Browse the repository at this point in the history
  • Loading branch information
pvdz committed Oct 16, 2020
1 parent fb31677 commit 265d524
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 20 deletions.
4 changes: 2 additions & 2 deletions packages/gatsby-transformer-remark/src/gatsby-node.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { onCreateNode, shouldOnCreateNode } = require(`./on-node-create`)
const { onCreateNode, unstableShouldOnCreateNode } = require(`./on-node-create`)
exports.onCreateNode = onCreateNode
exports.shouldOnCreateNode = shouldOnCreateNode
exports.unstableShouldOnCreateNode = unstableShouldOnCreateNode
exports.createSchemaCustomization = require(`./create-schema-customization`)
exports.setFieldsOnGraphQLNodeType = require(`./extend-node-type`)

Expand Down
6 changes: 3 additions & 3 deletions packages/gatsby-transformer-remark/src/on-node-create.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const grayMatter = require(`gray-matter`)
const _ = require(`lodash`)

function shouldOnCreateNode(node) {
function unstableShouldOnCreateNode(node) {
return (
node.internal.mediaType === `text/markdown` ||
node.internal.mediaType === `text/x-markdown`
Expand All @@ -22,7 +22,7 @@ module.exports.onCreateNode = async function onCreateNode(
const { createNode, createParentChildLink } = actions

// We only care about markdown content.
if (!shouldOnCreateNode(node)) {
if (!unstableShouldOnCreateNode(node)) {
return {}
}

Expand Down Expand Up @@ -81,4 +81,4 @@ module.exports.onCreateNode = async function onCreateNode(
}
}

module.exports.shouldOnCreateNode = shouldOnCreateNode
module.exports.unstableShouldOnCreateNode = unstableShouldOnCreateNode
4 changes: 2 additions & 2 deletions packages/gatsby-transformer-sharp/src/gatsby-node.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { onCreateNode, shouldOnCreateNode } = require(`./on-node-create`)
const { onCreateNode, unstableShouldOnCreateNode } = require(`./on-node-create`)
exports.onCreateNode = onCreateNode
exports.shouldOnCreateNode = shouldOnCreateNode
exports.unstableShouldOnCreateNode = unstableShouldOnCreateNode
exports.createSchemaCustomization = require(`./customize-schema`)
exports.createResolvers = require(`./create-resolvers`)
6 changes: 3 additions & 3 deletions packages/gatsby-transformer-sharp/src/on-node-create.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { supportedExtensions } = require(`./supported-extensions`)

function shouldOnCreateNode(node) {
function unstableShouldOnCreateNode(node) {
return !!supportedExtensions[node.extension]
}

Expand All @@ -11,7 +11,7 @@ module.exports.onCreateNode = async function onCreateNode({
}) {
const { createNode, createParentChildLink } = actions

if (!shouldOnCreateNode(node)) {
if (!unstableShouldOnCreateNode(node)) {
return
}

Expand All @@ -31,4 +31,4 @@ module.exports.onCreateNode = async function onCreateNode({
return
}

module.exports.shouldOnCreateNode = shouldOnCreateNode
module.exports.unstableShouldOnCreateNode = unstableShouldOnCreateNode
6 changes: 3 additions & 3 deletions packages/gatsby/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -311,11 +311,11 @@ export interface GatsbyNode {
* then Gatsby will not schedule the `onCreateNode` callback for this node for this plugin.
* Note: this API does not receive the regular `api` that other callbacks get as first arg.
*
* @gatsbyVersion 2.24.79
* @gatsbyVersion 2.24.80
* @example
* exports.shouldOnCreateNode = (node, pluginOptions) => node.internal.type === 'Image'
* exports.unstableShouldOnCreateNode = (node, pluginOptions) => node.internal.type === 'Image'
*/
shouldOnCreateNode?<TNode extends object = {}>(
unstableShouldOnCreateNode?<TNode extends object = {}>(
node: TNode,
): boolean

Expand Down
4 changes: 2 additions & 2 deletions packages/gatsby/scripts/__tests__/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ it("generates the expected api output", done => {
"preprocessSource": Object {},
"resolvableExtensions": Object {},
"setFieldsOnGraphQLNodeType": Object {},
"shouldOnCreateNode": Object {
"version": "2.24.79",
"unstableShouldOnCreateNode": Object {
"version": "2.24.80",
},
"sourceNodes": Object {},
},
Expand Down
6 changes: 3 additions & 3 deletions packages/gatsby/src/utils/api-node-docs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,11 @@ export const onCreateNode = true
* then Gatsby will not schedule the `onCreateNode` callback for this node for this plugin.
* Note: this API does not receive the regular `api` that other callbacks get as first arg.
*
* @gatsbyVersion 2.24.79
* @gatsbyVersion 2.24.80
* @example
* exports.shouldOnCreateNode = (node, pluginOptions) => node.internal.type === 'Image'
* exports.unstableShouldOnCreateNode = (node, pluginOptions) => node.internal.type === 'Image'
*/
export const shouldOnCreateNode = true
export const unstableShouldOnCreateNode = true

/**
* Called when a new page is created. This extension API is useful
Expand Down
4 changes: 2 additions & 2 deletions packages/gatsby/src/utils/api-runner-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -539,8 +539,8 @@ module.exports = async (api, args = {}, { pluginSource, activity } = {}) =>
// TODO: rethink createNode API to handle this better
if (
api === `onCreateNode` &&
gatsbyNode?.shouldOnCreateNode && // Don't bail if this api is not exported
!gatsbyNode.shouldOnCreateNode(args.node, plugin.pluginOptions)
gatsbyNode?.unstableShouldOnCreateNode && // Don't bail if this api is not exported
!gatsbyNode.unstableShouldOnCreateNode(args.node, plugin.pluginOptions)
) {
// Do not try to schedule an async event for this node for this plugin
return null
Expand Down

0 comments on commit 265d524

Please sign in to comment.