angeloashmore / gatsby-plugin-local-search

Gatsby plugin for providing client-side search for data available in Gatsby's GraphQL layer using a variety of engines
MIT License
51 stars 29 forks source link

How to pass context variables to gatsby plugin local search query? #33

Open miguelt1 opened 3 years ago

miguelt1 commented 3 years ago

In query I would like to have a dynamic variable to filter, that variable would be like a context variable, is that possible?

angeloashmore commented 3 years ago

Hi @miguelt1, could you share more about your setup? Since the query is called just once during Gatsby's bootstrapping phase, we aren't looping over content where variables normally would be used.

What kind of variables would you want to use?

For now, you can interpolate values into your query option since it is just a string. Any data available in your gatsby-node.js (which means anything you can do in Node.js, like reading a file or loading environment variables), can be added to your query via string interpolation.