mirror of
https://github.com/strapi/strapi.git
synced 2025-09-08 08:08:18 +00:00
Merge branch 'master' of github.com:strapi/strapi into develop
This commit is contained in:
commit
931551813d
@ -1,7 +1,7 @@
|
|||||||
# Plugin Folders and Files Architecture
|
# Plugin Folders and Files Architecture
|
||||||
|
|
||||||
The logic of a plugin is located at its root directory `./plugins/**`. The admin panel related parts of each plugin is contained in the `/admin` folder.
|
The logic of a plugin is located at its root directory `./plugins/**`. The admin panel related parts of each plugin are contained in the `/admin` folder.
|
||||||
The folders and files structure is the following:
|
The folders and files structure are the following:
|
||||||
|
|
||||||
<!-- ```
|
<!-- ```
|
||||||
/plugin
|
/plugin
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const validateGroupInput = require('./validation/group');
|
const validateGroupInput = require('./validation/group');
|
||||||
|
const _ = require('lodash');
|
||||||
/**
|
/**
|
||||||
* Groups controller
|
* Groups controller
|
||||||
*/
|
*/
|
||||||
@ -82,6 +82,15 @@ module.exports = {
|
|||||||
return ctx.send({ error: 'group.notFound' }, 404);
|
return ctx.send({ error: 'group.notFound' }, 404);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// convert zero length string on default attributes to undefined
|
||||||
|
if (_.has(body, 'attributes')) {
|
||||||
|
Object.keys(body.attributes).forEach(attribute => {
|
||||||
|
if (body.attributes[attribute].default === '') {
|
||||||
|
body.attributes[attribute].default = undefined;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await validateGroupInput(body);
|
await validateGroupInput(body);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
@ -176,6 +176,19 @@ module.exports = {
|
|||||||
|
|
||||||
return async (obj, options, graphqlCtx) => {
|
return async (obj, options, graphqlCtx) => {
|
||||||
const { context } = graphqlCtx;
|
const { context } = graphqlCtx;
|
||||||
|
|
||||||
|
if (options.input && options.input.where) {
|
||||||
|
context.params = Query.convertToParams(options.input.where || {});
|
||||||
|
} else {
|
||||||
|
context.params = {};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (options.input && options.input.data) {
|
||||||
|
context.request.body = options.input.data || {};
|
||||||
|
} else {
|
||||||
|
context.request.body = options;
|
||||||
|
}
|
||||||
|
|
||||||
// Hack to be able to handle permissions for each query.
|
// Hack to be able to handle permissions for each query.
|
||||||
const ctx = Object.assign(_.clone(context), {
|
const ctx = Object.assign(_.clone(context), {
|
||||||
request: Object.assign(_.clone(context.request), {
|
request: Object.assign(_.clone(context.request), {
|
||||||
@ -203,18 +216,6 @@ module.exports = {
|
|||||||
if (_.isFunction(resolver)) {
|
if (_.isFunction(resolver)) {
|
||||||
const normalizedName = _.toLower(name);
|
const normalizedName = _.toLower(name);
|
||||||
|
|
||||||
if (options.input && options.input.where) {
|
|
||||||
context.params = Query.convertToParams(options.input.where || {});
|
|
||||||
} else {
|
|
||||||
context.params = {};
|
|
||||||
}
|
|
||||||
|
|
||||||
if (options.input && options.input.data) {
|
|
||||||
context.request.body = options.input.data || {};
|
|
||||||
} else {
|
|
||||||
context.request.body = options;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isController) {
|
if (isController) {
|
||||||
const values = await resolver.call(null, context);
|
const values = await resolver.call(null, context);
|
||||||
|
|
||||||
|
@ -257,6 +257,17 @@ module.exports = {
|
|||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Note: we've to used the Object.defineProperties to reset the prototype. It seems that the cloning the context
|
||||||
|
// cause a lost of the Object prototype.
|
||||||
|
const opts = this.amountLimiting(_options);
|
||||||
|
|
||||||
|
ctx.query = {
|
||||||
|
...this.convertToParams(_.omit(opts, 'where')),
|
||||||
|
...this.convertToQuery(opts.where),
|
||||||
|
};
|
||||||
|
|
||||||
|
ctx.params = this.convertToParams(opts);
|
||||||
|
|
||||||
// Execute policies stack.
|
// Execute policies stack.
|
||||||
const policy = await compose(policiesFn)(ctx);
|
const policy = await compose(policiesFn)(ctx);
|
||||||
|
|
||||||
@ -275,17 +286,6 @@ module.exports = {
|
|||||||
|
|
||||||
// Resolver can be a function. Be also a native resolver or a controller's action.
|
// Resolver can be a function. Be also a native resolver or a controller's action.
|
||||||
if (_.isFunction(resolver)) {
|
if (_.isFunction(resolver)) {
|
||||||
// Note: we've to used the Object.defineProperties to reset the prototype. It seems that the cloning the context
|
|
||||||
// cause a lost of the Object prototype.
|
|
||||||
const opts = this.amountLimiting(_options);
|
|
||||||
|
|
||||||
ctx.query = {
|
|
||||||
...this.convertToParams(_.omit(opts, 'where')),
|
|
||||||
...this.convertToQuery(opts.where),
|
|
||||||
};
|
|
||||||
|
|
||||||
ctx.params = this.convertToParams(opts);
|
|
||||||
|
|
||||||
if (isController) {
|
if (isController) {
|
||||||
const values = await resolver.call(null, ctx, null);
|
const values = await resolver.call(null, ctx, null);
|
||||||
|
|
||||||
|
@ -165,8 +165,9 @@ const buildAssocResolvers = (model, name, { plugin }) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (
|
if (
|
||||||
(association.nature === 'manyToMany' && association.dominant) ||
|
((association.nature === 'manyToMany' && association.dominant) ||
|
||||||
association.nature === 'manyWay'
|
association.nature === 'manyWay') &&
|
||||||
|
_.has(obj, association.alias) // if populated
|
||||||
) {
|
) {
|
||||||
_.set(
|
_.set(
|
||||||
queryOpts,
|
queryOpts,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user