From 98f13321d4069758ec7a24da77573a7d0d4930dc Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Mon, 8 Feb 2021 09:51:20 +0000 Subject: [PATCH] Add hot reloading of related datasources for external queries --- packages/client/src/api/queries.js | 12 +++++++++--- packages/client/src/utils/buttonActions.js | 1 - 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/packages/client/src/api/queries.js b/packages/client/src/api/queries.js index 9b213d5c46..9876c85a63 100644 --- a/packages/client/src/api/queries.js +++ b/packages/client/src/api/queries.js @@ -1,10 +1,15 @@ -import { notificationStore } from "../store/notification" +import { notificationStore, datasourceStore } from "../store" import API from "./api" /** * Executes a query against an external data connector. */ -export const executeQuery = async ({ queryId, parameters, notify = false }) => { +export const executeQuery = async ({ queryId, parameters }) => { + const query = await API.get({ url: `/api/queries/${queryId}` }) + if (query?.datasourceId == null) { + notificationStore.danger("That query couldn't be found") + return + } const res = await API.post({ url: `/api/queries/${queryId}`, body: { @@ -13,8 +18,9 @@ export const executeQuery = async ({ queryId, parameters, notify = false }) => { }) if (res.error) { notificationStore.danger("An error has occurred") - } else if (notify) { + } else if (!query.readable) { notificationStore.success("Query executed successfully") + datasourceStore.actions.invalidateDatasource(query.datasourceId) } return res } diff --git a/packages/client/src/utils/buttonActions.js b/packages/client/src/utils/buttonActions.js index f96d18269d..4791ff8a88 100644 --- a/packages/client/src/utils/buttonActions.js +++ b/packages/client/src/utils/buttonActions.js @@ -46,7 +46,6 @@ const queryExecutionHandler = async action => { datasourceId, queryId, parameters: queryParams, - notify: true, }) }