Error: entityManager.findOneWithCreatorRoles is not a function

I ran into the exact same issue as you, and it looks like that function has been removed at some point. For my particular use-case I ended up replacing the controller entirely. With the collection names from your example, it would look like this:

plugin.controllers.relations.findAvailable = async (ctx) => {
    const adminUserId = ctx.state.user.id;
    const localeCode = ctx.query.locale || 'en';
    const requestType = ctx.request.url.split("/")[3].split(".")[1];

    let query;

    if (requestType === 'category') {
      query = await strapi.db.query('api::menu.menu').findMany({
        where: {
          locale: localeCode,
          createdBy: adminUserId,
        },
        populate: ['createdBy'],
      });
    } else if (requestType === 'menu') {
      query = await strapi.db.query('api::category.category').findMany({
        where: {
          locale: localeCode,
          createdBy: adminUserId,
        },
        populate: ['createdBy'],
      });
    } else {
      return ctx.badRequest(`Unknown request type: "${requestType}". Add new types at src/extensions/content-manager/strapi-server.js`);
    }

    const result = {"results": query};

    return result;
  };

This will simply return a list of collection items that the user making the request created, where the returned collection depends on which collection the request came from, although splitting the request URL like this is not an ideal solution. The collection names are also hard-coded. Making this work for any pair of collections would require more work.

It’s also not using TypeScript, but I hope it’s a good start, if you’re still stuck on this. I’m not an expert, but feel free to ask if anything about this is unclear.

1 Like