apollo server object is an asynchronous function, the preceding line proceeds to access the server object before it could be initialized.
I think, It looks like this, to work as asynchronous function:
async function startServer() { server = new ApolloServer({ typeDefs, resolvers }); await server.start(); server.applyMiddleware({ app, path: '/api' }); } startServer();
app.listen({ port }, () => console.log( GraphQL Server running at htts://localhost: ${port} ${server.graphqlPath} ) );
GraphQL Server running at htts://localhost: ${port} ${server.graphqlPath}
Activity
mathewTheGreat commentedon Mar 28, 2022
apollo server object is an asynchronous function, the preceding line proceeds to access the server object before it could be initialized.
Raikyo777 commentedon Apr 6, 2022
I think, It looks like this, to work as asynchronous function:
async function startServer() {
server = new ApolloServer({ typeDefs, resolvers });
await server.start();
server.applyMiddleware({ app, path: '/api' });
}
startServer();
app.listen({ port }, () =>
console.log(
GraphQL Server running at htts://localhost: ${port} ${server.graphqlPath})
);