mirror of
https://github.com/strapi/strapi.git
synced 2025-08-08 08:46:42 +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
35 lines
991 B
JavaScript
35 lines
991 B
JavaScript
'use strict';
|
|
|
|
const { pick } = require('lodash/fp');
|
|
|
|
const pickCreateArgs = pick(['params', 'data', 'files']);
|
|
|
|
module.exports = ({ strapi }) => ({
|
|
buildMutationsResolvers: ({ contentType }) => {
|
|
// todo[v4]: handle single type here?
|
|
const { uid } = contentType;
|
|
|
|
return {
|
|
async create(parent, args) {
|
|
// todo[v4]: Might be interesting to generate dynamic yup schema to validate payloads with more complex checks (on top of graphql validation)
|
|
const params = pickCreateArgs(args);
|
|
|
|
// todo[v4]: Sanitize args to only keep params / data / files (or do it in the base resolver)
|
|
return strapi.entityService.create(uid, params);
|
|
},
|
|
|
|
async update(parent, args) {
|
|
const { id, data } = args;
|
|
|
|
return strapi.entityService.update(uid, id, { data });
|
|
},
|
|
|
|
async delete(parent, args) {
|
|
const { id, ...rest } = args;
|
|
|
|
return strapi.entityService.delete(uid, id, rest);
|
|
},
|
|
};
|
|
},
|
|
});
|