api
api copied to clipboard
Api
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}
)
);