diff --git a/superset-frontend/spec/javascripts/chart/chartActions_spec.js b/superset-frontend/spec/javascripts/chart/chartActions_spec.js index b8205e61148..a5258854c1c 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 2318d6e51ea..c08f1d03637 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 c283260ed74..e13f18ae522 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,