feat(catalog): only fetch needed fields for entity presentation
To save bandwidth, only fetch the necessary fields for the entity presentation API for displaying the entity title. Signed-off-by: Heikki Hellgren <heikki.hellgren@op.fi>
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/plugin-catalog': patch
|
||||
---
|
||||
|
||||
Entity presentation api now only fetches fields that are required to display entity title
|
||||
@@ -161,6 +161,15 @@ describe('DefaultEntityPresentationApi', () => {
|
||||
expect(catalogApi.getEntitiesByRefs).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
entityRefs: ['component:default/test'],
|
||||
fields: [
|
||||
'kind',
|
||||
'metadata.name',
|
||||
'metadata.namespace',
|
||||
'metadata.title',
|
||||
'metadata.description',
|
||||
'spec.profile.displayName',
|
||||
'spec.type',
|
||||
],
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
@@ -26,15 +26,15 @@ import {
|
||||
EntityRefPresentation,
|
||||
EntityRefPresentationSnapshot,
|
||||
} from '@backstage/plugin-catalog-react';
|
||||
import { HumanDuration, durationToMilliseconds } from '@backstage/types';
|
||||
import { durationToMilliseconds, HumanDuration } from '@backstage/types';
|
||||
import DataLoader from 'dataloader';
|
||||
import ExpiryMap from 'expiry-map';
|
||||
import ObservableImpl from 'zen-observable';
|
||||
import {
|
||||
createDefaultRenderer,
|
||||
DEFAULT_BATCH_DELAY,
|
||||
DEFAULT_CACHE_TTL,
|
||||
DEFAULT_ICONS,
|
||||
createDefaultRenderer,
|
||||
} from './defaults';
|
||||
|
||||
/**
|
||||
@@ -371,6 +371,15 @@ export class DefaultEntityPresentationApi implements EntityPresentationApi {
|
||||
async (entityRefs: readonly string[]) => {
|
||||
const { items } = await options.catalogApi!.getEntitiesByRefs({
|
||||
entityRefs: entityRefs as string[],
|
||||
fields: [
|
||||
'kind',
|
||||
'metadata.name',
|
||||
'metadata.namespace',
|
||||
'metadata.title',
|
||||
'metadata.description',
|
||||
'spec.profile.displayName',
|
||||
'spec.type',
|
||||
],
|
||||
});
|
||||
|
||||
const now = Date.now();
|
||||
|
||||
Reference in New Issue
Block a user