Cleanup feedbacks

Signed-off-by: Alexandre Bodin <bodin.alex@gmail.com>
This commit is contained in:
Alexandre Bodin 2020-02-11 17:35:09 +01:00
parent 5723af75c5
commit 04f6050ae1
3 changed files with 17 additions and 21 deletions

View File

@ -7,8 +7,6 @@ module.exports = {
testQuery: {
policies: ['plugins::users-permissions.isAuthenticated'],
resolver: 'application::homepage.homepage.find',
// resolver: 'homepage.homepage.find'
// resolver: 'homepage.find'
},
},
},

View File

@ -4,11 +4,10 @@ module.exports = {
`,
resolver: {
Mutation: {
// updateUser: {
// description: 'Updates a user',
// policies: ['customPolicy'],
// resolver: 'plugins::users-permissions.user.update',
// },
updateUser: {
description: 'Updates a user',
policies: ['customPolicy'],
},
},
Query: {
userCustomRoute: {

View File

@ -34,12 +34,11 @@ const buildMutation = (mutationName, config) => {
const action = getAction(resolver);
return async (root, options = {}, graphqlContext) => {
const { context } = graphqlContext;
const ctx = buildMutationContext({ options, graphqlContext });
await policiesMiddleware(ctx);
const values = await action(context);
const values = await action(ctx);
const result = ctx.body || values;
if (_.isError(result)) {
@ -53,23 +52,23 @@ const buildMutation = (mutationName, config) => {
const buildMutationContext = ({ options, graphqlContext }) => {
const { context } = graphqlContext;
if (options.input && options.input.where) {
context.params = convertToParams(options.input.where || {});
} else {
context.params = {};
}
if (options.input && options.input.data) {
context.request.body = options.input.data || {};
} else {
context.request.body = options;
}
const ctx = context.app.createContext(
_.clone(context.req),
_.clone(context.res)
);
if (options.input && options.input.where) {
ctx.params = convertToParams(options.input.where || {});
} else {
ctx.params = {};
}
if (options.input && options.input.data) {
ctx.request.body = options.input.data || {};
} else {
ctx.request.body = options;
}
return ctx;
};