首页 > 解决方案 > 如何解决 gatsby-source-graphql 的问题

问题描述

我试图连接gatsby-source-graphql我的 gatsby JS 项目。但我有错误 Cannot query field "alladventures" on type "Query"

这是我的 gatsby-config 代码和我的 API: https ://api.services.activelyme.com/graphql/playground

      resolve: `gatsby-source-graphql`,
      options: {
        // This type will contain remote schema Query type
        typeName: `ALLADVENTURES`,
        // This is the field under which it's accessible
        fieldName: `alladventures`,
        // URL to query from
        url: `https://api.services.activelyme.com/graphql`,
      },
    },

这是我的组件代码

    graphql`
      query {
        alladventures {
          adventures {
            title
          }
        }
        site {
          siteMetadata {
            title
            description
            author
            norwayItems {
              item {
                status {
                  category
                  date
                  season
                }
                title
                location
                userName
                description1
                dates
                show {
                  regular_price
                  promotional_price
                }
                rating {
                  stars
                  review
                  adventures
                }
                mainImage
                guideImage
                link
              }
            }
          }
        }
      }
    `
  )
Schema must contain uniquely named types but contains multiple types named "Query".

Error: Schema must contain uniquely named types but contains multiple types named "Query".

我必须展示冒险。但我每次都会出错。

如果我将此示例与此 API 一起使用,则一切正常 https://www.gatsbyjs.org/docs/third-party-graphql/

标签: graphqlgatsby

解决方案


推荐阅读