Browse Source

Add hot reloading of related datasources for external queries

master
Andrew Kingston 6 years ago
parent
commit
bd1bd8ee2a
  1. 12
      packages/client/src/api/queries.js
  2. 1
      packages/client/src/utils/buttonActions.js

12
packages/client/src/api/queries.js

@ -1,10 +1,15 @@
import { notificationStore } from "../store/notification" import { notificationStore, datasourceStore } from "../store"
import API from "./api" import API from "./api"
/** /**
* Executes a query against an external data connector. * 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({ const res = await API.post({
url: `/api/queries/${queryId}`, url: `/api/queries/${queryId}`,
body: { body: {
@ -13,8 +18,9 @@ export const executeQuery = async ({ queryId, parameters, notify = false }) => {
}) })
if (res.error) { if (res.error) {
notificationStore.danger("An error has occurred") notificationStore.danger("An error has occurred")
} else if (notify) { } else if (!query.readable) {
notificationStore.success("Query executed successfully") notificationStore.success("Query executed successfully")
datasourceStore.actions.invalidateDatasource(query.datasourceId)
} }
return res return res
} }

1
packages/client/src/utils/buttonActions.js

@ -46,7 +46,6 @@ const queryExecutionHandler = async action => {
datasourceId, datasourceId,
queryId, queryId,
parameters: queryParams, parameters: queryParams,
notify: true,
}) })
} }

Loading…
Cancel
Save