Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom type naming conventions (error while running the createPages lifecycle) #42

Open
Jussiles opened this issue Aug 13, 2020 · 3 comments

Comments

@Jussiles
Copy link

Jussiles commented Aug 13, 2020

After updating Gatsby from 2.21.9 I started getting this error. Then I updated also gatsby-source-prismic-graphql plugin from 3.6.2 to use this repo and latest tag 3.6.11. Error still exists. Happens on running gatsby develop or gatsby build:

ERROR #11321  PLUGIN

"@prismicio/gatsby-source-prismic-graphql" threw an error while running the createPages lifecycle:

Unknown type "PRISMIC_SortPagecorey". Did you mean "PRISMIC_SortPageCorey", "PRISMIC_SortPagey", "PRISMIC_PageCore", "PRISMIC_WherePageCore", or "PRISMIC_SortCorePagey"?

  260 |                         });
  261 |                         _context.next = 10;
  262 |                         return graphql(query, {
      |                                ^
  263 |                           after: endCursor,
  264 |                           lang: lang || null,
  265 |                           sortBy: page.sortBy

File: node_modules/@prismicio/gatsby-source-prismic-graphql/gatsby-node.js:262:32

Error: Unknown type "PRISMIC_SortPagecorey". Did you mean "PRISMIC_SortPageCorey", "PRISMIC_SortPagey", "PRISMIC_PageCore", "PRISMIC_WherePageCo  re", or "PRISMIC_SortCorePagey"?
  GraphQL request:2:64
  1 |
  2 |   query AllPagesQuery ($after: String, $lang: String, $sortBy: PRISMIC_SortPagecorey) {
    |                                                                ^
  3 |     prismic {

  - graphql-runner.ts:98 GraphQLRunner.validate
    [packx-marketing]/[gatsby]/src/query/graphql-runner.ts:98:22

  - graphql-runner.ts:162 GraphQLRunner.query
    [packx-marketing]/[gatsby]/src/query/graphql-runner.ts:162:25

  - create-graphql-runner.ts:59
    [packx-marketing]/[gatsby]/src/bootstrap/create-graphql-runner.ts:59:8

  - gatsby-node.js:262 _callee$
    [packx-marketing]/[@prismicio]/gatsby-source-prismic-graphql/gatsby-node.js:262:32

  - new Promise

  - From previous event:

  - api-runner-node.js:440 Promise.catch.decorateEvent.pluginName
    [packx-marketing]/[gatsby]/src/utils/api-runner-node.js:440:9

  - From previous event:

  - api-runner-node.js:439
    [packx-marketing]/[gatsby]/src/utils/api-runner-node.js:439:14

  - timers.js:439 processImmediate
    internal/timers.js:439:21

  - From previous event:

  - api-runner-node.js:431
    [packx-marketing]/[gatsby]/src/utils/api-runner-node.js:431:13

  - From previous event:

  - api-runner-node.js:347 module.exports
    [packx-marketing]/[gatsby]/src/utils/api-runner-node.js:347:3

  - create-pages.ts:25 createPages
    [packx-marketing]/[gatsby]/src/services/create-pages.ts:25:9

  - interpreter.js:721 Interpreter.exec
    [packx-marketing]/[gatsby]/[xstate]/lib/interpreter.js:721:27

  - interpreter.js:223 Interpreter.execute
    [packx-marketing]/[gatsby]/[xstate]/lib/interpreter.js:223:22

  - interpreter.js:243 Interpreter.update
    [packx-marketing]/[gatsby]/[xstate]/lib/interpreter.js:243:18

  - interpreter.js:144
    [packx-marketing]/[gatsby]/[xstate]/lib/interpreter.js:144:23

  - scheduler.js:59 Scheduler.process
    [packx-marketing]/[gatsby]/[xstate]/lib/scheduler.js:59:13

  - scheduler.js:43 Scheduler.schedule
    [packx-marketing]/[gatsby]/[xstate]/lib/scheduler.js:43:14

  - interpreter.js:140 Interpreter.send
    [packx-marketing]/[gatsby]/[xstate]/lib/interpreter.js:140:29

  - interpreter.js:836 actor.id
    [packx-marketing]/[gatsby]/[xstate]/lib/interpreter.js:836:23

failed createPages - 0.191s

This is my gatsby-config.js:

      resolve: '@prismicio/gatsby-source-prismic-graphql',
      options: {
        accessToken: '${process.env.PRISMIC_API_KEY}',
        repositoryName: '${process.env.PRISMIC_REPOSITORY_NAME}',
        defaultLang: defaultLanguage.locale,
        langs: Object.values(languages).map(lang => lang.locale),
        shortenUrlLangs: true,
        path: '/preview',
        previews: true,
        pages: [
          {
            type: 'PageCore',
            match: '/:lang/:uid',
            previewPath: '/preview-pagecore',
            filter: data =>
              !isDummy(data.node._meta) &&
              !['index', 'home'].includes(data.node._meta.uid),
            component: require.resolve('./src/templates/pageCore.js'),
            sortBy: 'date_ASC',
          },
          {
            type: 'Page',
            match: '/:lang/:uid',
            previewPath: '/preview-page',
            filter: data =>
              !isDummy(data.node._meta) &&
              !['index', 'home'].includes(data.node._meta.uid),
            component: require.resolve('./src/templates/page.js'),
          },
]

Issue seems to be with PageCore. Type Page works fine.

I found some related issues from old and new repo but didn't find solutions from those.
birkir#200 (comment)
#2

@Jussiles
Copy link
Author

Jussiles commented Aug 18, 2020

Seems nobody has been interested in this issue. I will try to take the discussion about naming convention further.

Is there any documentation about how the naming convention should be between Prismic - Prismic GraphQL API - Gatsby (this plugin)?

What worked for our project before on gatsby-config.js (type: PageCore, type: BlogPost…) doesn’t work anymore after the PR (#2) was merged. I know I could create new Custom type with new API ID as a workaround. But that would require me upgrade our Prismic plan from Starter to Medium to import/export the existing content to the new Custom type. It’s not what I want to do in the first place.

On the Prismic side our Custom type API IDs are: page-core, blog-post…

Should the naming conventions for Custom type be documented somewhere? After it there can be fixes done based on documentation for the plugin if needed.

Thoughts?

@Jussiles Jussiles changed the title error while running the createPages lifecycle Custom type naming conventions (error while running the createPages lifecycle) Aug 18, 2020
@MarcMcIntosh
Copy link

Hi @Jussiles

Error: Unknown type "PRISMIC_SortPagecorey". Did you mean "PRISMIC_SortPageCorey",
Hmm looks like an error with capitalisation :/

You you provide a recreation of the issue in the examples and open a PR?

If you run into issues creating an example, I recommend using gatsby 2.24.11

@petrogad
Copy link

Just hit this too. My prismic content type was labeled: "blog_post", I then attempted to use a config for my page as:

{
    type: 'blog_post',
    path: '/blog/',
    match: '/blog/:uid',
    previewPath: '/blog/',
    component: require.resolve('./src/templates/blogPost.tsx')
}

I also tried types of: "BlogPost", "Blog_Post", "blog_post" and the only type I got to work was "Blog_post".

It seems as if there's an issue with handling _ special and uniquely.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants