gatsby-source-prismic-graphql icon indicating copy to clipboard operation
gatsby-source-prismic-graphql copied to clipboard

Uncaught TypeError: Cannot set property 'query' of undefined

Open jonybekov opened this issue 4 years ago • 12 comments

Console throws an error when I build my project and run gatsby serve.
Uncaught TypeError: Cannot set property 'query' of undefined image

Neither swiper carousel nor bootstrap navbar toggle is working in production. In development mode everything works great!

Here's a github link to reproduction of my project https://github.com/Teo0303/raisense-bug-repro/

Here's my website that has the issue. https://raisense.uz/

Can anybody ever solved this kind of problem?

*** Edit ***

This problem only appears when I use gatsby-source-prismic-graphql. When I loaded data from local storage and built my project, problem disappeared

jonybekov avatar Nov 20 '19 08:11 jonybekov

With beta2 that is gone. But be aware that some other issues may come see https://github.com/birkir/gatsby-source-prismic-graphql/issues/77

saschb2b avatar Nov 22 '19 14:11 saschb2b

@saschb2b looks like even with the beta, it's breaking other usestaticquerys when you build it. Works find locally.

fandy avatar Nov 28 '19 11:11 fandy

Yep. Had to refactor everything to use the StaticQuery component

saschb2b avatar Nov 28 '19 12:11 saschb2b

Hey, @Teo0303 I don't see any problem when Itry to use your project. I don't understand why you're having this error in gatsby-browser.js though.

Are you performing queries in gatsby-browser?

Duaner avatar Nov 29 '19 16:11 Duaner

Having the same issue 👋

pierrenel avatar Dec 13 '19 17:12 pierrenel

I also am having this issue, you can work around by commenting out the fix and using a forked version of the repo. Not ideal though @birkir would you accept a PR for the removal of the fix?

EDIT Anyone wanting a workaround this has worked fine for me till we have a permanent solution: make a copy of the gatsby-browser.js file from gatsby-source-prismic-graphql with the previous fix code commented out / deleted. Add this to your package.json scripts:

"postinstall": "mv PATCHED_GATSBY_BROWSER.js node_modules/gatsby-source-prismic-graphql/gatsby-browser.js && echo '** gatsby-source-prismic-graphql has been patched, only confirmed as working on v3.3.1 test before upgrading **'"

robcalcroft avatar Dec 17 '19 17:12 robcalcroft

Hi, I see a v3.4.0 tag in your repo, but it's not published to npm. Does that version include the fix for this? I'm not able to install it directly from github bc. of something to do w/ your package.json setup.

jayKayEss avatar Feb 12 '20 18:02 jayKayEss

I had the same issue. Building the project for production is causing all JS events like onClick to stop working. I've manage to work around it my using version: 3.4.0-beta.1 and then switching all my useStaticQuery to < StaticQuery />. Hoping for an update soon :)

aodysseos avatar Feb 25 '20 20:02 aodysseos

Running into this issue with useStaticQuery also. Using this plugin is quite the frustrating experience.

justinluk avatar Mar 19 '20 15:03 justinluk

I had the same problem. With version gatsby-source-prismic-graphql": { "version": "3.5.0" it works.

mniederm avatar Mar 20 '20 16:03 mniederm

I have the same issue. Unfortunately 3.5.0 doesn't fix it on my end. Changing to <StaticQuery /> was the only working quick workaround.

@birkir can we have your assistance on this issue?

devfive avatar Mar 23 '20 22:03 devfive

Same issue here. With the latest version of the plugin. (3.5.0)

<StaticQuery /> indeed works as a temporary&ugly fix. Thanks!

Mokto avatar Apr 07 '20 12:04 Mokto