Ruby on rails 使用graphql gem的Rails api使用哪个gatsby源插件

Ruby on rails 使用graphql gem的Rails api使用哪个gatsby源插件,ruby-on-rails,postgresql,heroku,graphql,gatsby,Ruby On Rails,Postgresql,Heroku,Graphql,Gatsby,我正在使用gem'graphql'构建一个Rails API,并希望使用Gatsby.js前端访问这个graphql API。我尝试使用插件和,但它们似乎都不起作用。(当我在本地机器上使用GraphiQL应用程序进行查询时,API工作正常。) 有更好的Gatsby.js源插件吗?它可以与使用gem'graphql'的Rails API配合使用,它提供了一个端点http://localhost:3000/graphql?如果是这样,我应该如何在gatsby config.js等中配置该插件?(顺便

我正在使用
gem'graphql'
构建一个Rails API,并希望使用
Gatsby.js
前端访问这个graphql API。我尝试使用插件和,但它们似乎都不起作用。(当我在本地机器上使用
GraphiQL
应用程序进行查询时,API工作正常。)

有更好的
Gatsby.js
源插件吗?它可以与使用
gem'graphql'
的Rails API配合使用,它提供了一个端点
http://localhost:3000/graphql
?如果是这样,我应该如何在
gatsby config.js
等中配置该插件?(顺便说一句,我正在使用一个Postgres数据库,我打算将其部署到Heroku——我曾想过继续使用,但我不确定这是否是最好的选择。)

routes.rb
中的Rails API中,我将
post”/graphql设置为:“graphql#execute”
以路由到
GraphqlController
。以下是控制器中的
execute
方法

def execute
  variables = ensure_hash(params[:variables])
  query = params[:query]
  operation_name = params[:operationName]
  context = {
    # Query context goes here, for example:
    # current_user: current_user,
  }
  result = GraphqlRailsSchema.execute(query, variables: variables, context: context, operation_name: operation_name)
  render json: result
  rescue => e
  raise e unless Rails.env.development?
  handle_error_in_development e
end
当我尝试呈现
json:result
时,
result
是:
[{“message”=>“没有查询字符串存在”}]>
,用于我下面引用的任何前端设置

在我的Gatsby.js前端中,当我使用时,在
Gatsby config.js
中,我有

{
  resolve: 'gatsby-source-apiserver',
  options: {
    typePrefix: 'internal__',
    url: `http://localhost:3000/graphql`,
    method: 'post',
    headers: {
      'Content-Type': 'application/json'
    },
    data: {

    },
    name: `posts`,
    entityLevel: `data.posts`,
    payloadKey: `body`,
  }
},
…当我运行
gatsby develope
时,我的控制台中出现了他的错误

{
  resolve: "gatsby-source-graphql",
  options: {
    // This type will contain remote schema Query type
    typeName: "Authors",
    // This is field under which it's accessible
    fieldName: "authors",
    // Url to query from
    url: "http://localhost:3000/graphql",
  },
},
TypeError:无法读取未定义的属性“数据”

而且,当我使用时,我在
gatsby config.js
中有这个

{
  resolve: "gatsby-source-graphql",
  options: {
    // This type will contain remote schema Query type
    typeName: "Authors",
    // This is field under which it's accessible
    fieldName: "authors",
    // Url to query from
    url: "http://localhost:3000/graphql",
  },
},
…当我运行
gatsby develope
时,我的控制台中出现了他的错误

{
  resolve: "gatsby-source-graphql",
  options: {
    // This type will contain remote schema Query type
    typeName: "Authors",
    // This is field under which it's accessible
    fieldName: "authors",
    // Url to query from
    url: "http://localhost:3000/graphql",
  },
},
错误:找不到模块“gatsby/graphql”


如您所见,我对如何在前端和后端之间连接
模式感到困惑。在此方面的任何帮助都将不胜感激

有没有找到解决方案?也在寻找解决方案