Open-Source API Development Ecosystem • https://hoppscotch.io • Offline, On-Prem & Cloud • Web, Desktop & CLI • Open-Source Alternative to Postman, Insomnia
TypeScript apiapi-clientapi-restapi-testingdeveloper-toolsgraphqlhttphttp-clientpwarestrest-apispatestingtesting-toolstoolsvuevuejswebsocket
chore: added changes to creating a history in resolvers and service method
ankitsridhar16ebf236b387bd
diff --git a/packages/hoppscotch-backend/src/user-history/user-history.resolver.ts b/packages/hoppscotch-backend/src/user-history/user-history.resolver.tsindex 8b64e5af0..65247c79f 100644--- a/packages/hoppscotch-backend/src/user-history/user-history.resolver.ts+++ b/packages/hoppscotch-backend/src/user-history/user-history.resolver.ts@@ -22,7 +22,7 @@ export class UserHistoryResolver {description: 'Adds a new REST/GQL request to user history',})@UseGuards(GqlAuthGuard)- async addRequestToHistory(+ async createUserHistory(@GqlUser() user: User,@Args({name: 'reqData',@@ -40,7 +40,7 @@ export class UserHistoryResolver {})reqType: string,): Promise<UserHistory> {- const createdHistory = await this.userHistoryService.addRequestToHistory(+ const createdHistory = await this.userHistoryService.createUserHistory(user.uid,reqData,resMetadata,diff --git a/packages/hoppscotch-backend/src/user-history/user-history.service.spec.ts b/packages/hoppscotch-backend/src/user-history/user-history.service.spec.tsindex 5a69dba7c..81eadca14 100644--- a/packages/hoppscotch-backend/src/user-history/user-history.service.spec.ts+++ b/packages/hoppscotch-backend/src/user-history/user-history.service.spec.ts@@ -136,8 +136,8 @@ describe('UserHistoryService', () => {).toEqual(userHistory);});});- describe('addRequestToHistory', () => {- test('Should resolve right and add a REST request to users history and return a `UserHistory` object', async () => {+ describe('createUserHistory', () => {+ test('Should resolve right and create a REST request to users history and return a `UserHistory` object', async () => {userHistoryService.validateReqType('REST');mockPrisma.userHistory.create.mockResolvedValueOnce({userUid: 'abc',@@ -160,7 +160,7 @@ describe('UserHistoryService', () => {};return expect(- await userHistoryService.addRequestToHistory(+ await userHistoryService.createUserHistory('abc',JSON.stringify([{}]),JSON.stringify([{}]),@@ -168,7 +168,7 @@ describe('UserHistoryService', () => {),).toEqualRight(userHistory);});- test('Should resolve right and add a GQL request to users history and return a `UserHistory` object', async () => {+ test('Should resolve right and create a GQL request to users history and return a `UserHistory` object', async () => {userHistoryService.validateReqType('GQL');mockPrisma.userHistory.create.mockResolvedValueOnce({userUid: 'abc',@@ -191,7 +191,7 @@ describe('UserHistoryService', () => {};return expect(- await userHistoryService.addRequestToHistory(+ await userHistoryService.createUserHistory('abc',JSON.stringify([{}]),JSON.stringify([{}]),@@ -202,7 +202,7 @@ describe('UserHistoryService', () => {test('Should resolve left when invalid ReqType is passed', async () => {userHistoryService.validateReqType('INVALID');return expect(- await userHistoryService.addRequestToHistory(+ await userHistoryService.createUserHistory('abc',JSON.stringify([{}]),JSON.stringify([{}]),@@ -210,7 +210,7 @@ describe('UserHistoryService', () => {),).toEqualLeft(USER_HISTORY_INVALID_REQ_TYPE);});- test('Should add a GQL request to users history and publish a created subscription', async () => {+ test('Should create a GQL request to users history and publish a created subscription', async () => {userHistoryService.validateReqType('GQL');mockPrisma.userHistory.create.mockResolvedValueOnce({userUid: 'abc',@@ -232,7 +232,7 @@ describe('UserHistoryService', () => {isStarred: false,};- await userHistoryService.addRequestToHistory(+ await userHistoryService.createUserHistory('abc',JSON.stringify([{}]),JSON.stringify([{}]),@@ -244,7 +244,7 @@ describe('UserHistoryService', () => {userHistory,);});- test('Should add a REST request to users history and publish a created subscription', async () => {+ test('Should create a REST request to users history and publish a created subscription', async () => {userHistoryService.validateReqType('REST');mockPrisma.userHistory.create.mockResolvedValueOnce({userUid: 'abc',@@ -266,7 +266,7 @@ describe('UserHistoryService', () => {isStarred: false,};- await userHistoryService.addRequestToHistory(+ await userHistoryService.createUserHistory('abc',JSON.stringify([{}]),JSON.stringify([{}]),diff --git a/packages/hoppscotch-backend/src/user-history/user-history.service.ts b/packages/hoppscotch-backend/src/user-history/user-history.service.tsindex 0b1543dbf..83c60698b 100644--- a/packages/hoppscotch-backend/src/user-history/user-history.service.ts+++ b/packages/hoppscotch-backend/src/user-history/user-history.service.ts@@ -46,14 +46,14 @@ export class UserHistoryService {}/**- * Adds a request to users history.+ * Creates a user history.* @param uid Users uid* @param reqData the request data* @param resMetadata the response metadata* @param reqType request Type to fetch i.e. GraphQL or REST* @returns a `UserHistory` object*/- async addRequestToHistory(+ async createUserHistory(uid: string,reqData: string,resMetadata: string,@@ -92,7 +92,7 @@ export class UserHistoryService {}/**- * Stars or unstars a request in the history+ * Toggles star status of a user history* @param uid Users uid* @param id id of the request in the history* @returns an Either of updated `UserHistory` or Error