Updated January 13, 2021
Which apollo-server to use? Comparing apollo-server, apollo-server-express, apollo-server-*
I've spent a lot of time primarily working on the frontend of mobile apps and in that time I've absolutely loved when I could work with a GraphQL API.
So, when I decided to start building a full stack open source trivia app for React Native School, I decided that I would be using a GraphQL API via Apollo Server.
But when I started looking at it and my desired hosting options I got confused...
What's the difference between apollo-server, apollo-server-express, apollo-server-lamda, apollo-server-*?
The docs cover it but I didn't find an answer immediately when I searched for the answer so, hopefully, I saved you some time.
Note to self: Read the docs, at the very least the README, first.
TLDR
Basically, apollo-server
is a standalone app and apollo-server-*
is an integration.
Expanded
The apollo-server
package provides everything you need to create a web server & a GraphQL API. Two packages, a dozen lines, and you've got a GraphQL API.
The apollo-server-
packages allow you to integrate with an existing web framework (like Express, Lambda/Serverless, Koa, etc.).
You set up your server via the normal means for that framework and then you setup a GraphQL endpoint via apollo-server
within that framework.
Which to Use?
If you only need your server to serve a GraphQL API I'd say apollo-server
is the way to go.
If you...
- Already have a web backend setup
- Know you'll need more than a GraphQL API
- Know where you're hosting it (say a GraphQL endpoint in a Next.js app)
Then you'll want to use the integration package for that framework/service.
Conclusion
From what I can tell they're all the same under the hood (they depend on apollo-server-core) and function the same way - they're just customized to work on the specific platform.
It also seems easy enough to move around if you need to change something - just move your type defs and resolvers over to the new way you setup your Apollo Server.