【发布时间】:2019-03-04 17:42:11
【问题描述】:
我正在尝试将我的 react 应用程序(使用 gatsby)连接到运行 Drupal 实例以使用 GraphQL 执行查询的 XAMPP 服务器。我不断收到有关我的配置文件的错误消息:
error Plugin gatsby-source-graphql returned an error
SyntaxError: Unexpected token < in JSON at position 0
这是我的配置文件代码:
module.exports = {
siteMetadata: {
title: 'Gatsby Default Starter',
},
plugins: [
{
resolve: "gatsby-source-graphql",
options: {
typeName: "DRUPAL",
fieldName: "drupal",
url: "http://localhost:8888/graphql",
},
},
],
}
我已经尝试使用和不使用最后一个“/graphql”的 localhost,只是“localhost”,但没有任何效果。我已经重新启动了我的前端和后端服务器两次。
编辑: 当我进入“http://localhost:8888/graphql”时,它会返回:
{"errors":[{"message":"GraphQL Request must include at least one of those two parameters: \u0022query\u0022 or \u0022queryId\u0022","category":"request"}]}
【问题讨论】:
标签: json reactjs graphql gatsby