如何解决Gatsby:GraphQL无法在类型“ Query”上查询字段“ allMarkdownRemark”
我是Gatsby的新手,正在尝试构建博客功能。我已经安装了gatsby-source-filesystem
,gatsby-transformer-remark
和gatsby-plugin-catch-links
。我在pages
目录中有博客文章,每个博客文章都在pages
内的文件夹中。当我尝试查询pages
中的博客文章时,会出现以下错误:
Cannot query field \"allMarkdownRemark\" on type \"Query\"
这是我的项目的结构:
这是我的配置文件:
module.exports = {
siteMetadata: {
title: `Gatsby Crash Course`,description: `Kick off your next,great Gatsby project with this default starter. This barebones starter ships with the main Gatsby configuration files you might need.`,author: `@gatsbyjs`,},plugins: [
`gatsby-plugin-react-helmet`,`gatsby-plugin-catch-links`,{
resolve: `gatsby-source-filesystem`,options: {
name: `images`,path: `${__dirname}/src/images`,options: {
name: `pages`,path: `${__dirname}/src/pages/`
},`gatsby-transformer-remark`,`gatsby-transformer-sharp`,`gatsby-plugin-sharp`,{
resolve: `gatsby-plugin-manifest`,options: {
name: `gatsby-starter-default`,short_name: `starter`,start_url: `/`,background_color: `#663399`,theme_color: `#663399`,display: `minimal-ui`,icon: `src/images/gatsby-icon.png`,// This path is relative to the root of the site.
},// this (optional) plugin enables Progressive Web App + Offline functionality
// To learn more,visit: https://gatsby.dev/offline
// `gatsby-plugin-offline`,],}
我的GraphQL查询:
{
allMarkdownRemark {
edges {
node {
frontmatter {
path
title
date
author
}
}
}
}
}
如何解决此错误,并使allMarkdownRemark
正常工作并从pages
检索博客文章?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。