I recently stumbled upon react-relay-network-layer which provides a middleware for query batching. It does all sorts of bad things to fake an HTTP request to this middleware.
I needed to port the same middleware to Koa, and thus I find myself doing the same bad things to achieve the same thing against koa-graphql, the port of this package to Koa.
So there are at least 4 different packages whose job is:
- Get an HTTP GraphQL request
- Resolve it given some options
- Return an HTTP response.
The second point is literally the same for everyone, but we can't use a common solution because request/response interfaces are different from framework to framework (or even from use case to use case, as for query batching).
Thus I propose to create a package (say http-graphql) to provide this functionality through a common, framework-agnostic core to resolve an HTTP GraphQL request.
Then express-graphql package could simply wrap http-graphql with express-specific logic, and the same can do koa-graphql, koa-graphql-batch and anyone who needs to process and HTTP GraphQL request.
It's just a matter of surgically remove express-specific idioms from this package and replace it with the most slim and simple common interface we can come up with (maybe repurpose Node.js own interfaces?).
From a user standpoint, this would be a simple minor version bump to a GraphQL package, but with improved customization, stability and reliability.
Issue #113 could be addressed while creating the new http-graphql package, by exporting both a silver-bullet function resolveHttpGraphQLRequest(req: HttpRequest) : HttpResponse) and more granular functions like parser, validate, execute, ...
(I'd be happy to do this! I studied the codebase and I think I could manage the work. Obviously the new repo would be under the graphql organization.)