'"Unable to connect to server" error during the creation of development graph
but the server is started : "server started at http://localhost:4000/graphql"
this is the code in index.ts :
(async () => {
const app = express();
const options = await getConnectionOptions(
process.env.NODE_ENV || "development"
);
await createConnection({ ...options, name: "default" });
const apolloServer = new ApolloServer({
schema: await buildSchema({
resolvers: [MovieResolver],
validate: true
}),
context: ({ req, res }) => ({ req, res })
});
apolloServer.applyMiddleware({ app, cors: false });
const port = 4000;
app.listen(port, () => {
console.log(`server started at http://localhost:${port}/graphql`);
});
})();
Solution 1:[1]
Probably you need to add /graphql at the end,
http://localhost:4000/graphql
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Sajeetharan |

