Reputation: 9
While I was setting the server, connecting to the MongoDB database, and doing a mutation, I'm getting the following error after running node index in my terminal: GraphQLError [Object]: Syntax Error: Cannot parse the unexpected character ";".
Index.JS:
const { ApolloServer } = require('apollo-server');
const gql = require('graphql-tag');
const typeDefs = gql`;
type Query{
SayHi: String!
}
`;
const resolvers = {
Query: {
sayHi: () => 'Hello World!'
}
};
const server = new ApolloServer({
typeDefs,
resolvers
});
server.listen({ port: 5000 }).then((res) => {
console.log('Server running at ${res.url}');
})
How can I resolve this issue?
Upvotes: 0
Views: 2147
Reputation: 387
I encountered the same issue, and the error message says exactly what is going wrong. There shouldn't contain ;
in the gql
block. I resolved the issue by removing the ;
character.
Upvotes: 1