Files
grafana-zabbix/.changeset
Jocelyn Collado-Kuri 3d0895c008 Fix the way we merge frontend and backend queries (#2158)
## Summary

With the new logic to merge backend and frontend query responses, some
of the frontend query responses were being lost due to early
termination.

Merging frontend and backend responses was not properly waiting for all
promises to resolve before returning this "merged" result

## Detailed explanation

In `mergeQueries` although `Promise.all` was triggered, we returned
immediately without waiting for the promises to actually resolve, now
instead of passing down promises:
- use `switchMap` so that the upstream backend response observable can
be used as an inner Observable value to be concatenated with the rest of
the responses
- Why not use `map`? To prevent out of sync results, we need to wait for
the promises to resolve **before** we pass it down to the `mergeQueries`
function, `map` does not allow that.
- use `from` and trigger `Promise.all` **before** calling `mergeQueries`
so that all promise results can be resolved and converted to observables
by the time they get passed into the function
- modify `mergeQueries` to accept `DataResponse` for arguments, clone
the existing data and return the merged result.

<img width="1700" height="398" alt="Screenshot 2025-12-29 at 1 06 05 PM"
src="https://github.com/user-attachments/assets/c07c59b1-43b8-47f9-adc6-67583b125856"
/>

## Why

To fix how frontend and backend queries are merged so that no response
gets lost in the process

## How to test
1. Create a new dashboard or go to Explore
2. For query type select `Problems` or anything that is not `Metrics` 
3. Execute the query, and you should be able to see a response.
2025-12-31 06:46:56 -08:00
..

Changesets

Hello and welcome! This folder has been automatically generated by @changesets/cli, a build tool that works with multi-package repos, or single-package repos to help you version and publish your code. You can find the full documentation for it in our repository

We have a quick list of common questions to get you started engaging with this project in our documentation