错误:始终违规:gatsby-source-graphql需要指定选项`typeName`

时间:2019-03-26 11:09:34

标签: graphql gatsby

我是GatsbyJs的新手-GraphQL,我一直在探索gatsby(https://github.com/gatsbyjs/gatsby/tree/master/examples/using-gatsby-source-graphql)提供的示例,当我尝试使用本地apollo-grapql服务器时,它在前端返回数据,但是会抛出异常上面的错误并阻止了构建过程,不确定是否需要将typeName传递给我?任何帮助,我们将不胜感激。

    `gatsby-source-graphql`,
    {
      resolve: "gatsby-source-graphql",
     options: {
      // This type will contain remote schema Query type
      typeName: "Query",
      // This is field under which it's accessible
      fieldName: "blah",
      // Url to query from
      url: "http://10.113.34.59:4000/graphql",
      // this is URL where served exposed its service in local
  },

1 个答案:

答案 0 :(得分:0)

`gatsby-source-graphql`, <==== this caused the issue
{
  resolve: "gatsby-source-graphql",
 options: {
  // This type will contain remote schema Query type
  typeName: "Query",
  // This is field under which it's accessible
  fieldName: "blah",
  // Url to query from
  url: "http://10.113.34.59:4000/graphql",
  // this is URL where served exposed its service in local
},

以下工作正常

{
  resolve: "gatsby-source-graphql",
 options: {
  // This type will contain remote schema Query type
  typeName: "Query",
  // This is field under which it's accessible
  fieldName: "blah",
  // Url to query from
  url: "http://10.113.34.59:4000/graphql",
  // this is URL where served exposed its service in local
 },