Skip to main content

GraphQL speed improvements

Changes in: gapi Permalink

Storyblok's GraphQL api just got huge performance improvements and the possibility to use automatic persisted queries which will save you a lot of traffic.


Usage example in Next.js of persisted queries:

To use automatic persisted queries you need to add the library apollo-link-persited-queries like done in the Next.js example

import { ApolloClient } from 'apollo-client'
import { InMemoryCache } from 'apollo-cache-inmemory'
import withApollo from 'next-with-apollo'
import { createHttpLink } from 'apollo-link-http'
import { createPersistedQueryLink } from 'apollo-link-persisted-queries'
import fetch from 'isomorphic-unfetch'

const GRAPHQL_URL = ''

const link = createPersistedQueryLink({useGETForHashedQueries: true}).concat(createHttpLink({
  fetch, // Switches between unfetch & node-fetch for client & server.
  headers: {
    'Token': 'YOUR_TOKEN',
    'Version': 'published',
    'Accept': 'application/json'

export default withApollo(
  ({ initialState }) =>
    new ApolloClient({
      link: link,
      cache: new InMemoryCache()
        //  rehydrate the cache using the initial data passed from the server:
        .restore(initialState || {})