Skip to main content

Using Third-party GraphQL APIs

Gatsby v2 introduces a simple way to integrate any GraphQL API into Gatsby’s GraphQL. You can integrate both third-party APIs, like GitHub’s, APIs of services like GraphCMS or your custom GraphQL API.

Basic example

First install the plugin.

Provided there is a GraphQL API under a url, adding it to an API just requires adding this to the config.

See all configuration options in the plugin docs

Third-party APIs will be available under the fieldName specified, so you can query through it normally.

Note that types of the third-party API will be prefixed with ${typeName}_. You need to prefix it too, e.g. when using variables or fragments.

Creating pages dynamically through third-party APIs

You can also create pages dynamically by adding a createPages callback in gatsby-node.js. For example you can create a page for every Star Wars species.

Further reading


Edit this page on GitHub
Docs
Tutorials
Plugins
Blog
Showcase