Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

StaticQuery is not working #232

Open
gforro opened this issue Jun 29, 2020 · 4 comments
Open

StaticQuery is not working #232

gforro opened this issue Jun 29, 2020 · 4 comments

Comments

@gforro
Copy link

gforro commented Jun 29, 2020

The static queries stop to work, when the gatsby-source-prismic-graphql plugin is configured to be used. The problem is that the query is stucked for some reasons and the Loading (StaticQuery) message is shown in a page, where a component with a simple static query is used. It is enough to use the static-query example from this repositories to reproduce the problem. Steps to reproduce the problem:

  1. Add the following to the package.json (to fix the issue in gatsby-source-graphql-universal - Error: Cannot find module './third-party/gatsby-node):
    Add to the scripts part:
    "preinstall": "npx npm-force-resolutions",
    
    Add to the root part:
    "resolutions": {
      "gatsby-source-graphql-universal": "3.3.0"
    }
  2. Add the following to the gatsby-node.js to fix the issue with the cache (problem when gatsby cache is cleaned):
    let fs = require("fs")
    let dir = "./.cache/caches/gatsby-source-prismic-graphql"
    
    exports.onPreBootstrap = () => {
      if (!fs.existsSync(dir)) {
        fs.mkdirSync(dir)
      }
    }
    
  3. Uncomment the <Layout> part in the index.js page.

Now You will get the problem!

@gforro
Copy link
Author

gforro commented Jun 29, 2020

The problem is caused by a change in the gatsby's babel-plugin-remove-graphql-queries which is shadowed in the implementation of gatsby-source-graphql-universal.

Change in the gatsbyjs:
gatsbyjs/gatsby@752f5ff#diff-a46d7772b3756095c8e95b889d9b1df1

@gforro
Copy link
Author

gforro commented Jun 29, 2020

Pull request has been created for the fix in the gatsby-source-graphql-universal: birkir/gatsby-source-graphql-universal#25

@MarcMcIntosh
Copy link

Hi @gforro can you make the PR here and we'll merge it into an upstream package?
https://github.com/prismicio/gatsby-source-graphql-universal

@natedonato
Copy link

If anyone is having the same issue with staticquery, or an issue with a broken dependency in the gatsby-source-prismic-graphql, I fixed mine by switching from this branch to the @prismicio branch mentioned by @MarcMcIntosh that has more fixes applied.

For NPM newbies like me that need more specific instructions:

The easiest way I found to seamlessly switch to the prismic fork was to remove the old package, and then install the prismic version as an alias
npm i gatsby-source-prismic-graphql@npm:@prismicio/gatsby-source-prismic-graphql

Can also be done by adding this to your package.json dependencies
"gatsby-source-prismic-graphql": "npm:@prismicio/gatsby-source-prismic-graphql@^3.6.10",

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants