Skip to content

Commit

Permalink
fix: Retrieve either ComponentsWithHierarchies or Components (cache)
Browse files Browse the repository at this point in the history
  • Loading branch information
bprusinowski committed Sep 22, 2023
1 parent 28b8e9a commit 5caec40
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 14 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
33 changes: 19 additions & 14 deletions app/configurator/configurator-state.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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<ComponentsQuery, ComponentsQueryVariables>(
ComponentsDocument,
variables
);

return metadataQuery?.data?.dataCubeByIri &&
componentsQuery?.data?.dataCubeByIri
Expand Down

0 comments on commit 5caec40

Please sign in to comment.