diff --git a/CHANGELOG.md b/CHANGELOG.md index e6c57eed0..b874b9dc0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ You can also check the [release page](https://github.com/visualize-admin/visuali - Fixes - Cube checker now correctly checks if dimensions are present + - It's now possible to change the chart type for copied, non-hierarchical charts without having to open an options panel first # [3.22.6] - 2023-09-19 diff --git a/app/configurator/configurator-state.tsx b/app/configurator/configurator-state.tsx index ea01a42a8..8b36811f5 100644 --- a/app/configurator/configurator-state.tsx +++ b/app/configurator/configurator-state.tsx @@ -58,6 +58,9 @@ import { DimensionValue, isGeoDimension } from "@/domain/data"; import { DEFAULT_DATA_SOURCE } from "@/domain/datasource"; import { client } from "@/graphql/client"; import { + ComponentsDocument, + ComponentsQuery, + ComponentsQueryVariables, ComponentsWithHierarchiesDocument, ComponentsWithHierarchiesQuery, ComponentsWithHierarchiesQueryVariables, @@ -329,24 +332,26 @@ const getCachedMetadata = ( draft: ConfiguratorStateConfiguringChart, locale: Locale ): DataCubeMetadataWithHierarchies | null => { - const metadataQuery = client.readQuery< - DataCubeMetadataQuery, - DataCubeMetadataQueryVariables - >(DataCubeMetadataDocument, { - iri: draft.dataSet, - locale, - sourceType: draft.dataSource.type, - sourceUrl: draft.dataSource.url, - }); - const componentsQuery = client.readQuery< - ComponentsWithHierarchiesQuery, - ComponentsWithHierarchiesQueryVariables - >(ComponentsWithHierarchiesDocument, { + const variables = { iri: draft.dataSet, locale, sourceType: draft.dataSource.type, sourceUrl: draft.dataSource.url, - }); + }; + const metadataQuery = client.readQuery< + DataCubeMetadataQuery, + DataCubeMetadataQueryVariables + >(DataCubeMetadataDocument, variables); + // Some charts use hierarchical query, so we need to check for both. + const componentsQuery = + client.readQuery< + ComponentsWithHierarchiesQuery, + ComponentsWithHierarchiesQueryVariables + >(ComponentsWithHierarchiesDocument, variables) ?? + client.readQuery( + ComponentsDocument, + variables + ); return metadataQuery?.data?.dataCubeByIri && componentsQuery?.data?.dataCubeByIri