-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Docs: Apollo Server example throws error #1078
Comments
|
Hey it is pretty simple to solve this issue. Here is what I did const express = require("express");
const { ApolloServer, gql } = require("apollo-server-express");
const typeDefs = gql`
type Query {
hello: String
}
`;
const resolvers = {
Query: {
hello: () => "Hello world!",
},
};
const server = new ApolloServer({ typeDefs, resolvers });
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)
);
};
main(); Basically create a main function and make it an async function and await |
Thank you but I know how to solve it. I am just pointing that there is an error in the docs |
I will open pr and fix this issue. |
As discussed in #1082 this was fixed, but the new instructions are not entirely accurate now that Apollo Server 4 has shipped. We'll get this updated - thanks! |
@hwillson is this still the case? |
Description
When trying run Apollo Server code example from https://graphql.org/code/ I got an error:
Steps to Reproduce
npm install apollo-server-express express
run node server.js
with this code inserver.js
:Expected Result
code runs with no errors
Actual Result
code runs with error
The text was updated successfully, but these errors were encountered: