Files
hoppscotch/packages/hoppscotch-backend/src/user-history/user.resolver.ts
Mir Arif Hasan ccdce37f88 fix: enum type fixes in SDL (HBE-183) (#55)
* fix: added reqType typed in sdl

* fix: updateUserSession type
2023-03-28 17:46:41 +06:00

38 lines
1.1 KiB
TypeScript

import { Args, Parent, ResolveField, Resolver } from '@nestjs/graphql';
import { User } from '../user/user.model';
import { UserHistoryService } from './user-history.service';
import { UserHistory } from './user-history.model';
import { ReqType } from 'src/types/RequestTypes';
import { PaginationArgs } from '../types/input-types.args';
@Resolver(() => User)
export class UserHistoryUserResolver {
constructor(private userHistoryService: UserHistoryService) {}
@ResolveField(() => [UserHistory], {
description: 'Returns a users REST history',
})
async RESTHistory(
@Parent() user: User,
@Args() args: PaginationArgs,
): Promise<UserHistory[]> {
return await this.userHistoryService.fetchUserHistory(
user.uid,
args.take,
ReqType.REST,
);
}
@ResolveField(() => [UserHistory], {
description: 'Returns a users GraphQL history',
})
async GQLHistory(
@Parent() user: User,
@Args() args: PaginationArgs,
): Promise<UserHistory[]> {
return await this.userHistoryService.fetchUserHistory(
user.uid,
args.take,
ReqType.GQL,
);
}
}