mirror of
https://github.com/strapi/strapi.git
synced 2025-09-07 15:49:24 +00:00
23 lines
743 B
JavaScript
23 lines
743 B
JavaScript
'use strict';
|
|
|
|
const { omit } = require('lodash/fp');
|
|
const { transformArgs } = require('../builders/utils');
|
|
|
|
const buildComponentResolver = ({ contentTypeUID, attributeName, strapi }) => {
|
|
return async (source, args = {}) => {
|
|
const contentType = strapi.getModel(contentTypeUID);
|
|
const transformedArgs = transformArgs(args, { contentType, usePagination: true });
|
|
|
|
// todo[v4]: move the .load to the entity service?
|
|
const hotFixedArgs = {
|
|
...omit(['start', 'filters'], transformedArgs),
|
|
where: transformedArgs.filters,
|
|
offset: transformedArgs.start,
|
|
};
|
|
|
|
return strapi.db.entityManager.load(contentTypeUID, source, attributeName, hotFixedArgs);
|
|
};
|
|
};
|
|
|
|
module.exports = { buildComponentResolver };
|