|
| 1 | +--- |
| 2 | +id: comparison |
| 3 | +title: Comparison with other JavaScript GraphQL server libraries |
| 4 | +sidebar_label: Comparison |
| 5 | +--- |
| 6 | + |
| 7 | +## GraphQL Yoga and Apollo Server |
| 8 | + |
| 9 | +This comparison highlights the main differences when using Yoga instead of Apollo Server. |
| 10 | + |
| 11 | +### No Framework-specific Packages |
| 12 | + |
| 13 | +One of the goals of `graphql-yoga` is to have as few `graphql-yoga` packages as possible. |
| 14 | +Yoga is designed around the W3C Request/Response specification (often just referred to as ["Fetch API"](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API)), |
| 15 | +which is already adopted by deno, cloudflare workers, and browsers. |
| 16 | + |
| 17 | +For Node.js environments and frameworks (which unfortunately do not have full W3C Request/Response support), graphql-yoga comes with a small compatibility layer for making it work. |
| 18 | + |
| 19 | +You only need to search for [`apollo-server-` on NPM](https://www.npmjs.com/search?q=apollo-server-) to see how many variants and packages there are for apollo and how hard it is to maintain. |
| 20 | + |
| 21 | +### Run anywhere |
| 22 | + |
| 23 | +As mentioned in the above paragraph `graphql-yoga` is built around W3C Request/Response which is supported in all major serverless/worker/"serverful" JavaScript environments. |
| 24 | +Apollo Server plans to drop active support for cloudflare workers and [pushes it onto the community](https://github.com/apollographql/apollo-server/issues/6034). |
| 25 | +GraphQL Yoga will continuously support all platforms and runtimes and |
| 26 | +Furthermore, Yoga has a full end to end testing suite that actually deploys to all those runtimes in order to ensure integrity and prevent unexpected issues. |
| 27 | + |
| 28 | +### Powerful Plugin System |
| 29 | + |
| 30 | +Envelop’s powerful GraphQL plugin system, that is unfortunately not fully compatible with Apollo Server. |
| 31 | +There is still no further follow-up from the apollo maintainers over [on the Apollo Server and envelop discussion](https://github.com/apollographql/apollo-server/discussions/5541). |
| 32 | + |
| 33 | +GraphQL Yoga builds upon envelop and, futhrermore, has a default plugin preset enabled for ensuring best practices for a performant (parse and validation caching) and secure GraphQL (e.g. though error masking) server by default. |
| 34 | +If you want to opt-out of some or all of these plugins that is also possible. |
| 35 | + |
| 36 | +Yoga is fully customizable for your needs! |
| 37 | + |
| 38 | +You can find a list of all available Envelop plugins over on [the envelop plugin hub](https://www.envelop.dev/plugins). |
| 39 | + |
| 40 | +### Full Support of the GraphQL over HTTP specification |
| 41 | + |
| 42 | +GraphQL Yoga is fully compatible with the GraphQL over HTTP specification (including the incremental delivaery over HTTP specification). |
| 43 | + |
| 44 | +### File Uploads |
| 45 | + |
| 46 | +GraphQL Yoga supports [file uploads out of the box](/v3/docs/features/file-uploads#enable-file-uploads-in-graphql-yoga). |
| 47 | + |
| 48 | +### GraphQL Subscriptions over Server-Sent-Events (SSE) |
| 49 | + |
| 50 | +GraphQL Yoga supports [GraphQL Subscriptions over Server-Sent-Events (SSE)](/v3/docs/features/subscriptions#subscriptions) out of the box without the need of any additional libraries. |
| 51 | + |
| 52 | +### Bundle Size and lean Dependencies |
| 53 | + |
| 54 | +For serverless/edge (service worker) environments, the size of the server code can be crucial for cold-start time and performance. |
| 55 | + |
| 56 | +Here you can see a comparison of bundle sizes: |
| 57 | + |
| 58 | +- [https://bundlephobia.com/package/[email protected]](Bundlephobia graphql-yoga) |
| 59 | +- [https://bundlephobia.com/package/[email protected]](Bundlephobia apollo-server-micro) |
| 60 | + |
| 61 | +GraphQL Yoga only has a fraction of the dependencies of Apollo Server, and in general is much smaller. |
| 62 | + |
| 63 | +- [Dependency visualizer `graphql-yoga`](https://npm.anvaka.com/#/view/2d/graphql-yoga) |
| 64 | +- [Dependency visualizer `apollo-server-micro`](https://npm.anvaka.com/#/view/2d/apollo-server-micro) |
| 65 | + |
| 66 | +GraphQL Yogas APIs are designed for code-splitting and supported by popular bundlers. |
| 67 | + |
| 68 | +## GraphQL Yoga and GraphQL Helix |
| 69 | + |
| 70 | +We are maintainers of both libraries today. |
| 71 | + |
| 72 | +The Guild initially adopted, improved, and recommended `graphql-helix`. |
| 73 | + |
| 74 | +While working on it, we realized that it to some extent allowed building more extensible GraphQL server set-ups, but on the other hand, required boilerplate code and isn't easily adoptable by new GraphQL developers. |
| 75 | +We also tried adding support for other environments such as cloudflare workers, but adding it as an after-thought wasn't that straightforward. |
| 76 | +Eventually, after a lot of trying we figured that the approach of adding it as an after-thought is the actual limitation, and instead of the other way around (W3C Request/Response first, Node.js HTTP Response/Request as a light-weight layer on top) might be a better solution. |
| 77 | + |
| 78 | +This put us in a difficult position. |
| 79 | +The Guild does not own `graphql-helix` and we did not want to do drastic changes to it, without verifying that it actually works. |
| 80 | +At the same time we were already building `graphql-yoga` based on helix. So we decided to actually do this experiment within graphql-yoga and remove helix as a dependency from yoga. |
| 81 | + |
| 82 | +Today we can happily say that it worked out fine! |
| 83 | + |
| 84 | +Today we recommend `graphql-yoga` over `graphql-helix`, if you want a batteries-included solution for GraphQL server development. |
| 85 | + |
| 86 | +GraphQL Yoga is easier to get started, has nicer defaults, and requires less boilerplate while giving you the same extensibility as `graphql-helix`! |
0 commit comments