Search code examples
gatsby

Getting error upon deleting gatsby node of a type owned by another plugin


I'm getting the following error:

Error: The plugin "default-site-plugin" deleted a node of a type owned by another plugin.
            The node type "community_education__district_classes" is owned by "gatsby-source-apiserver".

I know I am getting this error because I am using gatsby-source-apiserver and it returns nodes that I don't want. I filter them out and use deleteNode to remove them. It was working, and still is working, but I just recently upgraded my npm packages and now I am getting this error.

Is there a way to remove this error? Is it a bad idea for me to be removing these nodes where I am in gatsby-node.js if they are automatically generated by the plugin? Is GraphQL the better solution for this? It seems like the alternative of editing the node module for my custom needs isn't a great solution either.

The specific code is something like this, but the logic is more complex (which is why I have opted not to add all of the nodes and then use GraphQL for filtering).

if (!node.isValid) {
  deleteNode({ node });
}

Solution

  • I posted this question as a GitHub issue as well, and the answer seems to be, "Yes, this is a bad idea." I refactored my code to use GraphQL to filter out the unwanted nodes.

    GitHub Issue Thread: https://github.com/gatsbyjs/gatsby/issues/13600#issuecomment-486413760