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 fields are not under 'node.fields' available but under 'node.frontmatter' #125

Open
zeekrey opened this issue May 11, 2020 · 1 comment

Comments

@zeekrey
Copy link

zeekrey commented May 11, 2020

I created a new project based on https://github.com/gatsbyjs/gatsby/tree/master/examples/using-markdown-pages

After I added gatsby-plugin-i18n the following errors occurs:

File: node_modules/gatsby-plugin-i18n/createPages.js:46:10

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
gatsby-plugin-i18n error:
[
  GraphQLError: Cannot query field "fields" on type "MarkdownRemark".
      at Object.Field (/private/tmp/gatsby/examples/using-markdown-pages/node_modules/graphql/validation/rules/FieldsOnCorrectType.js:53:31)
      at Object.enter (/private/tmp/gatsby/examples/using-markdown-pages/node_modules/graphql/language/visitor.js:324:29)
      at Object.enter (/private/tmp/gatsby/examples/using-markdown-pages/node_modules/graphql/language/visitor.js:375:25)
      at visit (/private/tmp/gatsby/examples/using-markdown-pages/node_modules/graphql/language/visitor.js:242:26)
      at validate (/private/tmp/gatsby/examples/using-markdown-pages/node_modules/graphql/validation/validate.js:73:24)
      at GraphQLRunner.validate (/private/tmp/gatsby/examples/using-markdown-pages/node_modules/gatsby/dist/query/graphql-runner.js:82:44)
      at GraphQLRunner.query (/private/tmp/gatsby/examples/using-markdown-pages/node_modules/gatsby/dist/query/graphql-runner.js:146:25)
      at /private/tmp/gatsby/examples/using-markdown-pages/node_modules/gatsby/dist/bootstrap/create-graphql-runner.js:25:37
      at /private/tmp/gatsby/examples/using-markdown-pages/node_modules/gatsby-plugin-i18n/createPages.js:49:5
      at new Promise (<anonymous>)
      at Object.createPages (/private/tmp/gatsby/examples/using-markdown-pages/node_modules/gatsby-plugin-i18n/createPages.js:46:10)
      at runAPI (/private/tmp/gatsby/examples/using-markdown-pages/node_modules/gatsby/dist/utils/api-runner-node.js:256:37)
      at Promise.catch.decorateEvent.pluginName (/private/tmp/gatsby/examples/using-markdown-pages/node_modules/gatsby/dist/utils/api-runner-node.js:375:15)
      at Promise._execute (/private/tmp/gatsby/examples/using-markdown-pages/node_modules/bluebird/js/release/debuggability.js:384:9)
      at Promise._resolveFromExecutor (/private/tmp/gatsby/examples/using-markdown-pages/node_modules/bluebird/js/release/promise.js:518:18)
      at new Promise (/private/tmp/gatsby/examples/using-markdown-pages/node_modules/bluebird/js/release/promise.js:103:10) {
    message: 'Cannot query field "fields" on type "MarkdownRemark".',
    locations: [ [Object] ]
  }
]
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

It looks like gatsby-transformer-remark puts custom fields under node.frontmatter. At least there is no node called node.fields. After installing gatsby-plugin-i18n nothing actually happened. I looked into the source code and saw, that getMarkdownPage.js expects a node called node.fields.slug and node.fields.langKey. But at least in the graphql explorer I can't find this data.

Does anybody know how to fix this?

@zeekrey
Copy link
Author

zeekrey commented May 11, 2020

Sorry, I missed the graphql query in the config object. I changed it:

markdownRemark: {
          postPage: 'src/templates/blogTemplate.js',
          query: `
            {
              allMarkdownRemark {
                edges {
                  node {
                    frontmatter {
                      slug,
                      langKey
                    }
                  }
                }
              }
            }
          `
        }

But still, nothing happens. If I look at the page sitemap, there are no routes for the actual language keys.

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

1 participant