gatsbyjs / gatsby

The best React-based framework with performance, scalability and security built in.
https://www.gatsbyjs.com
MIT License
55.3k stars 10.31k forks source link

Result of StaticQuery could not be fetched after cleaning cache #30449

Closed alimaldonado closed 3 years ago

alimaldonado commented 3 years ago

Description

Whenever I run gatsby clean so gatsby can fetch my CMS' graphql endpoint from zero, the application cannot fetch it unless I also reinstall the dependencies.

Btw: I tried to re-fetch the data with the /__refresh endpoint but it does not find new properties from my API's entities.

Steps to reproduce

const topDesigns = useStaticQuery(graphql`
    {
      directus {
        items {
          designs(sort: "date_created") {
            name
            extract
            date_created
            date_updated
          }
        }
      }
    }
  `);

Expected result

The application can fetch the data

Actual result

The result of this StaticQuery could not be fetched. This is likely a bug in Gatsby and if refreshing the page does not fix it, please open an issue in https://github.com/gatsbyjs/gatsby/issues Edit: I found the data can be fetched again if I comment the query, save the file, uncomment the query and refresh the page on my browser.

Environment

  System:
    OS: Windows 10 10.0.19041
    CPU: (8) x64 Intel(R) Core(TM) i7-9700T CPU @ 2.00GHz 
  Binaries:
    Node: 14.15.3 - C:\Program Files\nodejs\node.EXE      
    Yarn: 1.22.4 - ~\AppData\Roaming\npm\yarn.CMD
    npm: 6.14.9 - C:\Program Files\nodejs\npm.CMD
  Languages:
    Python: 3.9.1
  Browsers:
    Chrome: 89.0.4389.90
    Edge: Spartan (44.19041.423.0), Chromium (89.0.774.57)
  npmPackages:
    gatsby: ^3.0.4 => 3.0.4
    gatsby-plugin-gatsby-cloud: ^2.0.0 => 2.0.0
    gatsby-plugin-image: ^1.0.1 => 1.0.1
    gatsby-plugin-manifest: ^3.0.0 => 3.0.0
    gatsby-plugin-react-helmet: ^4.0.0 => 4.0.0
    gatsby-plugin-resolve-src: ^2.1.0 => 2.1.0
    gatsby-plugin-sass: ^4.0.2 => 4.0.2
    gatsby-plugin-sharp: ^3.0.1 => 3.0.1
    gatsby-source-filesystem: ^3.0.0 => 3.0.0
    gatsby-source-graphql: ^3.1.0 => 3.1.0
    gatsby-transformer-sharp: ^3.0.0 => 3.0.0
  npmGlobalPackages:
    gatsby-cli: 3.0.0
alimaldonado commented 3 years ago

I edited my issue, since I found a workaround removing the query and adding it again to the component. However the error will not disapear no matter how many times you refresh the page, unless doing that.

I'll wait to close this issue since I don't know if this behavior can affect anything else.

LekoArts commented 3 years ago

Hi!

Sorry to hear you're running into an issue. To help us best begin debugging the underlying cause, it is incredibly helpful if you're able to create a minimal reproduction. This is a simplified example of the issue that makes it clear and obvious what the issue is and how we can begin to debug it.

If you're up for it, we'd very much appreciate if you could provide a minimal reproduction and we'll be able to take another look.

Thanks for using Gatsby! 💜

minimit commented 3 years ago

Have you moved gatsby outside the /src folder? to me it gives error when I try it see #27878

alimaldonado commented 3 years ago

Have you moved gatsby outside the /src folder? to me it gives error when I try it see #27878

I haven't but I think it has something to do with what I mentioned early: my solution was to coment/delete my query, save and then rewrite/uncomment, save again and the query gets fetched without having to reinstall dependencies.

While it's a kinda odd behavior, it's nothing more than annoying doing as what I did. I'm gonna try what you did as well. Also, it seems like it only happens with the last query wrote.

LekoArts commented 3 years ago

Hi!

Since we didn't receive an answer for 7 days or more about the ask of a reproduction I'm going to close this now, as we can't do much to help without a reproduction. If you are able to create a minimal reproduction for this then please do answer here or open a new issue with a reproduction. Thanks!