algolia / gatsby-plugin-algolia

A plugin to push to Algolia based on graphQl queries
https://yarn.pm/gatsby-plugin-algolia
Apache License 2.0
177 stars 45 forks source link

Reporter error when no matching fields found for partial update #113

Closed froddd closed 3 years ago

froddd commented 3 years ago

If a partial update finds an object that has none of the specified matchedFields properties, the reporter should output:

when enablePartialUpdates is true, the objects must have at least one of the match fields. Current object:
{
  // object
}
expected one of these fields:
modified

This currently fails with the following error:

       [Algolia] Starting Partial updates...
error failed to index to Algolia

         ReferenceError: curObj is not defined

         - gatsby-node.js:177 runIndexQueries
           [build_8e578be9_]/[gatsby-plugin-algolia]/gatsby-node.js:177:32

         - async Promise.all

         - gatsby-node.js:72 Object.exports.onPostBuild
           [build_8e578be9_]/[gatsby-plugin-algolia]/gatsby-node.js:72:5

         - api-runner-node.js:425 runAPI
           [build_8e578be9_]/[gatsby]/src/utils/api-runner-node.js:425:16

       not finished onPostBuild - 7.430s

The reporter message is trying to output the JSON for curObj, which does not exist: https://github.com/algolia/gatsby-plugin-algolia/blob/master/gatsby-node.js#L177

I'll push a PR to fix this shortly!

Haroenv commented 3 years ago

Thanks for finding this and suggesting a fix. I've released it as 0.16.2