Closed epbarger closed 3 years ago
could you provide with what the queries
are here? this does seem like a bug, but I'm not too sure what the cause is. I guess possibly settings without value gets set to empty object instead of undefined?
Sure! Queries is pretty simple .
const queries = [
{
query: indexQuery,
transformer: ({ data }) =>
splitNodeContent(
addBreadcrumbsToNodes(data.allMdx.nodes).map(node =>
transformNodeForAlgolia(node),
),
),
indexName: 'index-name-here',
},
];
I'll mess with the configuration a bit more and see if I can find anything that causes the issue to manifest. So far I've tried adding settings: {}
to both the main and query config, to no effect
if you can debug around this line what value settings
has, it could be useful https://github.com/algolia/gatsby-plugin-algolia/blob/master/gatsby-node.js#L252
if you can debug around this line what value
settings
has, it could be useful https://github.com/algolia/gatsby-plugin-algolia/blob/master/gatsby-node.js#L252
Sure, settings is undefined
there, so it's not entering the conditional
I was able to edit gatsby-node
a bit and got something working. No idea if this is a safe solution to the problem or not though without tests or knowledge of other configurations.
settings: settings || {}
. This fixes the destructuring problem when settings
isn't present that I think the conditional was there to solve....(Object.keys(settings).length > 0 ? settings : existingSettings),
since settings will always at least be {}
Hope this is helpful! Probably cleaner ways to fix this, but it's a start.
Also, it looks like when you provide settings it completely replaces the existing settings? I'm not sure I would have expected that from the README. Maybe worth more explanation, or even a way to control whether the settings you provide are merged with the existing settings, or replace them. Something like a mergeSettings
option.
It overrides the settings, since if you first set a setting with Gatsby, change the code later to remove that setting, I think you would prefer only the new settings to apply. You're right that in hindsight requiring all settings to be set via Gatsby seems more problematic than removed settings still applying
Defaulting to empty settings would mean that we can't differentiate between no settings given and "remove all settings" (although that doesn't ever seem like a good idea).
Could you make a pull request with your suggested changes for making this work properly again with settings not given?
Also a pull request explaining settings more clearly with how you understood them would be very welcome!
Sure, I'll try to get a PR up in the next few days. Thanks for your help!
Running on
0.15.1
, withenablePartialUpdates: false
andchunkSize: 1000
. When the index process has finished, checking the Algolia UI shows that many settings have reset to default, including "Searchable attributes", "Attributes to snippet", and "Facets". Otherwise, the index updates successfully.I believe this was working fine in previous versions. It seems unexpected that these settings would be cleared?
The first version I experience this on is
0.14.1
(0.14.0
produced the error noted here)Plugin config