Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

179
Views
How can I add an Algolia index to Gatsby GraphQL?

I would like to obtain all (or a subset) of my records from an Algolia index and access them via GraphQL. I know there is a Gatsby plugin that allows you to do the opposite i.e., add data from a GraphQL query to Algolia, but not the other way around. I have been able to get the tutorial for adding GraphQL data to work, but I have not had any success when trying to go beyond hardcoded arrays (this is in the gatsby-node.js file):

const algoliasearch = require("algoliasearch/lite");

const searchClient = algoliasearch(
    process.env.GATSBY_ALGOLIA_APP_ID,
    process.env.GATSBY_ALGOLIA_SEARCH_KEY
)

const searchIndex = searchClient.initIndex(process.env.GATSBY_ALGOLIA_INDEX_NAME)

exports.sourceNodes = ({ actions, createNodeId, createContentDigest }) => {    
    searchIndex.search("", {
        attributesToRetrieve: ["name", "url"]
    }).then(({ hits }) => {
        hits.forEach(hit => {
            const node = {
                name: hit.name,
                url: hit.url,
                id: createNodeId(`hit-${hit.name}`),
                internal: {
                    type: "hit",
                    contentDigest: createContentDigest(hit),
                },
            }
            actions.createNode(hit)
        })
    });
}

While the console successfully logs the array of nodes, and the verbose Gatsby deploy output includes the "hit" node as a node type, they do not appear in the GraphQL explorer.

Any help is greatly appreciated, thank you!

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!