From 2f7cde95da2e501b2750c1f846df2fdbff7cb0e9 Mon Sep 17 00:00:00 2001 From: Ali BARIN Date: Tue, 26 Oct 2021 23:55:02 +0200 Subject: [PATCH] refactor: rename fields with arguments and properties --- packages/web/src/components/AddAppConnection/index.tsx | 2 +- packages/web/src/graphql/queries/get-app.ts | 8 ++++---- packages/web/src/helpers/computeAuthStepVariables.ts | 10 +++++----- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/packages/web/src/components/AddAppConnection/index.tsx b/packages/web/src/components/AddAppConnection/index.tsx index a4d029f4..e211607d 100644 --- a/packages/web/src/components/AddAppConnection/index.tsx +++ b/packages/web/src/components/AddAppConnection/index.tsx @@ -49,7 +49,7 @@ export default function AddAppConnection(props: AddAppConnectionProps){ let stepIndex = 0; while (stepIndex < steps.length) { const step = steps[stepIndex]; - const variables = computeAuthStepVariables(step, response); + const variables = computeAuthStepVariables(step.arguments, response); const stepResponse = await processStep(step, variables); diff --git a/packages/web/src/graphql/queries/get-app.ts b/packages/web/src/graphql/queries/get-app.ts index 85a307ce..18e96206 100644 --- a/packages/web/src/graphql/queries/get-app.ts +++ b/packages/web/src/graphql/queries/get-app.ts @@ -23,10 +23,10 @@ export const GET_APP = gql` step type name - fields { + arguments { name value - fields { + properties { name value } @@ -36,10 +36,10 @@ export const GET_APP = gql` step type name - fields { + arguments { name value - fields { + properties { name value } diff --git a/packages/web/src/helpers/computeAuthStepVariables.ts b/packages/web/src/helpers/computeAuthStepVariables.ts index 174c17a2..8793703b 100644 --- a/packages/web/src/helpers/computeAuthStepVariables.ts +++ b/packages/web/src/helpers/computeAuthStepVariables.ts @@ -6,17 +6,17 @@ type VARIABLES = { [key: string]: any } -const computeAuthStepVariables = (authStep: any, aggregatedData: any) => { +const computeAuthStepVariables = (variableSchema: any, aggregatedData: any) => { const variables: VARIABLES = {}; - for (const field of authStep.fields) { - if (field.fields) { - variables[field.name] = computeAuthStepVariables(field, aggregatedData); + for (const variable of variableSchema) { + if (variable.properties) { + variables[variable.name] = computeAuthStepVariables(variable.properties, aggregatedData); continue; } - variables[field.name] = template(field.value, { interpolate })(aggregatedData); + variables[variable.name] = template(variable.value, { interpolate })(aggregatedData); } return variables;