【问题标题】:Error There was an error while compiling your site's GraphQL queries错误 编译您网站的 GraphQL 查询时出错
【发布时间】:2020-02-17 00:41:11
【问题描述】:

当我执行 gatsby develop 时,这个错误不断出现。

export const pageQuery = graphql`
  query($path: String!) {
    markdownRemark(frontmatter: { path: { eq: $path } }) {
      html
      frontmatter {
        date(formatString: "MMMM DD, YYYY")
        path
        title
        porcao
        tempo
        cover
      }
    }
  }
`

GraphQL 错误 编译您网站的 GraphQL 查询时出现错误。 错误:RelayParser:遇到一个或多个文档的重复定义:每个文档必须具有唯一的名称。重复文件: - cUsersUserDocumentsPwaPizzaSrcTemplatesRecipeTemplateJs2809623611

【问题讨论】:

    标签: reactjs graphql markdown gatsby


    【解决方案1】:

    遇到一个或多个文档的重复定义:每个文档必须有一个唯一的名称。

    此错误是指您的 graphql 查询名称(这似乎是非唯一的)。

    假设您有一个索引页面和一个关于页面,每个页面都有自己的 graphql 查询。如果您为查询命名,则必须确保为它们提供唯一的名称。

    例如:

    // src/pages/about.js
    
    export const aboutPageQuery = graphql`
      query AboutQuery {...}
    `
    

    // src/pages/index.js
    
    export const indexPageQuery = graphql`
      query IndexQuery {...}
    `
    

    【讨论】:

      猜你喜欢
      • 2018-06-18
      • 1970-01-01
      • 2010-11-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-11-15
      • 2018-09-17
      • 1970-01-01
      相关资源
      最近更新 更多