Category: 14. Gatsby Internals

  • Node Creation

    The createNode API, one of the Gatsby Node APIs, is responsible for creating nodes, which can take the form of any object. Within Redux, which Gatsby leverages to manage state, nodes are stored under the nodes namespace. The nodes namespace carries state in the form of a map of Node identifiers to Node objects. Node creation happens first and foremost in the sourceNodes bootstrap stage, and all nodes…

  • The Gatsby Build Lifecycle

    The Gatsby build lifecycle consists of a series of steps, many of which will be recognizable from the overviews of some of these APIs in previous sections. After nodes are sourced and created, a schema is generated to facilitate GraphQL queries in Gatsby pages and components. Thereafter, the queries are executed to create the pages that…

  • Executing Plugins and Injecting Arguments

    Once the previous step is complete, the Gatsby bootstrap filters the flattenedPlugins namespace in Redux to yield only the plugins that implement the Gatsby API that needs to be executed. For each successive plugin it encounters, Gatsby will require its gatsby-node.js file and invoke its exported function that implements one of the Gatsby Node APIs. For instance, if the API…

  • The apiRunInstance Object

    Because some API calls in Gatsby can take longer to finish than others, every time an API is invoked, the Gatsby bootstrap creates an object called apiRunInstance to track the call. This object contains the fields listed in Table 14-2. Field Description id A unique identifier generated based on the type of API invoked api The API being invoked; e.g., onCreateNode args…

  • Loading Configured Plugins

    Among the very first steps performed in Gatsby’s bootstrap is loading all the plugins configured in gatsby-config.js, as well as internal Gatsby plugins that come with the core framework. Gatsby saves these loaded plugins to Redux using the flattened​Plu⁠gins namespace. In Redux, each plugin has the fields listed in Table 14-1. NOTE For more information about how Gatsby leverages Redux for data storage, consult…

  • APIs and Plugins in Gatsby

    When you invoke an API or plugin within Gatsby itself or in a plugin you’ve provided to the implementation, what does Gatsby do on the inside? In this section, we’ll take a brief tour through the major phases of API and plugin execution in Gatsby from the standpoint of gatsby-node.js. An understanding of what portions of…

  • Gatsby Internals

    Throughout this book, we’ve taken a tour through the compelling set of features available to developers building Gatsby sites. And in the previous section, we explored advanced topics in Gatsby for expert-level use cases that go well beyond its out-of-the-box capabilities. But what about those who are interested in contributing to Gatsby, extending it, or…