njosefbeck / gatsby-source-stripe

Gatsby source plugin for building websites using Stripe as a data source
74 stars 17 forks source link

Gatsby 3 touchNode deprecation warning #67

Closed brxck closed 2 years ago

brxck commented 3 years ago

Prerequisites

[X] Put an X between the brackets on this line if you have done all of the following:

Describe the bug

Using the latest gatsby-source-stripe with Gatsby 3 triggers a deprecation warning:

warning Calling "touchNode" with an object containing the nodeId is deprecated. Please pass the node directly to the function: touchNode(node) "touchNode" was called by gatsby-source-stripe

The touchNode call in question is here.

To Reproduce

Steps to reproduce the behavior:

  1. Start Gatsby 3 development server

Versions (please complete the following information):

gatsby: 3.1.2 gatsby-source-stripe: 3.2.2

Gatsby config:

{
    resolve: `gatsby-source-stripe`,
    options: {
        objects: ["Price"],
        secretKey: process.env.STRIPE_SECRET_KEY,
        downloadFiles: true,
        auth: false,
    },
},
njosefbeck commented 3 years ago

@brxck So I'm a little fuzzy on the implementation here, but in this file would I then just pass the node into saveNodeFromGarbageCollection, or maybe touchNode orrr does cachedFileData have a reference to the node? I can dig in at some point, but thought I'd ask here first in case you have more insight.

https://github.com/njosefbeck/gatsby-source-stripe/blob/91664587beea5487a718bc932686b207e33742cc/src/helpers/checkCache.js#L12

brxck commented 3 years ago

I'm also fuzzy here. My naive impression is that there are two different nodes within checkCache(). node is the Stripe resource node, while the node referred to bycachedFileData.fileNodeId is the File node that would belong to it.

I don't think we actually have a reference to the File node being touched, so you might have to retrieve it via the getNode helper? This code and these Gatsby APIs are new to me though, so take that with a grain of salt 😅

njosefbeck commented 3 years ago

Ah yeah maybe it's as simple as passing:

https://github.com/njosefbeck/gatsby-source-stripe/blob/91664587beea5487a718bc932686b207e33742cc/src/helpers/checkCache.js#L9

this node into saveNodeFromGarbageCollection and thus into touchNode. I'll try that and see how it goes.

njosefbeck commented 2 years ago

This should be resolved in the latest version, so closing this now. Feel free to reopen if you continue to experience the issue.