This is an automated email from the ASF dual-hosted git repository. rusackas pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-superset.git
The following commit(s) were added to refs/heads/master by this push: new ee77707 feat: add deafult buildQuery for V1 chart data requests (#10048) ee77707 is described below commit ee777075320f38c8c66be5c67b14b86cc7980744 Author: Ville Brofeldt <33317356+ville...@users.noreply.github.com> AuthorDate: Fri Jun 12 17:49:13 2020 +0300 feat: add deafult buildQuery for V1 chart data requests (#10048) --- .../spec/javascripts/chart/chartActions_spec.js | 2 +- superset-frontend/spec/javascripts/explore/utils_spec.jsx | 15 ++++++++++++++- superset-frontend/src/explore/exploreUtils.js | 12 ++++++++++-- 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/superset-frontend/spec/javascripts/chart/chartActions_spec.js b/superset-frontend/spec/javascripts/chart/chartActions_spec.js index b8205e6..a525885 100644 --- a/superset-frontend/spec/javascripts/chart/chartActions_spec.js +++ b/superset-frontend/spec/javascripts/chart/chartActions_spec.js @@ -77,7 +77,7 @@ describe('chart actions', () => { describe('v1 API', () => { beforeEach(() => { - fakeMetadata = { useLegacyApi: false }; + fakeMetadata = { viz_type: 'my_viz', useLegacyApi: false }; }); it('should query with the built query', async () => { diff --git a/superset-frontend/spec/javascripts/explore/utils_spec.jsx b/superset-frontend/spec/javascripts/explore/utils_spec.jsx index 2318d6e..c08f1d0 100644 --- a/superset-frontend/spec/javascripts/explore/utils_spec.jsx +++ b/superset-frontend/spec/javascripts/explore/utils_spec.jsx @@ -19,7 +19,11 @@ import sinon from 'sinon'; import URI from 'urijs'; -import { getExploreUrl, getExploreLongUrl } from 'src/explore/exploreUtils'; +import { + buildV1ChartDataPayload, + getExploreUrl, + getExploreLongUrl, +} from 'src/explore/exploreUtils'; import * as hostNamesConfig from 'src/utils/hostNamesConfig'; describe('exploreUtils', () => { @@ -189,4 +193,13 @@ describe('exploreUtils', () => { ); }); }); + + describe('buildV1ChartDataPayload', () => { + it('generate valid request payload despite no registered buildQuery', () => { + const v1RequestPayload = buildV1ChartDataPayload({ + formData: { ...formData, viz_type: 'my_custom_viz' }, + }); + expect(v1RequestPayload).hasOwnProperty('queries'); + }); + }); }); diff --git a/superset-frontend/src/explore/exploreUtils.js b/superset-frontend/src/explore/exploreUtils.js index c283260..e13f18a 100644 --- a/superset-frontend/src/explore/exploreUtils.js +++ b/superset-frontend/src/explore/exploreUtils.js @@ -19,7 +19,8 @@ /* eslint camelcase: 0 */ import URI from 'urijs'; import { SupersetClient } from '@superset-ui/connection'; -import { allowCrossDomain, availableDomains } from 'src/utils/hostNamesConfig'; +import { buildQueryContext } from '@superset-ui/query'; +import { availableDomains } from 'src/utils/hostNamesConfig'; import { safeStringify } from 'src/utils/safeStringify'; import { getChartBuildQueryRegistry, @@ -198,7 +199,14 @@ export const shouldUseLegacyApi = formData => { }; export const buildV1ChartDataPayload = ({ formData, force }) => { - const buildQuery = getChartBuildQueryRegistry().get(formData.viz_type); + const buildQuery = + getChartBuildQueryRegistry().get(formData.viz_type) ?? + (buildQueryformData => + buildQueryContext(buildQueryformData, baseQueryObject => [ + { + ...baseQueryObject, + }, + ])); return buildQuery({ ...formData, force,