Skip to content

Commit

Permalink
Fix findMachineById call in update and delete machines resolvers
Browse files Browse the repository at this point in the history
  • Loading branch information
jpreciadom committed Feb 9, 2024
1 parent 6928d67 commit 4098ef7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/graphql-resolvers/machine-ms/machine.resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@ export class MachineResolver {
@arg('newData') newData: NewMachine,
): Promise<Machine> {
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);
}
Expand All @@ -82,7 +84,7 @@ export class MachineResolver {
@authorized()
async deleteMachine(@arg('id') id: string): Promise<Machine> {
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);
}
Expand Down
2 changes: 1 addition & 1 deletion src/services/abstract-ms.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export abstract class AbstractMsService {
}

protected handleResponse<T>(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;
Expand Down

0 comments on commit 4098ef7

Please sign in to comment.