Merge pull request #16831 from backstage/freben/client-nulls

catalog-client: getEntitiesByRefs should return undefined
This commit is contained in:
Fredrik Adelöw
2023-03-13 16:10:00 +01:00
committed by GitHub
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) };
}
/**