Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: the current Apollo docs causes an async error #1082

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ npm: "apollo-server-express"
To run a hello world server with apollo-server-express:

```bash
npm install apollo-server-express express
npm install apollo-server-express express graphql
```

Then run `node server.js` with this code in `server.js`:
Expand All @@ -32,12 +32,17 @@ const resolvers = {

const server = new ApolloServer({ typeDefs, resolvers });

const app = express();
server.applyMiddleware({ app });
const main = async () => {
const app = express();
await server.start();
server.applyMiddleware({ app });

app.listen({ port: 4000 }, () =>
console.log('Now browse to http://localhost:4000' + server.graphqlPath)
);
app.listen({ port: 4000 }, () =>
console.log("Now browse to http://localhost:4000" + server.graphqlPath)
);
};

main();
```

Apollo Server also supports all Node.js HTTP server frameworks: Express, Connect, HAPI, Koa and NestJs.