I was wondering if any middleware is necessary to run an Apollo 2.0 server. I see that you can run it without, but when I try to customize the url and port, I get an error: Error: listen EACCES ${URL}:${PORT} My code: https://github.com/lucasnorman/apollo-test. Thanks!
When using typescript, I get a type error that doesn't allow me to pass in
the serverUrl. If I change the import to a require statement, which
disables the type checking, then it works. Any way around this?
On Wed, Aug 8, 2018 at 7:15 AM, Stephen Richardson <[email protected]
wrote:
Pass the path/port in the new ApolloServer constructor object, with
schema. Then call listen() without any arguments. The pattern you are using
is mixing the express style applyMiddleware, which is still valid but is
setup differently..—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/apollographql/apollo-server/issues/1411#issuecomment-411401116,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AZF4XZHoUyKQH6BkrQ8RjPjJHwrnZcjKks5uOuR9gaJpZM4VdID8
.
@lucasnorman have you tried the following:
server.listen({ port: PORT }).then({ url })...
or
server.listen(PORT).then()
The only problem is that, I can't change the graphQLPath. It defaults to root.
I tried:
server.setGraphQLPath('/graphql')
server.graphQLPath = '/graphql
Nothing worked.
@josephharveyangeles Ya so through some trial an error I have found that without a middleware like express, you cannot change the default graphQLPath.
@lucasnorman do you happen to know if that's by design? I can indeed change it via apollo-server-express but I moved to apollo-server thinking that I won't be adding express stuff anymore on my graph server. But now I can't change the path.
So was it like, if I'm going to use it as a dedicated graphql server, why bother changing the path? But what is the purpose of setGraphQLPath() method?
I am not entirely sure because I haven't really looked into it. All I know is that without a middleware such as express, your api endpoint ends up being the default '/'. Maybe someone else can shine some light on why that is?
See this comment https://github.com/apollographql/apollo-server/issues/1617#issuecomment-419753087 for a longer explanation on why the path is irrelevant without middleware.
You should be able to use a port you would like without middleware. Use server.listen({ port: 3000 }) etc.
Great, thanks!
Most helpful comment
@lucasnorman have you tried the following:
server.listen({ port: PORT }).then({ url })...or
server.listen(PORT).then()The only problem is that, I can't change the graphQLPath. It defaults to root.
I tried:
server.setGraphQLPath('/graphql')server.graphQLPath = '/graphqlNothing worked.