gatsby-source-prismic-graphql
gatsby-source-prismic-graphql copied to clipboard
"gatsby-source-prismic-graphql" threw an error while running the createPages lifecycle, related to pages type
When running gatsby develop
or gatsby build
, I get the following error:
ERROR #11321 PLUGIN
"gatsby-source-prismic-graphql" threw an error while running the createPages lifecycle:
Syntax Error: Expected $, found Name "Posty"
GraphQLError: Syntax Error: Expected $, found Name "Posty"
- new Promise
- graphql-runner.js:38 GraphQLRunner.query
[react-ajz003]/[gatsby]/dist/query/graphql-runner.js:38:12
failed createPages - 0.071s
I found that the Name "posty" is related to my options in the gatsby-config.js
file. Specifically the object defining the type 'Blog Post'.
pages: [{ // optional
type: 'Blog Post', // TypeName from prismic
match: '/article/:uid', // pages will be generated under this pattern
previewPath: '/article', // optional path for unpublished documents
component: require.resolve('./src/templates/article.js')
}]
I created a new custom type on Prismic called Article and used 'Article' in the type field instead, and worked. Is there a problem with having the type be separate words?
I think the problem is in your type name.
I had a similar issue, my type was Quick start guide page
It seems that the plugin capitalizes only the first letter, and connects the spaces with a _
, so what worked for me was changing the type
property in the gatsby-config.js
, for the gatsby-source-prismic-graphql
to Quick_start_guide_page
.
So I suggest you try to change your type to Blog_post
or Blog_Post
, and try again?
I also experienced this issue and the suggestion above from noblica works - in Prismic the type is ukulele
and using Ukulele
in gatsby-config.js works.
I experienced the same, the prismic type in gatsby-config.js
has to start with Capital letter
IMHO, this is undocumented behavior, and should be added to the docs, to avoid further confusion.
@noblica Thanks for finding the workaround. This needs to at least be documented.
But really, the TypeName as Prismic shows it to users is how users should be expected to put it into the config. It's not ideal/intuitive for users to know that "Blog Post" has to be manually converted to any one of "Blog_Post", "Blog_post", or "blog_post," so that the system recognizes it.
Hey, I made a PR for this issue here: ~~https://github.com/prismicio/gatsby-source-prismic-graphql/pull/2~~ https://github.com/birkir/gatsby-source-prismic-graphql/pull/214
Hope it's fine. Feel free to provide feedback!