Source plugins#

Now that we learned how to create pages and access dynamic data with GraphQL, we can start fetching some data from external sources.

Source plugins are the tools that can handle this job.

Every plugin is specialized in getting data from a different source.


There are a lot of plugins for almost every need. You can find a complete list of plugins on GatsbyJS official website.

Let us start with a basic one, gatsby-source-filesystem: a plugin that transforms files into GraphQL nodes.

npm install --save gatsby-source-filesystem

After that, we need to enable the plugin in our project. To do this, we need to add it into gatsby-config.js file.

module.exports = {
    siteMetadata: {
        title: 'Gatsby Default Starter',
    plugins: [
            resolve: `gatsby-source-filesystem`,
            options: {
                name: `src`,
                path: `${__dirname}/src`,

Now restart the development server.

If we open GraphiQL page, we will see new possible queries.


Create a new page called "files-list.js" that displays a list of all files with some informations (path, size, extension) found with some query.

import React from "react"
import { graphql } from "gatsby"
import Header from '../components/header';

import Layout from '../components/layout'

export default ({ data }) => {
  return (
      <h1>Here is a list of files</h1>
          {{ node }, index) => (
            <tr key={index}>

export const query = graphql`
  query {
    allFile {
      edges {
        node {
          birthTime(fromNow: true)