Add cloudinaryUrl custom field

This commit is contained in:
SachaG 2017-09-29 16:28:46 +09:00
parent b34a7a2fcb
commit 203935d0cf

View file

@ -28,7 +28,26 @@ export const addCustomFields = collection => {
blackbox: true,
optional: true
}
}
},
// GraphQL only
{
fieldName: 'cloudinaryUrl',
fieldSchema: {
type: String,
optional: true,
viewableBy: ['guests'],
resolveAs: {
type: 'String',
arguments: 'format: String',
resolver: (document, {format}, context) => {
const image = format ? _.findWhere(document.cloudinaryUrls, {name: format}) : document.cloudinaryUrls[0]
return image && image.url;
}
},
}
},
]);
}