diff --git a/packages/builder/src/pages/builder/app/[application]/data/datasource/[selectedDatasource]/_components/DynamicVariableModal.svelte b/packages/builder/src/pages/builder/app/[application]/data/datasource/[selectedDatasource]/_components/DynamicVariableModal.svelte
index 61d0a1993c..5c0cd0f883 100644
--- a/packages/builder/src/pages/builder/app/[application]/data/datasource/[selectedDatasource]/_components/DynamicVariableModal.svelte
+++ b/packages/builder/src/pages/builder/app/[application]/data/datasource/[selectedDatasource]/_components/DynamicVariableModal.svelte
@@ -1,5 +1,8 @@
diff --git a/packages/builder/src/pages/builder/app/[application]/data/datasource/[selectedDatasource]/rest/[query]/index.svelte b/packages/builder/src/pages/builder/app/[application]/data/datasource/[selectedDatasource]/rest/[query]/index.svelte
index e870c2f6db..d2914146ce 100644
--- a/packages/builder/src/pages/builder/app/[application]/data/datasource/[selectedDatasource]/rest/[query]/index.svelte
+++ b/packages/builder/src/pages/builder/app/[application]/data/datasource/[selectedDatasource]/rest/[query]/index.svelte
@@ -37,7 +37,7 @@
import AccessLevelSelect from "components/integration/AccessLevelSelect.svelte"
import DynamicVariableModal from "../../_components/DynamicVariableModal.svelte"
import Placeholder from "assets/bb-spaceship.svg"
- import { cloneDeep } from "lodash/fp"
+ import { cloneDeep, isEqual } from "lodash/fp"
import { RawRestBodyTypes } from "constants/backend"
let query, datasource
@@ -47,6 +47,7 @@
let response, schema, enabledHeaders
let authConfigId
let dynamicVariables, addVariableModal, varBinding
+ let baseQuery, baseDatasource, baseVariables
$: datasourceType = datasource?.source
$: integrationInfo = $integrations[datasourceType]
@@ -62,6 +63,15 @@
$: hasSchema =
Object.keys(schema || {}).length !== 0 ||
Object.keys(query?.schema || {}).length !== 0
+ $: baseQuery = !baseQuery ? cloneDeep(query) : baseQuery
+ $: baseDatasource = !baseDatasource ? cloneDeep(datasource) : baseDatasource
+ $: baseVariables = !baseVariables
+ ? cloneDeep(dynamicVariables)
+ : baseVariables
+ $: hasChanged =
+ !isEqual(baseQuery, query) ||
+ !isEqual(baseDatasource, datasource) ||
+ !isEqual(baseVariables, dynamicVariables)
function getSelectedQuery() {
return cloneDeep(
@@ -120,6 +130,9 @@
datasource.config.dynamicVariables = rebuildVariables(saveId)
datasource = await datasources.save(datasource)
}
+ baseQuery = query
+ baseDatasource = datasource
+ baseVariables = dynamicVariables
} catch (err) {
notifications.error(`Error saving query`)
}
@@ -299,6 +312,7 @@
{dynamicVariables}
bind:binding={varBinding}
bind:this={addVariableModal}
+ on:change={saveQuery}
/>
{#if query && queryConfig}
@@ -332,7 +346,7 @@