From 23622fee480226c63aedeb622b45954c555b7b73 Mon Sep 17 00:00:00 2001 From: binh-dam-ibigroup <56846598+binh-dam-ibigroup@users.noreply.github.com> Date: Wed, 25 Sep 2024 10:43:10 -0400 Subject: [PATCH] fix(core-utils): Make query-gen agnostic to OTP plan query params it doesn't process. --- packages/core-utils/src/query-gen.ts | 27 +++++---------------------- 1 file changed, 5 insertions(+), 22 deletions(-) diff --git a/packages/core-utils/src/query-gen.ts b/packages/core-utils/src/query-gen.ts index 50b5a35ac..b1e8fe335 100644 --- a/packages/core-utils/src/query-gen.ts +++ b/packages/core-utils/src/query-gen.ts @@ -214,21 +214,11 @@ export function generateCombinations(params: OTPQueryParams): OTPQueryParams[] { * @returns A fully formed query+variables ready to be sent to GraphQL backend */ export function generateOtp2Query( - { - arriveBy, - banned, - date, - from, - modes, - modeSettings, - numItineraries, - preferred, - time, - to, - unpreferred - }: OTPQueryParams, + otpQueryParams: OTPQueryParams, planQuery = DefaultPlanQuery ): GraphQLQuery { + const { from, modeSettings, to, ...otherOtpQueryParams } = otpQueryParams; + // This extracts the values from the mode settings to key value pairs const modeSettingValues = modeSettings.reduce((prev, cur) => { if (cur.type === "SLIDER" && cur.inverseKey) { @@ -247,26 +237,19 @@ export function generateOtp2Query( const { bikeReluctance, carReluctance, - walkSpeed, walkReluctance, + walkSpeed, wheelchair } = modeSettingValues; return { query: print(planQuery), variables: { - arriveBy, - banned, + ...otherOtpQueryParams, bikeReluctance, carReluctance, - date, fromPlace: `${from.name}::${from.lat},${from.lon}`, - modes, - numItineraries, - preferred, - time, toPlace: `${to.name}::${to.lat},${to.lon}`, - unpreferred, walkReluctance, walkSpeed, wheelchair