GraphQLError [Object]: Syntax Error: Cannot parse the unexpected character ";"

1.9k Views Asked by At

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?

1

There are 1 best solutions below

0
On

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.