From 4098ef7145ad24b63e9362c03f5621e1124e2866 Mon Sep 17 00:00:00 2001 From: Juan Diego Date: Thu, 8 Feb 2024 19:53:27 -0500 Subject: [PATCH] Fix findMachineById call in update and delete machines resolvers --- src/graphql-resolvers/machine-ms/machine.resolver.ts | 6 ++++-- src/services/abstract-ms.service.ts | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/graphql-resolvers/machine-ms/machine.resolver.ts b/src/graphql-resolvers/machine-ms/machine.resolver.ts index a759242..5e86b3b 100644 --- a/src/graphql-resolvers/machine-ms/machine.resolver.ts +++ b/src/graphql-resolvers/machine-ms/machine.resolver.ts @@ -70,7 +70,9 @@ export class MachineResolver { @arg('newData') newData: NewMachine, ): Promise { const {currentUser} = this.resolverData.context; - const existingMachine = await this.getMachineById(id); + console.log(currentUser); + const existingMachine = await this.machineMs.findMachineById(id); + console.log(existingMachine); if (existingMachine.accountId !== currentUser[securityId]) { throw new GraphQLError('The requester is not the machine owner', 403); } @@ -82,7 +84,7 @@ export class MachineResolver { @authorized() async deleteMachine(@arg('id') id: string): Promise { const {currentUser} = this.resolverData.context; - const existingMachine = await this.getMachineById(id); + const existingMachine = await this.machineMs.findMachineById(id); if (existingMachine.accountId !== currentUser[securityId]) { throw new GraphQLError('The requester is not the machine owner', 403); } diff --git a/src/services/abstract-ms.service.ts b/src/services/abstract-ms.service.ts index 1d804f0..0cb46ad 100644 --- a/src/services/abstract-ms.service.ts +++ b/src/services/abstract-ms.service.ts @@ -39,7 +39,7 @@ export abstract class AbstractMsService { } protected handleResponse(response: AxiosResponse): T { - // If response status if grather of equal than 400 then request failed + // If response status if grather of equal than 400 then the request failed if (response.status >= 400) { const errorBody = response.data as MsHttpError; const {message, statusCode, details} = errorBody.error;