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

Adding merge settings option #153

Closed c4ndybar closed 2 years ago

c4ndybar commented 2 years ago

Adding mergeSettings

The mergeSettings option will merge whatever settings you have with the existing index settings. The settings defined for the query will take precedence.

Why?

This allows you to make index changes using the Algolia web interface and to preserve those changes. Currently, any changes you make through the Algolia web interface are overwritten anytime this plugin runs.

Haroenv commented 2 years ago

This makes sense, but it means that if you remove a setting from the Gatsby settings, it will not be removed (which is why I didn't do this yet before), do you think that's not an issue?

c4ndybar commented 2 years ago

This makes sense, but it means that if you remove a setting from the Gatsby settings, it will not be removed (which is why I didn't do this yet before), do you think that's not an issue?

Good point, I didn't even think of that. I think it's definitely an issue 😅

So the edge case is.

  1. User enables mergeSettings
  2. Build with some settings
  3. Later removes a field from the settings completely (but setting persists since it exists on the index)

I'm not sure how frequently this series of events would happen, but it's certainly something that could be called out in documentation for mergeSettings.

Something like.

When using mergeSettings, you shouldn't remove any settings as the settings will already exist on the index and be persisted. Instead, you should change the value of the setting here. Another option is to remove the setting here and then manage the setting from Algolia's web interface.

Haroenv commented 2 years ago

Seems like the best workaround indeed, feel free to add it to the readme like this @c4ndybar

Haroenv commented 2 years ago

released in 0.24.0, thanks again