getClient#
A function that properly configures a graphql-request client to interact with the Storyblok GraphQL API.
This function expects the dependencies graphql-request and graphql to be installed.
Parameters#
getClient accepts a configuration object parameter, with the following options:
The Storyblok API token is required.
Usage#
Basic example#
Recommended: with GraphQL Code Generator#
In combination with GraphQL Code Generator you can generate a fully typed GraphQL SDK.
The client returned by getClient can be wrapped in getSdk:
For a full configuration, please see the example. The relevant configuration files are ./.graphqlrc.yaml, ./lib/graphqlClient.ts and ./graphql.
For more information on this configuration of GraphQL Code Generator and its options, check out the docs.