import { DraftToAssetsResolver } from 'definitions' ; const resolver = async ( { id , authorId } , _ , { viewer , dataSources : { systemService } } ) => { const isAdmin = viewer . hasRole ( 'admin' ) ; const isAuthor = authorId === viewer . id ; if ( ! isAdmin && ! isAuthor ) { return [ ] ; } const { id : draftEntityTypeId } = await systemService . baseFindEntityTypeId ( 'draft' ) ; const assets = await systemService . findAssetAndAssetMap ( { entityTypeId : draftEntityTypeId , entityId : id , } ) ; return assets . map ( ( asset ) => { return { ... asset , path : asset . path ? `${ systemService . aws . s3Endpoint }/${ asset . path }` : null , } ; } ) ; } ; export default resolver ;