The “node” is the center of Gatsby’s data system. All data that’s added to Gatsby is modeled using nodes.
Node data structure
The basic node data structure is as follows:
A key reserved for plugins who wish to extend other nodes.
A digest “Hash”, or short digital summary, of the content of this node (for example,
The digest should be unique to the content of this node since it’s used for caching. If the content changes, this digest should also change. There’s a helper function called createContentDigest to create an
Optional media type to indicate to transformer plugins this node has data they can further process.
A globally unique node type chosen by the plugin owner.
The plugin which created this node. This field is added by gatsby itself (and not the plugin).
Stores which plugins created which fields. This field is added by gatsby itself (and not the plugin).
Optional field exposing the raw content for this node that transformer plugins can take and further process.
Text description of the node.
New nodes are added to Gatsby by “source” plugins. A common one that many Gatsby sites use is the Filesystem source plugin which turns files on disk into File nodes.
Other source plugins pull data from external APIs such as the Drupal and Hacker News
Transformer plugins can also create nodes by transforming source nodes into new types of nodes. It is very common when building Gatsby sites to install both source plugin(s) and transformer plugins.
Nodes created by transformer plugins are set as “children” of their “parent” nodes.
Remark (Markdown library) transformer plugin
looks for new nodes that are created with a
text/markdownand then transforms these nodes into
MarkdownRemarknodes with an
- The YAML transformer plugin looks for
new nodes with a media type of
Gatsby automatically infers the structure of your site’s nodes and creates a GraphQL schema which you can then query from your site’s components.
To learn more about how nodes are created and linked together, check out the Node Creation documentation in the “Behind the Scenes” section.