Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | 2x 1x 8x 8x 1x 1x 1x 2x 2x 1x 1x 1x 2x 2x 2x 2x 1x 1x 1x 2x 2x 2x 2x 1x 1x | import { AppMatcompArgs, AppMatcompInputDto, AppMatcompModel, AppMatcompSubscription } from '@app/backend-interfaces';
import { Inject, NotFoundException, UseGuards } from '@nestjs/common';
import { Args, Mutation, Query, Resolver, Subscription } from '@nestjs/graphql';
import { PubSub } from 'graphql-subscriptions';
import { AppMatcompGuard } from '../guards/matcomp.guard';
import type { TMatcompService } from '../interfaces/matcomp.interface';
import { MATCOMP_SERVICE_TOKEN } from '../services/matcomp.service';
@Resolver(() => AppMatcompModel)
export class AppMatcompResolver {
constructor(
@Inject(MATCOMP_SERVICE_TOKEN) private readonly service: TMatcompService,
@Inject('PUB_SUB') private readonly pubSub: PubSub,
) {}
@Query(() => [AppMatcompModel])
@UseGuards(AppMatcompGuard)
public async matcomps(@Args() matcompArgs: AppMatcompArgs) {
return this.service.findAll(matcompArgs);
}
@Query(() => AppMatcompModel)
@UseGuards(AppMatcompGuard)
public async matcomp(
@Args('id')
id: string,
) {
const matcomp = this.service.findOneById(id);
if (typeof matcomp === 'undefined') {
throw new NotFoundException(id);
}
return matcomp;
}
@Mutation(() => AppMatcompModel)
@UseGuards(AppMatcompGuard)
public async create(@Args('input') args: AppMatcompInputDto) {
const createdMatcomp = this.service.create(args);
const matcompSubscription: AppMatcompSubscription = new AppMatcompSubscription({ matcomp: createdMatcomp });
void this.pubSub.publish('matcompCreated', matcompSubscription);
return createdMatcomp;
}
@Subscription(() => AppMatcompModel)
@UseGuards(AppMatcompGuard)
public matcompCreated() {
return this.pubSub.asyncIterableIterator('matcompCreated');
}
@Mutation(() => AppMatcompModel)
@UseGuards(AppMatcompGuard)
public async remove(@Args('id') id: string) {
const removedMatcomp = this.service.remove(id);
const matcompSubscription: AppMatcompSubscription = new AppMatcompSubscription({ matcomp: removedMatcomp });
void this.pubSub.publish('matcompRemoved', matcompSubscription);
return removedMatcomp;
}
@Subscription(() => AppMatcompModel)
@UseGuards(AppMatcompGuard)
public matcompRemoved() {
return this.pubSub.asyncIterableIterator('matcompRemoved');
}
}
|