mirror of
https://github.com/strapi/strapi.git
synced 2025-10-18 19:43:22 +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.
|
// 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.
|
// Upload new files and attach them to this entity.
|
||||||
await strapi.plugins.upload.services.upload.uploadToEntity({
|
await strapi.plugins.upload.services.upload.uploadToEntity({
|
||||||
id: entry.id || entry._id,
|
id: entry.id || entry._id,
|
||||||
|
@ -387,16 +387,29 @@ module.exports = {
|
|||||||
[model.primaryKey]: 'String'
|
[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.
|
// Add timestamps attributes.
|
||||||
if (_.get(model, 'options.timestamps') === true) {
|
if (_.get(model, 'options.timestamps') === true) {
|
||||||
Object.assign(initialState, {
|
Object.assign(initialState, {
|
||||||
created_at: 'String',
|
created_at: 'String',
|
||||||
updated_at: 'String'
|
updated_at: 'String'
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
const globalId = model.globalId;
|
Object.assign(acc.resolver[globalId], {
|
||||||
const _schema = _.cloneDeep(_.get(strapi.plugins, `graphql.config._schema.graphql`, {}));
|
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.
|
// Retrieve user customisation.
|
||||||
const { type = {}, resolver = {} } = _schema;
|
const { type = {}, resolver = {} } = _schema;
|
||||||
@ -471,10 +484,6 @@ module.exports = {
|
|||||||
|
|
||||||
// Build associations queries.
|
// Build associations queries.
|
||||||
(model.associations || []).forEach(association => {
|
(model.associations || []).forEach(association => {
|
||||||
if (!acc.resolver[globalId]) {
|
|
||||||
acc.resolver[globalId] = {};
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (association.nature) {
|
switch (association.nature) {
|
||||||
case 'manyMorphToOne':
|
case 'manyMorphToOne':
|
||||||
case 'manyMorphToMany':
|
case 'manyMorphToMany':
|
||||||
|
Loading…
x
Reference in New Issue
Block a user