import { Args, Info, Parent, ResolveField, Resolver, Subscription, } from '@nestjs/graphql'; import { GraphQLResolveInfo } from 'graphql'; import { PipelineTasksService } from '../pipeline-tasks/pipeline-tasks.service'; import { LogFields, LogList } from '../repos/dtos/log-list.model'; import { PipelinesService } from './pipelines.service'; @Resolver(() => LogFields) export class CommitLogsResolver { constructor( private readonly service: PipelinesService, private readonly taskServices: PipelineTasksService, ) {} @Subscription(() => LogList, { resolve: (value) => { return value; }, }) async listLogsForPipeline( @Args('id', { type: () => String }) id: string, @Info() info: GraphQLResolveInfo, ) { info.returnType.toString(); const job = await this.service.listLogsForPipeline(id); return (async function* () { yield await job.finished(); })(); } @ResolveField() async tasks(@Parent() commit: LogFields) { return await this.taskServices.listTasksByCommitHash(commit.hash); } }