graphql-helix
node-graphql-benchmarks
Our great sponsors
graphql-helix | node-graphql-benchmarks | |
---|---|---|
17 | 5 | |
831 | 551 | |
-0.5% | - | |
0.0 | 4.3 | |
7 days ago | 5 months ago | |
TypeScript | JavaScript | |
MIT License | MIT License |
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.
graphql-helix
-
Apollo Layoffs
Depends on language, I've build GraphQL servers in a few, though mostly JavaScript and Python. For Python I used to use Graphene, these days I use Strawberry.
For JavaScript, I originally used graphql-js and express-graphql, as these were the original libraries and I was a literal day 1 adopter. All the libraries are essentially just wrappers around graphql-js, so it's still viable to use directly. But for schema-building I now use Pothos (https://pothos-graphql.dev/), I'd probably use graphql-helix as the http layer (https://github.com/contra/graphql-helix).
-
Does Apollo GraphQL cost money to use in production? And other beginner questions about GraphQL
If you want a lower level graphql server https://graphql-helix.vercel.app/ or https://benzene.vercel.app/ might be worth checking out.
-
Code-first schema definition
While there are many GraphQL server packages available, we need one that will play nicely with Nuxt3's server engine (Nitro / h3). In the spirit of keeping things extensible and framework-agnostic, GraphQL Helix seems like a really good choice. Let's add it to our project:
-
What's next?
E.g. recently I found Graphql-helix, replaced apollo-server-micro with it and had never looked back ever since (incl. subscriptions), what else could be done better? Also in terms of DX
Looks interesting, have you tried graphql-helix?
-
a first look at graphQL helix
GraphQL Helix is a framework and runtime agnostic collection of utility functions for building your own GraphQL HTTP server. Instead of providing a complete HTTP server or middleware plugin function, GraphQL Helix only provides a handful of functions for turning an HTTP request into a GraphQL execution result. You decide how to send back the response.
-
Introducing Envelop - The GraphQL Plugin System
import { envelop, useSchema, useLogger } from '@envelop/core'; import fastify from 'fastify'; import { processRequest, getGraphQLParameters } from 'graphql-helix'; // This creates the `getEnveloped` function for us. Behind the scense the wrapped functions are created once, here. const getEnveloped = envelop({ plugins: [useSchema(schema), useLogger()], }); const app = fastify(); app.route({ method: ['POST'], url: '/graphql', async handler(req, res) { // Here we can pass the request and make available as part of the "context". // The return value is the a GraphQL-proxy that exposes all the functions. const { parse, validate, contextFactory, execute, schema } = getEnveloped({ req, }); const request = { body: req.body, headers: req.headers, method: req.method, query: req.query, }; const { operationName, query, variables } = getGraphQLParameters(request); // Here, we pass our custom functions to Helix, and it will take care of the rest. const result = await processRequest({ operationName, query, variables, request, schema, parse, validate, execute, contextFactory, }); if (result.type === 'RESPONSE') { res.status(result.status); res.send(result.payload); } else { // You can find a complete example with Subscriptions and stream/defer here: // https://github.com/contrawork/graphql-helix/blob/master/examples/fastify/server.ts res.send({ errors: [{ message: 'Not Supported in this demo' }] }); } }, }); app.listen(3000, () => { console.log(`GraphQL server is running...`); });
-
Subscriptions and Live Queries - Real Time with GraphQL
Fortunately, we now have libraries like Graphql Helix, which, in my humble opinion, should replace express-graphql as the reference HTTP implementation since GraphQL Helix is also not tied to any web server framework.
-
GraphQL - Diving Deep
If you are using Node.js there are a lot of implementations of GraphQL servers with a few being express-graphql, apollo-server, mercurius, graphql-helix and more. And if you are using other languages, you can see a great list here
-
The Stack #1
Graphql Helix
node-graphql-benchmarks
-
Should I use Apollo Server?
I'm not here to convince you it's your best option! Apollo Server is a full-featured server (with a plugin system, request lifecycle, etc.) and that does come at a performance cost. We don't run benchmarks against the other libraries (though there are some out there - as far as Node libraries go we aren't talking orders of magnitude in rps). I'd suggest if performance is your biggest concern, Node might not your best option.
-
GraphQL JIT – GraphQL execution using a JIT compiler
I remember seeing graphql-jit on a comparative benchmark of GQL server implementations, and it blowing everything out of the water, really impressive:
https://github.com/benawad/node-graphql-benchmarks
Depending on your usecase, you can go one level further and directly evaluate the query AST without delegating to resolvers.
(This generally only makes sense if you do programmatic schema generation. IE, read some metadata about a source and then generate GQL types/operations from it.)
So a query comes in, say something like:
query {
-
GraphQL - Diving Deep
And infact, if you are keen on understanding how every graphql-server performs, I would recommend checking out this
-
The Stack #1
And since there are no outside dependencies except for graphql-js there is also no bloat to the same unlike other graphql servers. If you want to see how other GraphQL servers perform, you might want to have a look at this.
What are some alternatives?
graphql-yoga - 🧘 Rewrite of a fully-featured GraphQL Server with focus on easy setup, performance & great developer experience. The core of Yoga implements WHATWG Fetch API and can run/deploy on any JS environment.
apollo-server - 🌍 Spec-compliant and production ready JavaScript GraphQL server that lets you develop in a schema-first way. Built for Express, Connect, Hapi, Koa, and more.
mercurius - Implement GraphQL servers and gateways with Fastify
nestjs-graphql - GraphQL (TypeScript) module for Nest framework (node.js) 🍷
graphql-jit - GraphQL execution using a JIT compiler
express-graphql - Create a GraphQL HTTP server with Express.
graphql-ws - Coherent, zero-dependency, lazy, simple, GraphQL over WebSocket Protocol compliant server and client.
envelop - Envelop is a lightweight library allowing developers to easily develop, share, collaborate and extend their GraphQL execution layer. Envelop is the missing GraphQL plugin system.
pothos - Pothos GraphQL is library for creating GraphQL schemas in typescript using a strongly typed code first approach
Postwoman - 👽 Open source API development ecosystem - https://hoppscotch.io
graphql-upload - Middleware and an Upload scalar to add support for GraphQL multipart requests (file uploads via queries and mutations) to various Node.js GraphQL servers.
prisma1 - 💾 Database Tools incl. ORM, Migrations and Admin UI (Postgres, MySQL & MongoDB) [deprecated]