mirror of
https://github.com/strapi/strapi.git
synced 2025-07-27 19:10:01 +00:00

* Add basic implementation for the graphql extension service * Add createPolicyContext in @strapi/utils * policiesMiddleware implementation for graphql * wrapResolvers first implementation (authentication, middlewares, policies) * move the content API schema build from /generators to /content-api. Extract types' register functions into a dedicated folder * fix schema generation on bootstrap * update the graphql service file to match new services arch * fix single type queries * simplify entity's resolver * use apollo graphql conventions for resolver's args naming * use the graphql extension system in i18n to add a locale arg to localized queries & mutations
26 lines
1011 B
JavaScript
26 lines
1011 B
JavaScript
'use strict';
|
|
|
|
const { omit } = require('lodash/fp');
|
|
|
|
module.exports = ({ strapi }) => ({
|
|
buildComponentResolver: ({ contentTypeUID, attributeName }) => {
|
|
const { transformArgs } = strapi.plugin('graphql').service('builders').utils;
|
|
|
|
return async (parent, args = {}) => {
|
|
const contentType = strapi.contentTypes[contentTypeUID];
|
|
const transformedArgs = transformArgs(args, { contentType, usePagination: true });
|
|
|
|
// Since we're using the entity-manager & not the entity-service to load the
|
|
// association, we need to apply some transformation to the transformed args object
|
|
const entityManagerArgs = {
|
|
...omit(['start', 'filters'], transformedArgs),
|
|
where: transformedArgs.filters,
|
|
offset: transformedArgs.start,
|
|
};
|
|
|
|
// todo[v4]: should we move the .load to the entity service so we can use the same args everywhere?
|
|
return strapi.db.entityManager.load(contentTypeUID, parent, attributeName, entityManagerArgs);
|
|
};
|
|
},
|
|
});
|