-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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): Remove deleteNode with ID arg #29205
Merged
Merged
Changes from 9 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
106c2d5
remove nodeId as arg
LekoArts d3cb7de
update signature, add new v4 deprecation warning, local tests pass
LekoArts ef41886
add test case to check for deprecation message
LekoArts eb17221
update existing tests
LekoArts 2652407
update deleteNode usage in our code
LekoArts c0e48ae
Merge remote-tracking branch 'upstream/master' into v3/delete-node-wi…
75eab7e
update wordpress plugin
LekoArts bb5c2e8
Merge branch 'master' into v3/delete-node-with-id-argument
LekoArts d03f0ed
Revert "update wordpress plugin"
LekoArts f9dbd41
improve message
LekoArts File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -425,53 +425,50 @@ ${reservedFields.map(f => ` * "${f}"`).join(`\n`)} | |
|
||
/** | ||
* Delete a node | ||
* @param {object} $0 | ||
* @param {object} $0.node the node object | ||
* @param {object} node A node object. See the "createNode" action for more information about the node object details. | ||
* @example | ||
* deleteNode({node: node}) | ||
* deleteNode(node) | ||
*/ | ||
actions.deleteNode = (options: any, plugin: Plugin, args: any) => { | ||
actions.deleteNode = (node: any, plugin?: Plugin) => { | ||
let id | ||
|
||
// Check if using old method signature. Warn about incorrect usage but get | ||
// node from nodeID anyway. | ||
if (typeof options === `string`) { | ||
// TODO(v4): Remove this deprecation warning and only allow deleteNode(node) | ||
if (node && node.node) { | ||
let msg = | ||
`Calling "deleteNode" with a nodeId is deprecated. Please pass an ` + | ||
`object containing a full node instead: deleteNode({ node }).` | ||
if (args && args.name) { | ||
// `plugin` used to be the third argument | ||
plugin = args | ||
`Calling "deleteNode" with an object containing a full node is deprecated. Please pass ` + | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See above. |
||
`the node directly to the function: deleteNode(node)` | ||
|
||
if (plugin && plugin.name) { | ||
msg = msg + ` "deleteNode" was called by ${plugin.name}` | ||
} | ||
report.warn(msg) | ||
|
||
id = options | ||
id = node.node.id | ||
} else { | ||
id = options && options.node && options.node.id | ||
id = node && node.id | ||
} | ||
|
||
// Always get node from the store, as the node we get as an arg | ||
// might already have been deleted. | ||
const node = getNode(id) | ||
const internalNode = getNode(id) | ||
if (plugin) { | ||
const pluginName = plugin.name | ||
|
||
if ( | ||
node && | ||
typeOwners[node.internal.type] && | ||
typeOwners[node.internal.type] !== pluginName | ||
internalNode && | ||
typeOwners[internalNode.internal.type] && | ||
typeOwners[internalNode.internal.type] !== pluginName | ||
) | ||
throw new Error(stripIndent` | ||
The plugin "${pluginName}" deleted a node of a type owned by another plugin. | ||
|
||
The node type "${node.internal.type}" is owned by "${ | ||
typeOwners[node.internal.type] | ||
The node type "${internalNode.internal.type}" is owned by "${ | ||
typeOwners[internalNode.internal.type] | ||
}". | ||
|
||
The node object passed to "deleteNode": | ||
|
||
${JSON.stringify(node, null, 4)} | ||
${JSON.stringify(internalNode, null, 4)} | ||
|
||
The plugin deleting the node: | ||
|
||
|
@@ -487,12 +484,13 @@ actions.deleteNode = (options: any, plugin: Plugin, args: any) => { | |
} | ||
} | ||
|
||
const deleteAction = createDeleteAction(node) | ||
const deleteAction = createDeleteAction(internalNode) | ||
|
||
// It's possible the file node was never created as sometimes tools will | ||
// write and then immediately delete temporary files to the file system. | ||
const deleteDescendantsActions = | ||
node && findChildren(node.children).map(getNode).map(createDeleteAction) | ||
internalNode && | ||
findChildren(internalNode.children).map(getNode).map(createDeleteAction) | ||
|
||
if (deleteDescendantsActions && deleteDescendantsActions.length) { | ||
return [...deleteDescendantsActions, deleteAction] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I might change this slightly?
"Calling 'deleteNode' with {node} is deprecated. Please pass the node directly to the function: deleteNode(node)."
An object containing the full node reads a bit confusing in my mind.