mirror of
https://github.com/strapi/strapi.git
synced 2025-10-15 18:16:24 +00:00
Merge pull request #956 from strapi/fix/upload
Fix uploaded file on create
This commit is contained in:
commit
52f3da7266
@ -59,7 +59,7 @@ module.exports = {
|
||||
});
|
||||
|
||||
// Then, request plugin upload.
|
||||
if (strapi.plugins.upload && !_.isEmpty(values.files)) {
|
||||
if (strapi.plugins.upload && Object.keys(files).length > 0) {
|
||||
// Upload new files and attach them to this entity.
|
||||
await strapi.plugins.upload.services.upload.uploadToEntity({
|
||||
id: entry.id || entry._id,
|
||||
|
@ -387,16 +387,29 @@ module.exports = {
|
||||
[model.primaryKey]: 'String'
|
||||
};
|
||||
|
||||
const globalId = model.globalId;
|
||||
const _schema = _.cloneDeep(_.get(strapi.plugins, `graphql.config._schema.graphql`, {}));
|
||||
|
||||
if (!acc.resolver[globalId]) {
|
||||
acc.resolver[globalId] = {};
|
||||
}
|
||||
|
||||
// Add timestamps attributes.
|
||||
if (_.get(model, 'options.timestamps') === true) {
|
||||
Object.assign(initialState, {
|
||||
created_at: 'String',
|
||||
updated_at: 'String'
|
||||
});
|
||||
}
|
||||
|
||||
const globalId = model.globalId;
|
||||
const _schema = _.cloneDeep(_.get(strapi.plugins, `graphql.config._schema.graphql`, {}));
|
||||
Object.assign(acc.resolver[globalId], {
|
||||
created_at: (obj, options, context) => {
|
||||
return obj.createdAt || obj.created_at;
|
||||
},
|
||||
updated_at: (obj, options, context) => {
|
||||
return obj.updatedAt || obj.updated_at;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Retrieve user customisation.
|
||||
const { type = {}, resolver = {} } = _schema;
|
||||
@ -471,10 +484,6 @@ module.exports = {
|
||||
|
||||
// Build associations queries.
|
||||
(model.associations || []).forEach(association => {
|
||||
if (!acc.resolver[globalId]) {
|
||||
acc.resolver[globalId] = {};
|
||||
}
|
||||
|
||||
switch (association.nature) {
|
||||
case 'manyMorphToOne':
|
||||
case 'manyMorphToMany':
|
||||
|
Loading…
x
Reference in New Issue
Block a user