How to create a post build script that uses GraphQL with GatsbyJS

Oscar de la Hera Gomez
A flower that represents GatsbyJS next to one that represents GraphQL. Beneath it sits the text "GraphQL Post Build Script."

A step by step tutorial on writing a custom Post Build script that uses GraphQL API calls with GatsbyJS.

Step One: Setup the project

GatsbyJS SEO

Create a GatsbyJS project that includes a gatsby-node.js script.

To download our Open Source Typescript & GatsbyJS starter project, please use the code or link below.

git clone git@github.com:delasign/gatsbyjs-typescript-starter.git

Step Two: Add the GraphQL Post Build Script

A screenshot of VSCode showing the Gatsby-node.js file selected and the script provided below at the bottom of the file.

In the gatsby-node.js file add the post build script at the bottom of the file, adding the GraphQL parameter to the function.

We have provided a sample below, please replace A_GRAPHQL_QUERY with your GraphQL query.

Any Questions?

We are actively looking for feedback on how to improve this resource. Please send us a note to inquiries@delasign.com with any thoughts or feedback you may have.

delasign logo

Book a Free Consultation.

An icon of an email.

Click here to email us.

Fill in the details below to book a free consultation or to let us know about something else. Whatever it is, we are here to help.

How can we help you ?

Contact Details