import { ForbiddenError } from 'common/errors' ; import { ArticleAccessToSecretResolver } from 'definitions' ; export const secret = async ( { articleId , authorId } , _ , { viewer , dataSources : { articleService } } ) => { if ( ! authorId || ! viewer . id ) { return ; } if ( authorId !== viewer . id ) { throw new ForbiddenError ( 'viewer has no permission' ) ; } const articleCircle = await articleService . findArticleCircle ( articleId ) ; if ( ! articleCircle ) { return ; } return articleCircle . secret ; } ;