dhoulb / gatsby-plugin-templated-files

DEPRECATED: Plugin is no longer supported
BSD Zero Clause License
5 stars 1 forks source link

Doesn't seem to work on recent versions of Gatsby #3

Open alexpeattie opened 5 years ago

alexpeattie commented 5 years ago

I seem to get an Unknown field 'templated' on type 'Query' error when trying to run the demo/ site on the recent versions of Gatsby (e.g. 2.3.31). I don't get the same issue when locking Gatsby's version to 2.0.29.

Possible causes

I had a bit of a play around and it seems like setFieldsOnGraphQLNodeType is never being called with the Templated type, i.e. this conditional is always false. I'm not sure why though? It wonder if it could be related to the changes introduced by the new schema customization API?

https://www.gatsbyjs.org/blog/2019-03-04-new-schema-customization/ https://www.gatsbyjs.org/blog/2019-03-18-releasing-new-schema-customization/ https://github.com/gatsbyjs/gatsby/issues/12272

Steps to reproduce

git clone https://github.com/dhoulb/gatsby-plugin-templated-files.git
cd gatsby-plugin-templated-files
yarn install
cd demo
yarn install
yarn run develop

Result:

yarn run v1.15.2
$ yarn clean && gatsby develop
$ trash .cache && trash public
success open and validate gatsby-configs — 0.006 s
success load plugins — 0.080 s
success onPreInit — 0.004 s
success initialize cache — 0.006 s
success copy gatsby files — 0.094 s
success onPreBootstrap — 0.009 s
success source and transform nodes — 0.018 s
success building schema — 0.173 s
success createPages — 0.001 s
gatsby-plugin-templated-files: chokidar add pages/child1.md
gatsby-plugin-templated-files: create node /pages/child1
gatsby-plugin-templated-files: create page /pages/child1
gatsby-plugin-templated-files: chokidar add pages/child3.txt
gatsby-plugin-templated-files: create node /pages/child3
gatsby-plugin-templated-files: create page /pages/child3
gatsby-plugin-templated-files: chokidar add pages/index.md
gatsby-plugin-templated-files: create node /pages/
gatsby-plugin-templated-files: add child /pages/child1
gatsby-plugin-templated-files: add child /pages/child3
gatsby-plugin-templated-files: create page /pages/
gatsby-plugin-templated-files: chokidar add pages/child2/LIST.md
gatsby-plugin-templated-files: create node /pages/child2
gatsby-plugin-templated-files: add parent /pages/
gatsby-plugin-templated-files: create page /pages/child2
gatsby-plugin-templated-files: chokidar add pages/child2/subchild1.md
gatsby-plugin-templated-files: create node /pages/child2/subchild1
gatsby-plugin-templated-files: add parent /pages/child2
gatsby-plugin-templated-files: create page /pages/child2/subchild1
gatsby-plugin-templated-files: chokidar add pages/child2/subchild2.md
gatsby-plugin-templated-files: create node /pages/child2/subchild2
gatsby-plugin-templated-files: add parent /pages/child2
gatsby-plugin-templated-files: create page /pages/child2/subchild2
gatsby-plugin-templated-files: chokidar add blog/2004-12-20 - Blog Article 1.md
gatsby-plugin-templated-files: create node /blog/2004/12/20/blog-article-1
gatsby-plugin-templated-files: add parent /pages/
gatsby-plugin-templated-files: create page /blog/2004/12/20/blog-article-1
gatsby-plugin-templated-files: chokidar add blog/2018-12-20 - Blog Article 2.md
gatsby-plugin-templated-files: create node /blog/2018/12/20/blog-article-2
gatsby-plugin-templated-files: add parent /pages/
gatsby-plugin-templated-files: create page /blog/2018/12/20/blog-article-2
success createPagesStatefully — 0.136 s
success onPreExtractQueries — 0.000 s
success update schema — 0.102 s
error GraphQL Error Encountered 2 error(s):
- Unknown field 'templated' on type 'Query'. Source: document `usersAlexDocumentsDemoSrcTemplatesPageJsx505431571` file: `GraphQL request`

  GraphQL request (3:3)
  2:    query($id: String!) {
  3:        templated(id: { eq: $id }) {
       ^
  4:            rootPath

- Unknown field 'templated' on type 'Query'.

      file: /Users/alex/Documents/demo/src/blog-templates/Blog.jsx
alexpeattie commented 5 years ago

Actually, it looks like a race condition where the schema is built before the first node is added.

cbetta commented 5 years ago

Running into the same issue.

rparree commented 5 years ago

Any solutions available for this?

tx.

dhoulb commented 5 years ago

Hi everyone, sorry about the issue. I found Gatsby's GraphQL integration is a bit flaky when I made the plugin but it was difficult to make it more robust.

It'll take a deep dive to fix but I don't have availability right now unfortunately. Will update you if I find the time.

kiastorm-zz commented 4 years ago

would love a solution for this!