简体   繁体   English

GraphQLError:语法错误:预期名称,找到 [

[英]GraphQLError: Syntax Error: Expected Name, found [

After trying to run a React app, I get the following error:尝试运行 React 应用程序后,出现以下错误:

"GraphQLError: Syntax Error: Expected Name, found [" “GraphQLError:语法错误:预期名称,找到 [”

The specific mutation the error references is:错误引用的具体突变是:

import gql from "graphql-tag";

export default gql(`
mutation($name: String!, $address: String!, $phoneNumber: String!, 
$allegedOffenses: String!, $courtDates: [AWSDate]!) {
createClient(
  name: $name,
  address: $address,
  phoneNumber: $phoneNumber,
  allegedOffenses: $allegedOffenses,
  courtDates: $[AWSDate]
) {
id,
name,
address,
phoneNumber,
allegedOffenses,
courtDates,
comments {
  items {
    commentId
   }
  }
 }
}`);

I tried using the troubleshooting steps found at GraphQLError: Syntax Error: Expected :, found { , but didn't have any luck.我尝试使用在GraphQLError: Syntax Error: Expected :, found { 中找到的故障排除步骤,但没有任何运气。 Any thoughts?有什么想法吗?

Typo in the mutation for courtDates parameter.. courtDates参数的突变中的courtDates ..

createClient(
  name: $name,
  address: $address,
  phoneNumber: $phoneNumber,
  allegedOffenses: $allegedOffenses,
  courtDates: $[AWSDate]
)

should be:应该:

createClient(
  name: $name,
  address: $address,
  phoneNumber: $phoneNumber,
  allegedOffenses: $allegedOffenses,
  courtDates: $courtDates
)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM