19 lines
650 B
JavaScript
Raw Normal View History

'use strict';
module.exports = ({ strapi }) => ({
buildComponentResolver({ contentTypeUID, attributeName }) {
const { transformArgs } = strapi.plugin('graphql').service('builders').utils;
return async (parent, args = {}) => {
const contentType = strapi.getModel(contentTypeUID);
2021-11-15 18:12:06 +01:00
const { component: componentName } = contentType.attributes[attributeName];
const component = strapi.getModel(componentName);
const transformedArgs = transformArgs(args, { contentType: component, usePagination: true });
return strapi.entityService.load(contentTypeUID, parent, attributeName, transformedArgs);
};
},
});