mirror of
https://github.com/vale981/Vulcan
synced 2025-03-06 01:51:40 -05:00
Add cloudinaryUrl custom field
This commit is contained in:
parent
b34a7a2fcb
commit
203935d0cf
1 changed files with 20 additions and 1 deletions
|
@ -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;
|
||||
}
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
]);
|
||||
|
||||
}
|
Loading…
Add table
Reference in a new issue