I'm getting the following Syntax error when trying to use Apollo client
GraphQLError: Syntax Error: Expected Name, found $
The query i'm sending is like so
const CREATE_AUTHOR = gql`
{
mutation createAuthor($firstName: String, $lastName: String) {
createAuthor(firstName: $firstName, lastName: $lastName) {
firstName
lastName
}
}
}
`;
My type definitions on the server are defined like this
//...
type Mutation {
createAuthor(firstName: String! lastName: String!): Author
updateAuthor(_id: String firstName: String lastName: String): Author
deleteAuthor(_id: String): Author
}
//...
My question is what is in correct with my useage of gql
looking at the apollo docs
https://www.apollographql.com/docs/react/essentials/mutations.html#calling-mutations
Their example matches my implementation I believe or I maybe misunderstanding the usage
const ADD_TODO = gql`
mutation addTodo($type: String!) {
addTodo(type: $type) {
id
type
}
}
`;
this.onSubmit
function look like? It looks like this linethis.onSubmit(e, createAuthor, firstName, lastName)
might be the discrepancy... – Chris Forrette