Gatsby:GraphQL无法在类型“ Query”上查询字段“ allMarkdownRemark”

问题描述

我是Gatsby的新手,正在尝试构建博客功能。我已经安装了gatsby-source-filesystemgatsby-transformer-remarkgatsby-plugin-catch-links。我在pages目录中有博客文章,每个博客文章都在pages内的文件夹中。当我尝试查询pages中的博客文章时,会出现以下错误

Cannot query field \"allMarkdownRemark\" on type \"Query\"

这是我的项目的结构:

enter image description here

这是我的配置文件

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 (将#修改为@)