Apollo Query Batching and graphql-ruby


Query batching is a way to speed up your application. Instead of waiting on multiple client-server roundtrips to load data, everything is loaded at once.

Enabling query batching in Apollo is as easy as using another network provider:

On the Ruby you need to make a few more changes, but all can be done in your GraphQL Controller. You need to map the array of given queries to a format that graphql-ruby understands. The gist below handles both batched and non-batched queries.

Batching queries can reduce the time your app is loading by a large amount, making for a more pleasant user experience.

More from the blog

- Resize images from s3 with AWS Lambda and Rust

My site contains a lot of images and resizing them for different devices (mobile phone, tabled, desktop etc.) takes a lot of time and (upload) bandwidth. This is especially annoying on Hotel Wi-Fi in a far-away country. With the help of AWS Lambda and Rust I made this into a smooth process.

- Taming our MongoDB database size.

Not so long ago we noticed that our MongoDB servers were running out of disk space at an alarming rate. Because we host our database on SSD enabled servers at DigitalOcean, scaling up could cost us a lot of money.