How to understand languageProvider

Hi,

I am developing a grafana datasource plugin, I have seen the prometheus/loki datasource source code, and I found they use languageProvider, I can’t understand it by its name, and the official document doesn’t describe it very clearly. So my question is how to understand the languageProvider, what functions it provides?

Thank you!

I’ve recently spent some time digging into this myself. If you want to look at an, arguably, simpler example that Prometheus/Loki, you can check out what I did.

Assuming you’re using the QueryField component from @grafana/ui, really the only thing the language provider does is to provide completion items to the onTypeahead callback. While there’s a LanguageProvider interface in the Grafana packages, I haven’t yet actually found any reason for its existence :sweat_smile:

You can call it something else if you’d like, you don’t have to extend the interface.

QueryField

"Language provider"

I’ve tried to keep the language provider relatively self-contained and documented. I don’t fully understand it myself yet, but I’ll add docs for it when I learn more.

I tried to refactor it a bit more. I think it’s simpler now to be honest.

wow, big thanks @marcusolsson , let me have a look!

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.