fix: enum type fixes in SDL (HBE-183) (#55)
* fix: added reqType typed in sdl * fix: updateUserSession type
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { Field, ID, ArgsType } from '@nestjs/graphql';
|
||||
import { ReqType } from '@prisma/client';
|
||||
import { ReqType } from 'src/types/RequestTypes';
|
||||
import { PaginationArgs } from 'src/types/input-types.args';
|
||||
|
||||
@ArgsType()
|
||||
@@ -82,7 +82,7 @@ export class ImportUserCollectionsFromJSONArgs {
|
||||
description: 'JSON string to import',
|
||||
})
|
||||
jsonString: string;
|
||||
@Field({
|
||||
@Field(() => ReqType, {
|
||||
name: 'reqType',
|
||||
description: 'Type of UserCollection',
|
||||
})
|
||||
|
||||
@@ -18,16 +18,12 @@ import { AuthUser } from 'src/types/AuthUser';
|
||||
import * as E from 'fp-ts/Either';
|
||||
import * as O from 'fp-ts/Option';
|
||||
import { PubSubService } from 'src/pubsub/pubsub.service';
|
||||
import {
|
||||
Prisma,
|
||||
User,
|
||||
UserCollection,
|
||||
ReqType as DBReqType,
|
||||
} from '@prisma/client';
|
||||
import { Prisma, UserCollection, ReqType as DBReqType } from '@prisma/client';
|
||||
import { UserCollection as UserCollectionModel } from './user-collections.model';
|
||||
import { ReqType } from 'src/types/RequestTypes';
|
||||
import { isValidLength, stringToJson } from 'src/utils';
|
||||
import { CollectionFolder } from 'src/types/CollectionFolder';
|
||||
|
||||
@Injectable()
|
||||
export class UserCollectionService {
|
||||
constructor(
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { Field, ID, ObjectType, registerEnumType } from '@nestjs/graphql';
|
||||
import { ReqType } from 'src/types/RequestTypes';
|
||||
|
||||
@ObjectType()
|
||||
export class UserHistory {
|
||||
@@ -39,11 +40,6 @@ export class UserHistory {
|
||||
executedOn: Date;
|
||||
}
|
||||
|
||||
export enum ReqType {
|
||||
REST = 'REST',
|
||||
GQL = 'GQL',
|
||||
}
|
||||
|
||||
registerEnumType(ReqType, {
|
||||
name: 'ReqType',
|
||||
});
|
||||
|
||||
@@ -2,6 +2,7 @@ import { Args, ID, Mutation, Resolver, Subscription } from '@nestjs/graphql';
|
||||
import { UserHistoryService } from './user-history.service';
|
||||
import { PubSubService } from '../pubsub/pubsub.service';
|
||||
import { UserHistory } from './user-history.model';
|
||||
import { ReqType } from 'src/types/RequestTypes';
|
||||
import { UseGuards } from '@nestjs/common';
|
||||
import { GqlAuthGuard } from '../guards/gql-auth.guard';
|
||||
import { GqlUser } from '../decorators/gql-user.decorator';
|
||||
@@ -40,8 +41,9 @@ export class UserHistoryResolver {
|
||||
@Args({
|
||||
name: 'reqType',
|
||||
description: 'Request type, REST or GQL',
|
||||
type: () => ReqType,
|
||||
})
|
||||
reqType: string,
|
||||
reqType: ReqType,
|
||||
): Promise<UserHistory> {
|
||||
const createdHistory = await this.userHistoryService.createUserHistory(
|
||||
user.uid,
|
||||
@@ -101,8 +103,9 @@ export class UserHistoryResolver {
|
||||
@Args({
|
||||
name: 'reqType',
|
||||
description: 'Request type, REST or GQL',
|
||||
type: () => ReqType,
|
||||
})
|
||||
reqType: string,
|
||||
reqType: ReqType,
|
||||
): Promise<number> {
|
||||
const deletedHistory = await this.userHistoryService.deleteAllUserHistory(
|
||||
user.uid,
|
||||
|
||||
@@ -2,12 +2,12 @@ import { UserHistoryService } from './user-history.service';
|
||||
import { PrismaService } from '../prisma/prisma.service';
|
||||
import { PubSubService } from '../pubsub/pubsub.service';
|
||||
import { mockDeep, mockReset } from 'jest-mock-extended';
|
||||
import { ReqType, UserHistory } from './user-history.model';
|
||||
import { UserHistory } from './user-history.model';
|
||||
import { ReqType } from 'src/types/RequestTypes';
|
||||
import {
|
||||
USER_HISTORY_INVALID_REQ_TYPE,
|
||||
USER_HISTORY_NOT_FOUND,
|
||||
} from '../errors';
|
||||
import { ReqType as DBReqType } from '@prisma/client';
|
||||
|
||||
const mockPrisma = mockDeep<PrismaService>();
|
||||
const mockPubSub = mockDeep<PubSubService>();
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { PrismaService } from '../prisma/prisma.service';
|
||||
import { PubSubService } from '../pubsub/pubsub.service';
|
||||
import { ReqType, UserHistory } from './user-history.model';
|
||||
import { UserHistory } from './user-history.model';
|
||||
import { ReqType } from 'src/types/RequestTypes';
|
||||
import * as E from 'fp-ts/Either';
|
||||
import * as O from 'fp-ts/Option';
|
||||
import {
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import { Args, Parent, ResolveField, Resolver } from '@nestjs/graphql';
|
||||
import { User } from '../user/user.model';
|
||||
import { UserHistoryService } from './user-history.service';
|
||||
import { ReqType, UserHistory } from './user-history.model';
|
||||
import { UserHistory } from './user-history.model';
|
||||
import { ReqType } from 'src/types/RequestTypes';
|
||||
import { PaginationArgs } from '../types/input-types.args';
|
||||
|
||||
@Resolver(() => User)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Field, ID, ArgsType } from '@nestjs/graphql';
|
||||
import { PaginationArgs } from 'src/types/input-types.args';
|
||||
import { ReqType } from 'src/user-history/user-history.model';
|
||||
import { ReqType } from 'src/types/RequestTypes';
|
||||
|
||||
@ArgsType()
|
||||
export class GetUserRequestArgs extends PaginationArgs {
|
||||
|
||||
@@ -24,7 +24,7 @@ import {
|
||||
} from '../input-type.args';
|
||||
import { AuthUser } from 'src/types/AuthUser';
|
||||
import { User } from 'src/user/user.model';
|
||||
import { ReqType } from 'src/user-history/user-history.model';
|
||||
import { ReqType } from 'src/types/RequestTypes';
|
||||
import { GqlThrottlerGuard } from 'src/guards/gql-throttler.guard';
|
||||
import { SkipThrottle } from '@nestjs/throttler';
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Field, ID, ObjectType } from '@nestjs/graphql';
|
||||
import { ReqType } from 'src/user-history/user-history.model';
|
||||
import { ReqType } from 'src/types/RequestTypes';
|
||||
|
||||
@ObjectType()
|
||||
export class UserRequest {
|
||||
|
||||
@@ -20,7 +20,7 @@ import {
|
||||
import { UserRequest } from './user-request.model';
|
||||
import { UserRequestService } from './user-request.service';
|
||||
import { AuthUser } from 'src/types/AuthUser';
|
||||
import { ReqType } from 'src/user-history/user-history.model';
|
||||
import { ReqType } from 'src/types/RequestTypes';
|
||||
import { UserCollectionService } from 'src/user-collection/user-collection.service';
|
||||
|
||||
const mockPrisma = mockDeep<PrismaService>();
|
||||
|
||||
@@ -13,7 +13,7 @@ import {
|
||||
} from 'src/errors';
|
||||
import { stringToJson } from 'src/utils';
|
||||
import { AuthUser } from 'src/types/AuthUser';
|
||||
import { ReqType } from 'src/user-history/user-history.model';
|
||||
import { ReqType } from 'src/types/RequestTypes';
|
||||
import { UserCollectionService } from 'src/user-collection/user-collection.service';
|
||||
|
||||
@Injectable()
|
||||
|
||||
@@ -2,7 +2,6 @@ import {
|
||||
ObjectType,
|
||||
ID,
|
||||
Field,
|
||||
InputType,
|
||||
registerEnumType,
|
||||
} from '@nestjs/graphql';
|
||||
|
||||
|
||||
@@ -46,6 +46,7 @@ export class UserResolver {
|
||||
@Args({
|
||||
name: 'sessionType',
|
||||
description: 'Type of the session',
|
||||
type: () => SessionType,
|
||||
})
|
||||
sessionType: SessionType,
|
||||
): Promise<User> {
|
||||
|
||||
@@ -8,7 +8,7 @@ import * as T from 'fp-ts/Task';
|
||||
import * as A from 'fp-ts/Array';
|
||||
import { pipe, constVoid } from 'fp-ts/function';
|
||||
import { AuthUser } from 'src/types/AuthUser';
|
||||
import { USER_NOT_FOUND, USERS_NOT_FOUND } from 'src/errors';
|
||||
import { USER_NOT_FOUND } from 'src/errors';
|
||||
import { SessionType, User } from './user.model';
|
||||
import { USER_UPDATE_FAILED } from 'src/errors';
|
||||
import { PubSubService } from 'src/pubsub/pubsub.service';
|
||||
|
||||
Reference in New Issue
Block a user