fennec-be/src/pipeline-tasks/pipeline-tasks.resolver.ts

54 lines
1.8 KiB
TypeScript
Raw Normal View History

import { Resolver, Args, Mutation, Subscription, Query } 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';
import { plainToClass } from 'class-transformer';
@Resolver()
export class PipelineTasksResolver {
2021-05-30 22:36:06 +08:00
constructor(private readonly service: PipelineTasksService) {}
@Mutation(() => PipelineTask)
async createPipelineTask(@Args('task') taskDto: CreatePipelineTaskInput) {
return await this.service.addTask(taskDto);
}
@Subscription(() => PipelineTaskLogMessage, {
resolve: (value) => {
const data = plainToClass(PipelineTaskLogMessage, value);
return data;
},
})
async pipelineTaskLog(@Args() args: PipelineTaskLogArgs) {
2021-05-30 22:36:06 +08:00
// const task = await this.service.findTaskById(args.taskId);
// const asyncIterator = this.logsService.watchLogs(task);
// return asyncIterator;
}
@Subscription(() => PipelineTask, {
resolve: (value) => {
return value;
},
})
async pipelineTaskChanged(@Args('id') id: string) {
2021-05-30 22:36:06 +08:00
// return await this.service.watchTaskUpdated(id);
}
@Query(() => [PipelineTask])
async listPipelineTaskByPipelineId(@Args('pipelineId') pipelineId: string) {
return await this.service.listTasksByPipelineId(pipelineId);
}
@Query(() => PipelineTask)
async pipelineTask(@Args('id') id: string) {
return await this.service.findTaskById(id);
}
@Mutation(() => Boolean)
async stopPipelineTask(@Args('id') id: string) {
const task = await this.service.findTaskById(id);
}
}