Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GraphQLError: Syntax Error: Expected Name, found [

Tags:

graphql

After trying to run a React app, I get the following error:

"GraphQLError: Syntax Error: Expected Name, found ["

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. Any thoughts?

like image 898
jayce504 Avatar asked Sep 25 '26 17:09

jayce504


1 Answers

Typo in the mutation for courtDates parameter..

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

should be:

createClient(
  name: $name,
  address: $address,
  phoneNumber: $phoneNumber,
  allegedOffenses: $allegedOffenses,
  courtDates: $courtDates
)
like image 145
Boney Avatar answered Sep 28 '26 23:09

Boney