2021-03-12 23:00:12 +08:00
|
|
|
import { Resolver, Args, Mutation, Subscription } from '@nestjs/graphql';
|
|
|
|
import { PipelineTask } from './pipeline-task.entity';
|
|
|
|
import { PipelineTasksService } from './pipeline-tasks.service';
|
|
|
|
import { CreatePipelineTaskInput } from './dtos/create-pipeline-task.input';
|
|
|
|
import { PipelineTaskLogMessage } from './models/pipeline-task-log-message.module';
|
|
|
|
import { PipelineTaskLogArgs } from './dtos/pipeline-task-log.args';
|
2021-03-15 13:30:52 +08:00
|
|
|
import { PipelineTaskLogsService } from './pipeline-task-logs.service';
|
2021-03-01 18:14:13 +08:00
|
|
|
|
|
|
|
@Resolver()
|
2021-03-12 23:00:12 +08:00
|
|
|
export class PipelineTasksResolver {
|
2021-03-15 13:30:52 +08:00
|
|
|
constructor(
|
|
|
|
private readonly service: PipelineTasksService,
|
|
|
|
private readonly logsService: PipelineTaskLogsService,
|
|
|
|
) {}
|
2021-03-12 23:00:12 +08:00
|
|
|
|
|
|
|
@Mutation(() => PipelineTask)
|
|
|
|
async createPipelineTask(@Args('task') taskDto: CreatePipelineTaskInput) {
|
|
|
|
return await this.service.addTask(taskDto);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Subscription(() => PipelineTaskLogMessage)
|
2021-03-15 13:30:52 +08:00
|
|
|
async pipelineTaskLog(@Args() args: PipelineTaskLogArgs) {
|
|
|
|
const task = await this.service.findTaskById(args.taskId);
|
|
|
|
const asyncIterator = this.logsService.watchLogs(task);
|
|
|
|
return asyncIterator;
|
|
|
|
}
|
2021-03-12 23:00:12 +08:00
|
|
|
}
|