mirror of
https://github.com/strapi/strapi.git
synced 2025-09-08 16:16:21 +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
|
||||
|
||||
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 folders and files structure is the following:
|
||||
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 are the following:
|
||||
|
||||
<!-- ```
|
||||
/plugin
|
||||
|
@ -1,6 +1,6 @@
|
||||
'use strict';
|
||||
|
||||
const validateGroupInput = require('./validation/group');
|
||||
const _ = require('lodash');
|
||||
/**
|
||||
* Groups controller
|
||||
*/
|
||||
@ -82,6 +82,15 @@ module.exports = {
|
||||
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 {
|
||||
await validateGroupInput(body);
|
||||
} catch (error) {
|
||||
|
@ -176,6 +176,19 @@ module.exports = {
|
||||
|
||||
return async (obj, options, 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.
|
||||
const ctx = Object.assign(_.clone(context), {
|
||||
request: Object.assign(_.clone(context.request), {
|
||||
@ -203,18 +216,6 @@ module.exports = {
|
||||
if (_.isFunction(resolver)) {
|
||||
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) {
|
||||
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.
|
||||
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.
|
||||
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) {
|
||||
const values = await resolver.call(null, ctx, null);
|
||||
|
||||
|
@ -165,8 +165,9 @@ const buildAssocResolvers = (model, name, { plugin }) => {
|
||||
};
|
||||
|
||||
if (
|
||||
(association.nature === 'manyToMany' && association.dominant) ||
|
||||
association.nature === 'manyWay'
|
||||
((association.nature === 'manyToMany' && association.dominant) ||
|
||||
association.nature === 'manyWay') &&
|
||||
_.has(obj, association.alias) // if populated
|
||||
) {
|
||||
_.set(
|
||||
queryOpts,
|
||||
|
Loading…
x
Reference in New Issue
Block a user