I am new to graphQL and after trying to run a React app, I get the following error:
I'm getting the error: GraphQLError: Syntax Error: Expected Name, found "$".
Here are my graphql queries/mutations.
This works fine:
gqlMutation = {
mutation: gql`
mutation{
createMaps(input: [{
client_id: "7b8c903a-3402"
text: "Some Text"
}])
{
info{
nodesCreated
relationshipsCreated
}
Maps{
uid
}
}
}`
}
const res = await client.mutate(gqlMutation);
But when I try to pass variables then it throws an error
client_id="7b8c903a-3402";
text= "Some Text";
const preppedQuery =`
mutation{
createMaps(input: [{
$client_id: String!,
$text: String!
}])
{
info{
nodesCreated
relationshipsCreated
}
Maps{
uid
}
}
}`
}
const gqlMutation = {
mutation: gql`${preppedQuery}`,
variables:
{
client_id,
text
}
};
const res = await client.mutate(gqlMutation);