Hey Prismic,
TL;DR I am running into this issue opened on GitHub in 2019, but none of the suggestions provided do work for me.
I am currently running into an issue I've never had before (with the gatsby-source-prismic-graphql
plugin), but no matter if I use the create page option inside gatsby-config.js
or the traditional Gatsby way inside gatsby-node.js
, the $uid
variable does net get passed into my page component query (I am using a "normal" page query and not StaticQuery
). The strange thing is I can open the pages locally in dev mode, but it breaks when deploying to Netlify or running the build command locally.
Nonetheless I get the following console error:
Variable "$uid" of required type "String!" was not provided.
// and
You might have a typo in the variable name "$uid" or you didn't provide the variable via context to this page query. Have a look at the docs to learn how to add data to context:
https://www.gatsbyjs.org/docs/page-query/#how-to-add-query-variables-to-a-page-query
What's interesting is, that the logged Gatsby link states a different way of passing a UID (i.e. with {eq: $uid}
) but that one is not available via the source plugin.
The UID definitely gets passed into the createPage
object, but it seams it never reaches the page component (I checked back with console logging the UID when creating the page and it get's logged correctly).
There was this Issue on GitHub, but reverting to the mentioned version does not help, neither does updating to the latest version help.
Here is my (shortened) query inside my page component:
export const query = graphql`
query JournalPostQuery($uid: String!) {
prismic {
journal_post(lang: "en-us", uid: $uid) {
hero_headline
hero_headline_appearance
hero_image
}
}
}
`
Just for the sake of completeness â my currently used packages (please note, I've tried the versions mentioned in the GitHub issue as well as some of the latest versions, the error is always the same!)
"gatsby": "^2.19.17",
"gatsby-source-prismic-graphql": "^3.5.0",
Thank you