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(indexing): allow plugin to work with repeated single index in queries by batching #103

Closed prichey closed 3 years ago

prichey commented 3 years ago

I'm submitting this because I reworked a decent amount of the plugin to be compatible with multiple queries to the same index. It seems to work well for my use case but the diff is fairly gnarly so I'm not sure if you'd like to pull this in or not. I'm happy to rework anything if you are interested in merging, but if not I can just maintain my fork and use the patched version for my needs. Let me know what you think, thanks!

Haroenv commented 3 years ago

I'll have a look at this soon, there's indeed a lot changed that needs individual attention (since there's no tests yet on this repo)

Haroenv commented 3 years ago

I'm not sure if I got these changes right, but I think you got rid of the top-level enablePartialUpdates, is that on purpose?

prichey commented 3 years ago

@Haroenv I realize it kind of looks like that but I actually just pass the whole config object (which is the settings passed to the plugin) from onPostBuild (here) to runIndexQueries (here) which is where enablePartialUpdates is actually destructured and utilized.

I'm running my fork on a project and I'm successfully merging 8 queries to the same index, all with partial updates:

[Algolia] 8 queries to index
[Algolia] Running 8 queries for index MC_DEV...
[Algolia] Queries resulted in a total of 2213 results
[Algolia] Starting Partial updates...
[Algolia] No updates necessary; skipping!
[Algolia] Done!

Let me know if you have any other questions / concerns, thanks!

Haroenv commented 3 years ago

Ah yes that makes sense, in my mind it was a separate enablePartialUpdates from the queries array, but you're right!

prichey commented 3 years ago

@Haroenv thanks for the review, I'll address comments then let you know once I'm all pushed up

prichey commented 3 years ago

@Haroenv I addressed your comments, let me know what you think. Thanks!