algolia / gatsby-plugin-algolia

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

[Feedback] `gatsby develop` doesn't trigger index upload #30

Closed mathieucaroff closed 4 years ago

mathieucaroff commented 5 years ago

Today I spent a bit of time reading the code before I realized that gatsby develop didn't trigger exports.onPostBuild, so no data from my queries were uploaded to Algolia. It might be good to advertise it a bit; something like:

gatsby-plugin-algolia uses the "onPostBuild" entry point which is not triggered when using gatsby develop. Make sure you use gatsby build to upload data to your indices.

For reference:

https://github.com/gatsbyjs/gatsby/issues/2698#issuecomment-488041539

This is a problem if you are using the gatsby-plugin-algolia search plugin. The cache is only (re)generated when gatsby build is run. In the case of Algolia, the exports.createPages entry point is a viable alternative to exports.onPostBuild if you want to edit your node_modules/gatsby-plugin-algolia/gatsby-node.js file.

Haroenv commented 5 years ago

That makes complete sense, your operations would go through the roof if you updated an index on develop; it might make sense if you’re on an unlimited plan and change to a specific index for dev mode.

Would you mind those trade offs?

mathieucaroff commented 5 years ago
const queries = [
  {
    query: repoQuery,
    transformer: repoTransformer,
    indexName,
    settings,
  },
]

Currently, a change brought to one of the queries - either the graphQl query, the settings or the transformer is never tested by gatsby develop. The code is run for the first time when the developer executes gatsby build.

As at the moment, I'm mostly making a proof of concept regarding the search feature, so I do not run gatsby build at all. This is why it took me a bit of time to understand what was going on.

Haroenv commented 5 years ago

I guess this mainly is something that should be mentioned more clearly in the documentation then.

dougwithseismic commented 4 years ago

I guess this mainly is something that should be mentioned more clearly in the documentation then. +1 I had no idea why it wasn't working until reading this post. Thanks for clarifying :)