diff --git a/.changeset/tiny-suns-trade.md b/.changeset/tiny-suns-trade.md new file mode 100644 index 0000000000..365e91ad69 --- /dev/null +++ b/.changeset/tiny-suns-trade.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-catalog-backend': patch +--- + +Fixed default refresh service to go through the whole ancestry of the entity. diff --git a/plugins/catalog-backend/src/service/DefaultRefreshService.ts b/plugins/catalog-backend/src/service/DefaultRefreshService.ts index 99b78f900b..45a8f27c6e 100644 --- a/plugins/catalog-backend/src/service/DefaultRefreshService.ts +++ b/plugins/catalog-backend/src/service/DefaultRefreshService.ts @@ -29,20 +29,17 @@ export class DefaultRefreshService implements RefreshService { const { entityRefs } = await this.database.listAncestors(tx, { entityRef: options.entityRef, }); - const locationAncestor = entityRefs.find(ref => + + const locationAncestors = entityRefs.filter(ref => ref.startsWith('location:'), ); // TODO: Refreshes are currently scheduled(as soon as possible) for execution and will therefore happen in the future. // There's room for improvements here where the refresh could potentially hang or return an ID so that the user can check progress. - if (locationAncestor) { - await this.database.refresh(tx, { - entityRef: locationAncestor, - }); + for (const locationAncestor of locationAncestors) { + await this.database.refresh(tx, { entityRef: locationAncestor }); } - await this.database.refresh(tx, { - entityRef: options.entityRef, - }); + await this.database.refresh(tx, { entityRef: options.entityRef }); }); } }