mirror of
https://github.com/strapi/strapi.git
synced 2025-07-28 03:20:17 +00:00
19 lines
654 B
JavaScript
19 lines
654 B
JavaScript
'use strict';
|
|
|
|
module.exports = ({ strapi }) => ({
|
|
buildComponentResolver({ contentTypeUID, attributeName }) {
|
|
const { transformArgs } = strapi.plugin('graphql').service('builders').utils;
|
|
|
|
return async (parent, args = {}) => {
|
|
const contentType = strapi.contentTypes[contentTypeUID];
|
|
|
|
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);
|
|
};
|
|
},
|
|
});
|