Plugin query API: Handle multiple errors (#63553)

This commit is contained in:
Andres Martinez Gotor
2023-03-02 11:25:50 +01:00
committed by GitHub
parent b211ec0a1d
commit c84cfd2b3f
7 changed files with 46 additions and 9 deletions

View File

@ -356,6 +356,12 @@ describe('Query Response parser', () => {
"refId": "A",
}
`);
expect(res.errors).toEqual([
{
message: 'Hello Error',
refId: 'A',
},
]);
const norm = res.data.map((f) => toDataFrameDTO(f));
expect(norm).toMatchInlineSnapshot(`

View File

@ -87,8 +87,13 @@ export function toDataQueryResponse(
refId: dr.refId,
message: dr.error,
};
rsp.state = LoadingState.Error;
}
if (rsp.errors) {
rsp.errors.push({ refId: dr.refId, message: dr.error });
} else {
rsp.errors = [{ refId: dr.refId, message: dr.error }];
}
rsp.state = LoadingState.Error;
}
if (dr.frames?.length) {