Express-graphql: GraphQL and HTTP2

Created on 20 Oct 2018  路  5Comments  路  Source: graphql/express-graphql

This is a new feature requirement:
Could we use GraphQL via HTTP2 ?

question

Most helpful comment

Any updates on this?

All 5 comments

Any updates on this?

Think this is a very valid discussion to have... does GraphQL makes sense with HTTP2?

Graphql as a query language looks really good because in 1 fetch, you can get deep associations. The only issue now is that the longest query to resolve will be the time to resolve the initial fetch. With http2 we could have several server pushes for populating the result little by little.

@Fr33maan https://github.com/dunglas/vulcain seems to be doing the same but I think it would need client-side changes as well.
Using HTTP/2 as the transport without changes to graphql should already show some improvements in performance.

express-graphql is just middleware for Express, so there's no reason you can't use it with HTTP2. You can use spdy to create an HTTP2/SPDY server that'll work with your Express instance:

const spdy = require('spdy')
const app = require('express')()

// apply your middleware here

spdy
  .createServer({ key, cert }, app)
  .listen(port)
Was this page helpful?
0 / 5 - 0 ratings