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

"gatsby-source-prismic-graphql" threw an error while running the createPages lifecycle, related to pages type #200

Open
ajz003 opened this issue May 2, 2020 · 6 comments

Comments

@ajz003
Copy link

ajz003 commented May 2, 2020

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?

@noblica
Copy link
Contributor

noblica commented May 15, 2020

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?

@meandillar
Copy link

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.

@wooxudong
Copy link

I experienced the same, the prismic type in gatsby-config.js has to start with Capital letter

@noblica
Copy link
Contributor

noblica commented May 18, 2020

IMHO, this is undocumented behavior, and should be added to the docs, to avoid further confusion.

@hs737
Copy link

hs737 commented May 19, 2020

@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.

@noblica
Copy link
Contributor

noblica commented May 19, 2020

Hey, I made a PR for this issue here: prismicio#2
#214

Hope it's fine. Feel free to provide feedback!

noblica referenced this issue Oct 23, 2020
* docs: mention forgotten fix in changelog

(and remove commits not relevant)

* Add formatting for page types

Co-authored-by: Vincent Velociter <[email protected]>
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

5 participants