This commit is contained in:
Aurelsicoko 2018-05-24 17:20:32 +02:00
parent 0a9fff5a30
commit c111aaba13
10 changed files with 15 additions and 11 deletions

View File

@ -328,7 +328,7 @@ module.exports = {
return async (obj, options, context) => { return async (obj, options, context) => {
// Hack to be able to handle permissions for each query. // Hack to be able to handle permissions for each query.
const ctx = Object.assign(context, { const ctx = Object.assign(_.clone(context), {
request: Object.assign(_.clone(context.request), { request: Object.assign(_.clone(context.request), {
graphql: null graphql: null
}) })
@ -362,6 +362,7 @@ module.exports = {
return values && values.toJSON ? values.toJSON() : values; return values && values.toJSON ? values.toJSON() : values;
} }
return resolver.call(null, obj, options, context); return resolver.call(null, obj, options, context);
} }
@ -560,7 +561,7 @@ module.exports = {
switch (association.nature) { switch (association.nature) {
case 'manyToMany': { case 'manyToMany': {
const arrayOfIds = obj[association.alias].map(related => { const arrayOfIds = (obj[association.alias] || []).map(related => {
return related[ref.primaryKey] || related; return related[ref.primaryKey] || related;
}); });

View File

@ -39,9 +39,11 @@ module.exports = async (ctx, next) => {
}, []); }, []);
if (!permission) { if (!permission) {
ctx.forbidden(); if (ctx.request.graphql === null) {
return ctx.request.graphql = strapi.errors.forbidden();
}
return ctx.request.graphql = ctx.body; ctx.forbidden();
} }
// Execute the policies. // Execute the policies.

View File

@ -19,6 +19,7 @@ module.exports = strapi => {
this.delegator = delegate(strapi.app.context, 'response'); this.delegator = delegate(strapi.app.context, 'response');
this.createResponses(); this.createResponses();
strapi.errors = Boom;
strapi.app.use(async (ctx, next) => { strapi.app.use(async (ctx, next) => {
try { try {
// App logic. // App logic.