Estou com um problema com graphql e apollo server e nao sei pq esse erro persiste e nao sei com resolver. Mesmo colocando o 'await server.start()' continua dando erro SyntaxError: await is only valid in async functions and the top level bodies of modules
error console
Error: You must `await server.start()` before calling `server.applyMiddleware()`
at Object.<anonymous> (C:\Desenvolvedor\Quiz_JovemGenios\jovemgenio-app\packages\server\src\main.js:15:8)
at Generator.next (<anonymous>)
main.js
import express from 'express';
import { ApolloServer } from 'apollo-server-express';
import typeDefs from './graphql/typeDefs';
import resolvers from './graphql/resolvers';
const app = express();
const server = new ApolloServer ({
typeDefs: typeDefs,
resolvers: resolvers,
});
server.applyMiddleware({
app,
cors: {
origin: 'http://localhost:30000'
},
bodyParserConfig: true,
});
const PORT = process.env.PORT ? parseInt(process.env.PORT) : 80000
const HOSTNAME = process.env.HOSTNAME || '127.0.0.1'
app.listen(8000, '127.0.0.1', async() => {
console.log(`app is listening at http://${HOSTNAME}:${PORT}`)
});