Product Updates

DatoCMS changelog for new features and general improvements
Content Delivery API

Query batching

June 12th, 2018

We just enabled query batching support to our GraphQL Content Delivery API.

This means you can combine multiple GraphQL operations into a single HTTP request, reducing HTTP overheads. If you use Apollo Client, you can enable batch queries with the apollo-link-batch-http package:

1
import { ApolloClient } from 'apollo-client';
2
import { setContext } from 'apollo-link-context';
3
import { InMemoryCache } from 'apollo-cache-inmemory';
4
import { BatchHttpLink } from 'apollo-link-batch-http';
5
6
const httpLink = new BatchHttpLink({
7
uri: 'https://graphql.datocms.com/',
8
});
9
10
const authLink = setContext((_, { headers }) => {
11
return {
12
headers: {
13
...headers,
14
'Authorization': `Bearer ${process.env.DATO_API_TOKEN}`,
15
}
16
}
17
});
18
19
const client = new ApolloClient({
20
link: authLink.concat(httpLink),
21
cache: new InMemoryCache(),
22
});
23
24
export default client;
Start using DatoCMS today
According to Gartner 89% of companies plan to compete primarily on the basis of customer experience this year. Don't get caught unprepared.
  • No credit card
  • Easy setup
Subscribe to our newsletter! 📥
One update per month. All the latest news and sneak peeks directly in your inbox.
support@datocms.com ©2024 Dato srl, all rights reserved P.IVA 06969620480