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?
I encountered the same issue, and the error message says exactly what is going wrong. There shouldn't contain
;
in thegql
block. I resolved the issue by removing the;
character.