feat: add field in infra type

This commit is contained in:
Mir Arif Hasan
2023-10-18 17:25:35 +06:00
parent e4030c4b4e
commit 04aaa108f3
2 changed files with 12 additions and 12 deletions

View File

@@ -1,4 +1,10 @@
import { ObjectType } from '@nestjs/graphql'; import { Field, ObjectType } from '@nestjs/graphql';
import { Admin } from './admin.model';
@ObjectType() @ObjectType()
export class Infra {} export class Infra {
@Field(() => Admin, {
description: 'Admin who executed the action',
})
executedBy: Admin;
}

View File

@@ -1,12 +1,5 @@
import { UseGuards } from '@nestjs/common'; import { UseGuards } from '@nestjs/common';
import { import { Args, ID, Query, ResolveField, Resolver } from '@nestjs/graphql';
Args,
ID,
Parent,
Query,
ResolveField,
Resolver,
} from '@nestjs/graphql';
import { GqlThrottlerGuard } from 'src/guards/gql-throttler.guard'; import { GqlThrottlerGuard } from 'src/guards/gql-throttler.guard';
import { Infra } from './infra.model'; import { Infra } from './infra.model';
import { AdminService } from './admin.service'; import { AdminService } from './admin.service';
@@ -29,11 +22,12 @@ export class InfraResolver {
constructor(private adminService: AdminService) {} constructor(private adminService: AdminService) {}
@Query(() => Infra, { @Query(() => Infra, {
description: 'Gives details of the infra executing this query', description: 'Fetch details of the Infrastructure',
}) })
@UseGuards(GqlAuthGuard, GqlAdminGuard) @UseGuards(GqlAuthGuard, GqlAdminGuard)
infra(@GqlAdmin() admin: Admin) { infra(@GqlAdmin() admin: Admin) {
return admin; const infra: Infra = { executedBy: admin };
return infra;
} }
@ResolveField(() => [User], { @ResolveField(() => [User], {