Not able to upload data to Algolio dashboard using gatsby-plugin-algolia

I was trying to integrate Alogolia Search with a Gatsby site using gatsby-plugin-algolia. Below is the code from gatsby-config to query markdown files content and push it to algolia for indexing .

require("dotenv").config({
  path: ".env",
})
const blogQuery = `query {
  allMarkdownRemark {
    nodes {
      frontmatter {
        title
      }
      excerpt
    }
  }
}
`
const queries = [
  {
    query: blogQuery,
    transformer: ({ data }) => data.allMarkdownRemark.nodes,
  },
]

module.exports = {
 
  plugins: [
    {
      resolve: "gatsby-plugin-algolia",
      options: {
        appId: process.env.ALGOLIA_APP_ID,
        apiKey: process.env.ALGOLIA_API_KEY,
        indexName: process.env.ALGOLIA_INDEX_NAME, // for all queries
        queries,
        cunkSize: 1000,
      },     
    ],
}

I have verified API keys in .env file also checked in graphQL playground that blogQuery returns results.
Here is the result of localhost:8000/__graphQL
enter image description here

When I run gatsby build I get below error :
enter image description here

I also tried to debug error in generated log, but could not figure out more :
enter image description here

Kindly let me know what I am missing as Algoia API keys are correct and graphQL query fetches records.
PS: Using Node 10.16.0
image

Hi there,
Thanks for reaching out to us.

transformer: ({ data }) => data.allMarkdownRemark.nodes,

According to your screenshot of graphql playground,
the transformer should be like the following:

transformer: ({ data }) => data.allMarkdownRemark.edges.map(edge => edge.node)

// or

transformer: ({ data }) => data.allMarkdownRemark.edges.map(edge => {
  const { node } = edge;
  return {
    title: node.frontmatter.title,
    excerpt: node.excerpt,
  }
})

Let me know how it goes :slight_smile:

Thanks for replying . Sorry I had pasted wrong query , I was just trying to check if it works with edges . Below is the GraphQL playground:

.

Also tried using previous query and transformer that uses edges , but still same error Algolia: query 0: executing query

Hi there,
Actually Algolia: query 0: executing query is not an error message.
I will update the message more clearly.
It just means the query #0 is being executed. You have an array of only one query.

Then the next step you can try is,

transformer: ({ data }) => console.log(data)

to see what the data looks like. Can you dump the data here and the your build log to see what went wrong?

Hey , thanks for replying .I got it resolved by modifying the query to include objectID

const blogQuery = `query {
  allMarkdownRemark {
    nodes {
      objectID: id
      frontmatter {
        title
      }
      excerpt
    }
  }
}`

However docs say if objectID missing Algolia will automatically insert but it was not working.