Chapter 5. Source Plugins and Sourcing Data

Among the most important features of Gatsby is its ability to retrieve and handle data from a variety of disparate sources, such as WordPress, Shopify, other GraphQL APIs external to Gatsby, and the local filesystem. Through its plugin ecosystem, Gatsby makes available a wide spectrum of backend services from which to pull data into a Gatsby site.

In Gatsby’s data layer, source plugins are responsible for retrieving data either internally from a local filesystem or externally from APIs, databases, third-party services, and especially content management and commerce systems. Regardless of what they’re responsible for, source plugins can be combined arbitrarily as part of Gatsby’s data layer, which contains data originating from many different sources. In this chapter, we’ll explore source plugins and how to use them to derive a range of data from the systems you want to pull from.

Using Source Plugins

Source plugins are similar to the other Gatsby plugins you’ll see in Chapter 9. Unlike plugins that govern CSS or features like analytics, however, source plugins serve as the intermediary between a data source, such as a local filesystem or an external service, and the Gatsby site presenting that data. They are Gatsby’s canonical data retrieval system for data beyond that provided within the pages directory.

When you run the gatsby develop or gatsby build command, your source plugins will issue queries against the data source to retrieve ...

Get Gatsby: The Definitive Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.