Skip to content
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

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

Closed
alimaldonado opened this issue Mar 24, 2021 · 5 comments
Closed

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

alimaldonado opened this issue Mar 24, 2021 · 5 comments
Labels
status: needs reproduction This issue needs a simplified reproduction of the bug for further troubleshooting. type: bug An issue or pull request relating to a bug in Gatsby

Comments

@alimaldonado
Copy link

alimaldonado commented Mar 24, 2021

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

  • Create a new page/component.
  • Add a graphql query, in my case:
const topDesigns = useStaticQuery(graphql`
    {
      directus {
        items {
          designs(sort: "date_created") {
            name
            extract
            date_created
            date_updated
          }
        }
      }
    }
  `);
  • Modify your graphql API and then modify your query to match the API
// fyi, I'm using Directus, though I don't believe it has something to do with the bug
const topDesigns = useStaticQuery(graphql`
    {
      directus {
        items {
          designs(sort: "date_created") {
            name
            extract
            picture
            date_created
            date_updated
          }
        }
      }
    }
  `);
  • Stop gatsby develop, run gatsby clean, and run gatsby develop again, so it will fetch again the data.

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 alimaldonado added the type: bug An issue or pull request relating to a bug in Gatsby label Mar 24, 2021
@gatsbot gatsbot bot added the status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer label Mar 24, 2021
@alimaldonado
Copy link
Author

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 LekoArts added status: needs reproduction This issue needs a simplified reproduction of the bug for further troubleshooting. topic: StaticQuery and removed status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer labels Mar 25, 2021
@LekoArts
Copy link
Contributor

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
Copy link
Contributor

minimit commented Mar 29, 2021

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

@alimaldonado
Copy link
Author

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
Copy link
Contributor

LekoArts commented Apr 6, 2021

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: needs reproduction This issue needs a simplified reproduction of the bug for further troubleshooting. type: bug An issue or pull request relating to a bug in Gatsby
Projects
None yet
Development

No branches or pull requests

3 participants