GraphQL-python-archive / graphql-django-view

[DEPRECATED | Use graphene-django package] A django view that will execute a GraphQLSchema using a given Executor.
http://graphene-python.org/
MIT License
23 stars 7 forks source link

Batched Requests #12

Closed nickhudkins closed 3 years ago

nickhudkins commented 8 years ago

Assuming you have these two queries:

First Route makes this query:

{
  viewer {
      items(first: 10) {
        edges {
          node {
           id
           title
          }
        }
      }
  }
}

Second Route makes this query:

{
  viewer {
      items(first: 10) {
        edges {
          node {
           id
           title
           description
          }
        }
      }
  }
}

with the default relay network layer, you will end up with 10 (n) node requests like so:

node(id: *id) {
  description
}

This is bad. So, the wonderful @nodkz wrote a great network layer, that when paired with some express-js middleware, handles batching.

That's wonderful if we (the collective python graphql users) were using express-js, but alas we are not so we need to implement a solution for such.

The JS implementation can be found here:

https://github.com/nodkz/react-relay-network-layer/blob/master/src/express-middleware/graphqlBatchHTTPWrapper.js

I plan to take a first pass at this tomorrow, but figured I would share with the public in case this has been on anyone else's mind.

nickhudkins commented 8 years ago

I took a first pass, it is terrible. it works, it has no error handling. I'll keep working on it as time permits. Feel free to follow progress here: https://github.com/nickhudkins/graphql-django-view