The issue I am running into is that when I set a key-value pair in the gatsby-config.js file I am not able to see the data inside GraphiQL. I am following the documentation and using keys that are used in the example code. See here for the documentation: https://www.gatsbyjs.org/docs/gatsby-config/#sitemetadata
Here is my gatsby-config.js
file:
module.exports = {
siteMetadata: {
title: `My Photography Site`,
description: `Just the best`,
},
plugins: [
`gatsby-plugin-emotion`,
`gatsby-transformer-remark`,
{
resolve: `gatsby-source-filesystem`,
options: {
name: `src`,
path: `${__dirname}/src/`,
},
},
{
resolve: `gatsby-plugin-typography`,
options: {
pathToConfigModule: `src/utils/typography`,
},
},
],
}
Here is my GraphiQL query (after restarting the development server to reload the gatsby-config.js file):
query SiteQuery {
site {
siteMetadata {
title
description
}
}
}
Expected results from the GraphiQL:
{
"data": {
"site": {
"siteMetadata": {
"title": "My Photography Site",
"description": "Just the best"
}
}
}
}
Here is the actual result of the GraphiQL:
{
"errors": [
{
"message": "Cannot query field \"description\" on type \"SiteSiteMetadata\".",
"locations": [
{
"line": 5,
"column": 7
}
],
"stack": [
"GraphQLError: Cannot query field \"description\" on type \"SiteSiteMetadata\".",
" at Object.Field (/mnt/c/Users/Spencer/dev/gatsbyjs/hello-world/node_modules/graphql/validation/rules/FieldsOnCorrectType.js:64:31)",
" at Object.enter (/mnt/c/Users/Spencer/dev/gatsbyjs/hello-world/node_modules/graphql/language/visitor.js:334:29)",
" at Object.enter (/mnt/c/Users/Spencer/dev/gatsbyjs/hello-world/node_modules/graphql/language/visitor.js:385:25)",
" at visit (/mnt/c/Users/Spencer/dev/gatsbyjs/hello-world/node_modules/graphql/language/visitor.js:252:26)",
" at validate (/mnt/c/Users/Spencer/dev/gatsbyjs/hello-world/node_modules/graphql/validation/validate.js:63:22)",
" at /mnt/c/Users/Spencer/dev/gatsbyjs/hello-world/node_modules/express-graphql/dist/index.js:154:52",
" at processTicksAndRejections (internal/process/task_queues.js:89:5)"
]
}
]
}
What is odd is that I was able to successfully create a custom key-value pair before and it worked fine. I had a key of tagLine
and a value of Panda Site
. The normal title
key worked as well.
Here are the software versions I am using:
- gatsby: 2.5.12
- node: v12.1.0
- npm: 6.9.0
I am running using Windows Subsystem for Linux (WSL). Let me know if you would like any other config files, including package.json.