catalog-client: getEntitiesByRefs should return undefined

Signed-off-by: Fredrik Adelöw <freben@gmail.com>
This commit is contained in:
Fredrik Adelöw
2023-03-13 13:36:06 +01:00
parent 87628d47c7
commit c630360631
3 changed files with 10 additions and 3 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/catalog-client': patch
---
Ensure that `getEntitiesByRefs` returns `undefined` instead of `null` for missing items
@@ -249,7 +249,7 @@ describe('CatalogClient', () => {
{ token },
);
expect(response).toEqual({ items: [entity, null] });
expect(response).toEqual({ items: [entity, undefined] });
});
});
+4 -2
View File
@@ -199,9 +199,11 @@ export class CatalogClient implements CatalogApi {
throw await ResponseError.fromResponse(response);
}
const { items } = await response.json();
const { items } = (await response.json()) as {
items: Array<Entity | null>;
};
return { items };
return { items: items.map(i => i ?? undefined) };
}
/**