From dc1002659bbc5d2f8c9f09ab7832af277f642d5c Mon Sep 17 00:00:00 2001 From: Ali BARIN Date: Sun, 12 Mar 2023 11:16:51 +0000 Subject: [PATCH] feat: validate connection input in updateStep --- packages/backend/src/graphql/mutations/update-step.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/packages/backend/src/graphql/mutations/update-step.ts b/packages/backend/src/graphql/mutations/update-step.ts index 0c5adbed..3a393fd9 100644 --- a/packages/backend/src/graphql/mutations/update-step.ts +++ b/packages/backend/src/graphql/mutations/update-step.ts @@ -32,6 +32,16 @@ const updateStep = async ( }) .throwIfNotFound(); + if (input.connection.id) { + const hasConnection = await context.currentUser + .$relatedQuery('connections') + .findById(input.connection?.id); + + if (!hasConnection) { + throw new Error('The connection does not exist!'); + } + } + step = await Step.query() .patchAndFetchById(input.id, { key: input.key,