Filter by locale in entity service API

System Information
  • Strapi Version: 4.1.7
  • Operating System: MacOsx
  • Database: PostGre
  • Node Version: v14.17.1
  • NPM Version: 8.5.5
  • Yarn Version: 1.22.17

Hello !

I’m making a custom graphQl query.
I have create a controller to get my contentType and make some logic on it.
Everything work.

I use strapi.entityService.findMany with a filter (slug coming from the param).
I want to find the french version of my contentType but i don’t manage.
I receive only the contentType with default language data.

Ps: The two contentType have the same slug

Here is my code

 const menus = await strapi.entityService.findMany("api::menu.menu", {
          filters: {
            slug: {
              $eq: param.slug,
            },
          },
          populate: [  ...  ],
        });

I’v tried :

 const menus = await strapi.entityService.findMany("api::menu.menu", {
          filters: {
            locale:"fr",   // or //  _locale:"fr
            slug: {
              $eq: param.slug,
            },
          },
          populate: [],
        });

But it’s not the good solution : (

Thanks a lot !

1 Like

I think locale has to be defined outside the filter. Cna you try this-

 const menus = await strapi.entityService.findMany("api::menu.menu", {
          filters: {
            slug: {
              $eq: param.slug,
            },
          },
          locale:"fr",
          populate: [],
        });
3 Likes

THANKS YOU !!!

Thanks, I put the locale inside of filters and by this reason don’t works.