Hello,
I’ve found this tutorial very useful, and I thank you for that.
Unfortunately, I can’t adapt the code to be compatible with multi languages (i18n). Here is my code :
"use strict";
module.exports = {
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 response = toEntityResponse(data.results[0]);
console.log("##################", response, "##################");
return response;
},
},
},
},
}));
},
};
When I make a GraphQL request, I am getting an empty response.
Thank you very much for your help!