diff --git a/app/configurator/configurator-state/index.spec.tsx b/app/configurator/configurator-state/index.spec.tsx index 85d076983..beb884ac0 100644 --- a/app/configurator/configurator-state/index.spec.tsx +++ b/app/configurator/configurator-state/index.spec.tsx @@ -54,6 +54,7 @@ Object.assign(mockClient, { query: jest.fn().mockImplementation(() => ({ toPromise: jest.fn().mockResolvedValue({ data: { + dataCubePreview: getCachedComponentsMock.geoAndNumerical, possibleFilters, }, }), diff --git a/app/configurator/configurator-state/init.tsx b/app/configurator/configurator-state/init.tsx index 51874113a..f6ddd91ce 100644 --- a/app/configurator/configurator-state/init.tsx +++ b/app/configurator/configurator-state/init.tsx @@ -11,6 +11,9 @@ import { import { SELECTING_DATASET_STATE } from "@/configurator/configurator-state/initial"; import { executeDataCubesComponentsQuery } from "@/graphql/hooks"; import { + DataCubePreviewDocument, + DataCubePreviewQuery, + DataCubePreviewQueryVariables, PossibleFiltersDocument, PossibleFiltersQuery, PossibleFiltersQueryVariables, @@ -43,11 +46,34 @@ export const initChartStateFromCube = async ( dataSource, }); + const { data: dataCubePreview } = await client + .query( + DataCubePreviewDocument, + { + sourceType: dataSource.type, + sourceUrl: dataSource.url, + locale, + cubeFilter: { iri: cubeIri }, + } + ) + .toPromise(); + const { data: components } = await executeDataCubesComponentsQuery(client, { sourceType: dataSource.type, sourceUrl: dataSource.url, locale, - cubeFilters: [{ iri: cubeIri, loadValues: true }], + cubeFilters: [ + { + iri: cubeIri, + componentIris: [ + ...(dataCubePreview?.dataCubePreview.dimensions.filter( + (d) => d.isKeyDimension + ) ?? []), + ...(dataCubePreview?.dataCubePreview.measures ?? []), + ].map((d) => d.iri), + loadValues: true, + }, + ], }); if (!components?.dataCubesComponents) {