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

Disable indexing on build? #67

Closed Blackglade closed 4 years ago

Blackglade commented 4 years ago

Hi,

I want to be able to disabling indexing of data on dev builds in my local environment. Is there anyway to block this? In the past I just set the following environment variables to garbage values:

ALGOLIA_ADMIN_KEY
GATSBY_ALGOLIA_APP_ID
GATSBY_ALGOLIA_SEARCH_KEY

but lately that doesn't work as the dev build errors out in my CI/CD pipeline with this:


Algolia: 1 queries to index
--
53 | Algolia: query 0: executing query
54 | Algolia: query 0: splitting in 1 jobs
55 | error failed to index to Algolia
56 |  
57 |  
58 | AlgoliaSearchError: Invalid Application-ID or API key
59 |  
60 | - AlgoliaSearchCore.js:377 success
61 | [website]/[algoliasearch]/src/AlgoliaSearchCore.js:377:32
62 |  
63 | - task_queues.js:97 processTicksAndRejections
64 | internal/process/task_queues.js:97:5
65 |  

Anyway to get around this?

Haroenv commented 4 years ago

You can based on that condition not add the plugin in Gatsby config. Does that work for you?

Blackglade commented 4 years ago

yeah that's what I'm currently doing. Was ideally hoping for a param passed into settings that could disable indexing on build.

Haroenv commented 4 years ago

Indexing on build is the only thing this plugin does, I'd rather not reinvent the wheel. Do you know of other Gatsby plugin which are conditional based on configuration, and not just on addition? Thanks

caelinsutch commented 4 years ago

Is there any interest in writing a PR for this? Maybe set an env variable to disable automatic indexing? Another option is using an env variable in your gatsby config

Haroenv commented 4 years ago

I'd like to see some other plugins doing something similar. If you don't want to index, nothing of the index should be done IMO

Blackglade commented 4 years ago

I did look around and was unable to find any other plugin that does nothing by addition of a config value. It seems like the accepted practice is to just remove it from export. You can close this issue out unless there's interest from anyone else to explore it further.