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

feat: add continueOnError flag #111

Closed akheron closed 3 years ago

akheron commented 3 years ago

This will let the build continue even if Algolia indexing fails.

akheron commented 3 years ago

Not sure if console.error() is the best way to print the exception.

I didn't replace other report.panic() calls because they mostly seem to be problems that the developer can avoid during development. The error I actually want to ignore is when Algolia rejects an indexing operation because of too big a payload.

Haroenv commented 3 years ago

what kind of error do you get that requires this to happen?

akheron commented 3 years ago

The error I actually want to ignore is when Algolia rejects an indexing operation because of too big a payload.

That means one of the documents I want to index are too big, and this should be fixed in the data. Stale data in algolia is fine meanwhile.

Haroenv commented 3 years ago

This is an interesting situation, since I think you should split the records up in smaller fragments, then using distinct to show only one hit per "document". This can be done within transformItems, and should be a thing you only need to set up once.

I'm kinda hesitant to add this option, since I can't find reference of any other plugins that allow this shortcutting, but also none of them really seem to have these kind of errors.

Maybe this lives better as a patch for you (using patch-package) or putting the code in your own code base?

sebpettersson commented 3 years ago

Is there a typo in this?

I get an "report is not defined" error on report.warn('failed to index to Algolia'). Glancing at the code, it looks like this should be reporter.warn()?

Haroenv commented 3 years ago

fixed in 0.20.1, thanks for noticing @sebpettersson