#Accessing my catalog entities from scaffolder

3 messages · Page 1 of 1 (latest)

round ether
#

I am creating a global function in my scaffolder so that the template can pass a value to this function and I will search up a related entity from the catalog and return it.
This is how I am creating my global function in scaffolder.ts

  const additionalTemplateGlobals: Record<string, TemplateGlobal> = {
    getEntityFromRef: ref => getEntityFromRef(ref as string, env.database),
  };

Looking at the source, it seems like I can get the client by doing something like const client = await env.database.getClient() and then I can do normal Knex stuff on this client object. Is this correct? Is this the best way or is there a better way to do it? Is there a helper function that I can call instead of needing to create a knex client?

dusky thunder
#

No, every plugin has its entirely own separate database, and besides, the databases are strictly considered private concerns that can change in any way at any time without prior notice.

#

To call the catalog, use a CatalogClient instance from the @backstage/catalog-client package.