58 lines
1.7 KiB
TypeScript
58 lines
1.7 KiB
TypeScript
import { Args, Mutation, Query, Resolver, Subscription } from '@nestjs/graphql';
|
|
import { CreatePipelineInput } from './dtos/create-pipeline.input';
|
|
import { UpdatePipelineInput } from './dtos/update-pipeline.input';
|
|
import { Pipeline } from './pipeline.entity';
|
|
import { PipelinesService } from './pipelines.service';
|
|
import { ListPipelineArgs } from './dtos/list-pipelines.args';
|
|
import { LogList } from '../repos/dtos/log-list.model';
|
|
|
|
@Resolver()
|
|
export class PipelinesResolver {
|
|
constructor(private readonly service: PipelinesService) {}
|
|
@Query(() => [Pipeline])
|
|
async listPipelines(@Args() dto: ListPipelineArgs) {
|
|
return await this.service.list(dto);
|
|
}
|
|
|
|
@Query(() => Pipeline)
|
|
async findPipeline(@Args('id', { type: () => String }) id: string) {
|
|
return await this.service.findOne(id);
|
|
}
|
|
|
|
@Mutation(() => Pipeline)
|
|
async createPipeline(
|
|
@Args('pipeline', { type: () => CreatePipelineInput })
|
|
dto: UpdatePipelineInput,
|
|
) {
|
|
return await this.service.create(dto);
|
|
}
|
|
|
|
@Mutation(() => Pipeline)
|
|
async modifyPipeline(
|
|
@Args('id', { type: () => String }) id: string,
|
|
@Args('Pipeline', { type: () => UpdatePipelineInput })
|
|
dto: UpdatePipelineInput,
|
|
) {
|
|
const tmp = await this.service.update(id, dto);
|
|
console.log(tmp);
|
|
return tmp;
|
|
}
|
|
|
|
@Mutation(() => Number)
|
|
async deletePipeline(@Args('id', { type: () => String }) id: string) {
|
|
return await this.service.remove(id);
|
|
}
|
|
|
|
@Subscription(() => LogList, {
|
|
resolve: (value) => {
|
|
return value;
|
|
},
|
|
})
|
|
async listLogsForPipeline(@Args('id', { type: () => String }) id: string) {
|
|
const job = await this.service.listLogsForPipeline(id);
|
|
return (async function* () {
|
|
yield await job.finished();
|
|
})();
|
|
}
|
|
}
|