Sorry for Super Late response, recently saw this question. If you haven’t figure out the answer yet or for future folks here is what I came up with.
The Problem
When using enititi.service it was only returning data for the the selected default locale. And not all available options. You can see the video for explanation. https://youtu.be/JpzqVIv767Y
To fix this I ended up using strapi.db.query. I beleave that the service has some logic that check default locale and only returns those items. Since db.query is more lower level and you directly querying the data you don’t have that issue.
Here is the refactored code.
"use strict";
const boostrap = require("./bootstrap");
module.exports = {
async bootstrap() {
await boostrap();
},
register({ strapi }) {
const extensionService = strapi.service("plugin::graphql.extension");
extensionService.use(({ strapi }) => ({
typeDefs: `
type Query {
article(slug: String!, locale: I18NLocaleCode): ArticleEntityResponse
}
`,
resolvers: {
Query: {
article: {
resolve: async (parent, args, context) => {
const { toEntityResponse } = strapi.service(
"plugin::graphql.format"
).returnTypes;
// const data = await strapi.services["api::article.article"].find({
// filters: { slug: args.slug, locale: args.locale },
// });
const data = await strapi.db.query("api::article.article").findMany({
where: { locale: args.locale, slug: args.slug }
});
// console.log("##################", data.results, "##################");
const response = toEntityResponse(data[0]);
// const response = toEntityResponse(data.results[0]);
console.log("##################", response, "##################");
return response;
},
},
},
},
}));
},
};
I would recommend on diving deeper into the