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