prismicio / gatsby-source-prismic-graphql

Gatsby source plugin for Prismic GraphQL
MIT License
17 stars 14 forks source link

createPages failed. Unknown type "PRISMIC_SortPagey" #54

Open greatwitenorth opened 4 years ago

greatwitenorth commented 4 years ago

We have a project that has been using this source plugin for sometime, and this morning when I went to fire up my local development copy I got this error message:

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

Unknown type "PRISMIC_SortPagey". Did you mean "PRISMIC_SortPage", "PRISMIC_Page", "PRISMIC_WherePage", "PRISMIC_SortFooter", or "PRISMIC_Footer"?

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

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

  Error: Unknown type "PRISMIC_SortPagey". Did you mean "PRISMIC_SortPage", "PRISMIC_Page", "PRISMIC_WherePage", "PRISMIC_SortFooter", or "PRISMIC_Footer"?
  GraphQL request:2:64
  1 |
  2 |   query AllPagesQuery ($after: String, $lang: String, $sortBy: PRISMIC_SortPagey) {
    |                                                                ^
  3 |     prismic {

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

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

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

  - gatsby-node.js:262 _callee$
    [ecopoxy]/[gatsby-source-prismic-graphql]/gatsby-node.js:262:32

I'm not sure why, but it looks like a "y" is being appended to the PRISMIC_Sort type:

https://github.com/prismicio/gatsby-source-prismic-graphql/blob/6a23f5f32dcd95d054ca473dbd9b253a04726dff/packages/gatsby-source-prismic-graphql/src/gatsby-node.ts#L254

I suppose this was working fine at one point, but I had to modify the code to remove the "y" and it seems to work. Not sure what changed or how to debug this further.

Our production builds are failing on Netlify as well. Yesterday around 10am cst the build ran fine. Today I've tried to re-deploy the same site with no code/prismic cms changes and the build now fails with the same above error.

greatwitenorth commented 4 years ago

After looking into this further it seems like our grapqhl endpoint is returning the sort types now without the "y" ending:

For the query:

query{
  __schema{
    types{
      name
    }
  }
}

I get this result:

...
{
      "name": "SortPage"
},
...

Not sure if anyone else's repos are seeing this issue. Will reach out to prismic support.