do-kevin
(Kevin)
January 21, 2022, 8:59pm
1
package.json
"gatsby": "^4.3.0",
"gatsby-background-image": "^1.6.0",
"@storybook/react": "^6.4.9",
"storybook-addon-gatsby": "^0.0.3",
Hi, I'm trying to get images to load when I'm using StaticQuery. In Storybook, it just shows as Loading (StaticQuery)
. I've been researching this issue and encountered a potential fix in this GitHub issue:
opened 11:20PM - 17 May 19 UTC
closed 10:05PM - 20 May 19 UTC
bug
There is a StaticQuery error wherever we use `useSiteMetadata()` which queries G… raphQL. This appears like best practices in Gatsby but is not working in our Storybook.
**Error**
> 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
In Gatsby's issue tracker 👉 https://github.com/gatsbyjs/gatsby/issues/10662
**Repro**
1. Clone /frontpage
2. `yarn install && yarn build && yarn run storybook`
3. Go to [IndexScreen:default](http://localhost:6007/?path=/story/frontpage-screens-indexscreen-indexscreen--default) in Storybook
4. See error
**More context**
The strange thing is that this behavior doesn't appear when Chromatic renders the component for some reason.
Anyone seen this before? cc @tmeasday @dakebl @isaac-martin
However, when I try adding
config.module.rules[0].use[0].options.plugins.push(
[
require.resolve('babel-plugin-remove-graphql-queries'),
{
stage: config.mode === `development` ? 'develop-html' : 'build-html',
staticQueryDir: './page-data/sq/d'
}
]
);
to my .storybook/main.js
, I get Error: Duplicate plugin/preset detected.
in my console window. Since babel-plugin-remove-graphql-queries
is already a dependency for storybook-addon-gatsby
, how do I override this plugin's option?
Phil
(Phil Snow)
January 24, 2022, 10:32am
3
Hi Kevin,
Welcome to the community!
I'm definitely not an expert on Gatsby, but I'm going to reach out to my team members with more experience to see if they can help you with this.
Thanks.
Hi @do-kevin ,
Thanks for pointing this out. Static Query support is now built-in to storybook-addon-gatsby
in v0.0.4
.
Could you update and let me know if this fixes your issue?
The addon provides the stage
and staticQueryDir
options to babel-plugin-remove-graphql-queries
, just like your example.
It also configures Storybook to load the ./page-data/sq/d
directory automatically, so you do not need to use the -s
option when starting Storybook.
Thanks!