When build website get the following error "Cannot query field "allGraphCmsPost" on type "Query"" .
HUFGhani opened this issue · comments
when build site getting following error, Command that i'm using to build site is yarn clean && yarn build
i've use the following example repo https://github.com/GraphCMS/gatsby-starter-graphcms-blog
I'm using Gatsby v4
ERROR #85923 GRAPHQL
There was an error in your GraphQL query:
Cannot query field "allGraphCmsPost" on type "Query".
If you don't expect "allGraphCmsPost" to exist on the type "Query" it is most likely a typo.
However, if you expect "allGraphCmsPost" to exist there are a couple of solutions to common problems:
- If you added a new data source and/or changed something inside gatsby-node.js/gatsby-config.js, please try a restart of your development server
- The field might be accessible in another subfield, please try your query in GraphiQL and use the GraphiQL explorer to see which fields you can query and what shape they have
- You want to optionally use your field "allGraphCmsPost" and right now it is not used anywhere. Therefore Gatsby can't infer the type and add it to the GraphQL schema. A quick fix is to add at least one entry with
that field ("dummy content")
It is recommended to explicitly type your GraphQL schema if you want to use optional fields. This way you don't have to add the mentioned "dummy content". Visit our docs to learn how you can define the schema for
"Query":
https://www.gatsbyjs.com/docs/reference/graphql-data-layer/schema-customization#creating-type-definitions
ERROR #85928
An error occurred during parallel query running.
Go here for troubleshooting tips: https://gatsby.dev/pqr-feedback
Error: Worker exited before finishing task
- index.js:112 ChildProcess.<anonymous>
/[gatsby-worker]/dist/index.js:112:45
- child_process.js:277 Process.ChildProcess._handle.onexit
internal/child_process.js:277:12
not finished run queries in workers - 0.202s
gatsby-config.js
module.exports = {
....
plugins: [
.....
{
resolve: 'gatsby-source-graphcms',
options: {
endpoint: process.env.GRAPHCMS_ENDPOINT,
token: process.env.GRAPHCMS_TOKEN,
buildMarkdownNodes: true,
downloadLocalImages: true,
stages: ['PUBLISHED'],
concurrency: 20,
},
},
}
]
gatsby-node.js
const path = require('path')
exports.createPages = async ({ actions: { createPage }, graphql }) => {
const { data } = await graphql(
`
{
posts: allGraphCmsPost(sort: { fields: date, order: ASC }, filter: { stage: { eq: PUBLISHED } }) {
edges {
page: node {
id
author {
id
name
title
}
content {
markdownNode {
childMdx {
body
}
}
}
excerpt
seo {
description
image {
url
}
keywords
title
}
slug
title
}
}
}
}
`
)
if (data.errors) throw data.errors
data.posts.edges.forEach(({ page }) => {
createPage({
component: path.resolve('./src/templates/blogPostTemplate.tsx'),
context: {
id: page.id,
page,
},
path: `/blog/${page.slug}`,
})
})
}
exports.createResolvers = ({ createResolvers }) => {
const resolvers = {
GraphCMS_Post: {
formattedDate: {
type: 'String',
resolve: source => {
const date = new Date(source.date)
return new Intl.DateTimeFormat('en-GB', {
weekday: 'long',
year: 'numeric',
month: 'long',
day: 'numeric',
}).format(date)
},
},
},
}
createResolvers(resolvers)
}
Package.json
"dependencies": {
"@chakra-ui/gatsby-plugin": "^2.0.2",
"@chakra-ui/icons": "^1.1.1",
"@chakra-ui/react": "^1.7.2",
"@emotion/react": "^11.6.0",
"@emotion/styled": "^11.6.0",
"@mdx-js/mdx": "^1.6.22",
"@mdx-js/react": "^1.6.22",
"@nivo/calendar": "^0.74.0",
"@nivo/core": "^0.74.0",
"axios": "^0.24.0",
"date-fns": "^2.25.0",
"framer-motion": "^5.3.0",
"gatsby": "^4.2.0",
"gatsby-image": "^3.11.0",
"gatsby-plugin-brotli": "^2.1.0",
"gatsby-plugin-image": "^2.2.0",
"gatsby-plugin-loadable-components-ssr": "^4.1.0",
"gatsby-plugin-manifest": "^4.2.0",
"gatsby-plugin-mdx": "^3.2.0",
"gatsby-plugin-minify-html": "^1.0.4",
"gatsby-plugin-react-helmet": "^5.2.0",
"gatsby-plugin-robots-txt": "^1.6.14",
"gatsby-plugin-sharp": "^4.2.0",
"gatsby-source-filesystem": "^4.2.0",
"gatsby-source-graphcms": "^2.6.0",
"gatsby-transformer-sharp": "^4.2.0",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-helmet": "^6.1.0",
"react-icons": "^4.3.1",
"react-seo-component": "^2.0.2",
"serverless": "^2.66.2"
},
"devDependencies": {
"@commitlint/cli": "^15.0.0",
"@commitlint/config-conventional": "^15.0.0",
"@loadable/component": "^5.15.0",
"@testing-library/jest-dom": "^5.15.0",
"@testing-library/react": "^12.1.2",
"@types/jest": "^27.0.2",
"@types/loadable__component": "^5.13.4",
"@types/mdx-js__react": "^1.5.5",
"@types/node": "^16.11.9",
"@types/react": "^17.0.33",
"@types/react-dom": "^17.0.11",
"@typescript-eslint/eslint-plugin": "^5.4.0",
"@typescript-eslint/parser": "^5.4.0",
"babel-jest": "^27.3.1",
"babel-preset-gatsby": "^2.2.0",
"eslint": "^8.2.0",
"eslint-config-prettier": "^8.3.0",
"eslint-import-resolver-alias": "^1.1.2",
"eslint-plugin-prettier": "^4.0.0",
"fullstack-serverless": "^0.8.0",
"gatsby-plugin-sitemap": "^5.2.0",
"gatsby-plugin-webpack-bundle-analyser-v2": "^1.1.26",
"husky": "^7.0.4",
"identity-obj-proxy": "^3.0.0",
"jest": "^27.3.1",
"jest-sonar-reporter": "^2.0.0",
"lint-staged": ">=12.1.2",
"prettier": "^2.4.1",
"typescript": "^4.5.2"
},
Hey
Can you provide your endpoint here?
Can you try removing some of the config options you have as well, such as download assets, and markdown nodes?
You may also want to upgrade the next
version as I've just published a new one.
The issue here seems to be more of an introspection issue, meaning no endpoint was found. Since allGraphCmsPost
is generated in step 1 of our plugin, the types should be available thereafter. Only if something went wrong there (cannot source it) would there be an issue, I believe.
Closing as this appears to be more of a config issue than a plugin issue. We can continue to discuss though. Will reopen if it's plugin related.
Thanks!