How to extend service?

System Information
  • Strapi Version: 4.20.5
  • Operating System: macos
  • Database: postgres
  • Node Version: 18.17.1
  • NPM Version: 9.6.7
  • Yarn Version: not used

Hi, I am trying to extend service, I have read those articles:

I have a collection type named ‘persona’ and after trials and errors I came up with this code:

const { createCoreService } = require('@strapi/strapi').factories;


let xxx = ({ strapi }) => {
    return ({

        async find(...args) {
            // Calling the default core controller
            const {results, pagination} = await super.find(...args);

            return {results, pagination};

        async findOne(entityId, params) {
            // some logic here
            const result = await super.findOne(entityId, params);
            // some more logic

            return result;

export default createCoreService('api::persona.persona', xxx);

This code is placed in src/api/persona/services/persona.ts where the default code generated by Strapi was placed. In logs I can see XXX phrase during strapi startup, but no YYY, ZZZ nor AAA when clicking in a browser on the persona list or on the single persona. Therefore I assume that the file is processed but neither find nor findOne is overriden.

My question is: what is wrong in my code that it does not override the service properly?

I have finally found an answer. With methods described in the links above one can only override “client api”. Admin panel uses completely different set of api which cannot be extended this way and the documentation is not explicit about that: Controller update method is not called from the admin panel · Issue #18214 · strapi/strapi · GitHub

So my question now changes to: How to override “strapi admin api”? I have a relation between two entities and on the edit screen I want to filter out certain values (in other words there is some business constraint telling which entities can be linked together and I do not want to display entries which are not allowed).