console: In the rest details, send the request variable value as a JSON object if type of variable is JSON instead of a string

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/9396
GitOrigin-RevId: 5a72d144e6b47ef986ed056490649e791d3f1bea
This commit is contained in:
Varun Choudhary 2023-06-07 18:15:38 +05:30 committed by hasura-bot
parent 93860fd244
commit 504ef83b11

View File

@ -3,6 +3,7 @@ import { parse } from 'graphql';
import globals from '../../../../Globals';
import { AllowedRESTMethods } from '../../../../metadata/types';
import { VariableState } from './LivePreview/state';
import { isJsonString } from '../../../Common/utils/export.utils';
// getCurrentPageHost can be used within all components
// that are showing the REST endpoint that will be generated
@ -292,6 +293,11 @@ const getValueWithType = (variableData: VariableState) => {
return Number(variableData.value);
}
// NOTE: bool_exp are of JSON type, so pass it as JSON object (issue: https://github.com/hasura/graphql-engine/issues/9671)
if (variableData.type.endsWith('_exp') && isJsonString(variableData.value)) {
return JSON.parse(variableData.value);
}
return variableData.value?.trim()?.toString();
};