Skip to content

Commit

Permalink
feat: Ability to get unique dimension values filtered by above filters
Browse files Browse the repository at this point in the history
  • Loading branch information
ptbrowne committed Jan 21, 2022
1 parent c180f0b commit 0901d4c
Show file tree
Hide file tree
Showing 9 changed files with 288 additions and 68 deletions.
6 changes: 5 additions & 1 deletion app/configurator/components/chart-configurator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,11 @@ export const ChartConfigurator = ({
}) => {
const locale = useLocale();
const [{ data }] = useDataCubeMetadataWithComponentValuesQuery({
variables: { iri: state.dataSet, locale },
variables: {
iri: state.dataSet,
locale,
filters: state.chartConfig.filters,
},
});

if (data?.dataCubeByIri) {
Expand Down
12 changes: 10 additions & 2 deletions app/graphql/queries/data-cubes.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,20 @@ fragment dimensionMetaData on Dimension {
iri
label
isKeyDimension
values
values(filters: $filters)
unit
... on TemporalDimension {
timeUnit
timeFormat
}
}

query DataCubePreview($iri: String!, $locale: String!, $latest: Boolean) {
query DataCubePreview(
$iri: String!
$locale: String!
$latest: Boolean
$filters: Filters
) {
dataCubeByIri(iri: $iri, locale: $locale, latest: $latest) {
iri
title
Expand Down Expand Up @@ -101,6 +106,7 @@ query DataCubeMetadataWithComponentValues(
$iri: String!
$locale: String!
$latest: Boolean
$filters: Filters
) {
dataCubeByIri(iri: $iri, locale: $locale, latest: $latest) {
iri
Expand All @@ -120,6 +126,7 @@ query DimensionValues(
$dimensionIri: String!
$locale: String!
$latest: Boolean
$filters: Filters
) {
dataCubeByIri(iri: $dataCubeIri, locale: $locale, latest: $latest) {
dimensionByIri(iri: $dimensionIri) {
Expand All @@ -133,6 +140,7 @@ query TemporalDimensionValues(
$dimensionIri: String!
$locale: String!
$latest: Boolean
$filters: Filters
) {
dataCubeByIri(iri: $dataCubeIri, locale: $locale, latest: $latest) {
dimensionByIri(iri: $dimensionIri) {
Expand Down
40 changes: 35 additions & 5 deletions app/graphql/query-hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,11 @@ export type Dimension = {
};


export type DimensionValuesArgs = {
filters?: Maybe<Scalars['Filters']>;
};



export type Measure = Dimension & {
__typename: 'Measure';
Expand All @@ -114,6 +119,11 @@ export type Measure = Dimension & {
values: Array<Scalars['DimensionValue']>;
};


export type MeasureValuesArgs = {
filters?: Maybe<Scalars['Filters']>;
};

export type NominalDimension = Dimension & {
__typename: 'NominalDimension';
iri: Scalars['String'];
Expand All @@ -125,6 +135,11 @@ export type NominalDimension = Dimension & {
};


export type NominalDimensionValuesArgs = {
filters?: Maybe<Scalars['Filters']>;
};


export type ObservationsQuery = {
__typename: 'ObservationsQuery';
/** Observations with their values parsed to native JS types */
Expand All @@ -147,6 +162,11 @@ export type OrdinalDimension = Dimension & {
values: Array<Scalars['DimensionValue']>;
};


export type OrdinalDimensionValuesArgs = {
filters?: Maybe<Scalars['Filters']>;
};

export type Query = {
__typename: 'Query';
dataCubeByIri?: Maybe<DataCube>;
Expand All @@ -162,6 +182,7 @@ export type QueryDataCubeByIriArgs = {
locale?: Maybe<Scalars['String']>;
iri: Scalars['String'];
latest?: Maybe<Scalars['Boolean']>;
filters?: Maybe<Scalars['Filters']>;
};


Expand Down Expand Up @@ -209,6 +230,11 @@ export type TemporalDimension = Dimension & {
values: Array<Scalars['DimensionValue']>;
};


export type TemporalDimensionValuesArgs = {
filters?: Maybe<Scalars['Filters']>;
};

export enum TimeUnit {
Year = 'Year',
Month = 'Month',
Expand Down Expand Up @@ -244,6 +270,7 @@ export type DataCubePreviewQueryVariables = Exact<{
iri: Scalars['String'];
locale: Scalars['String'];
latest?: Maybe<Scalars['Boolean']>;
filters?: Maybe<Scalars['Filters']>;
}>;


Expand Down Expand Up @@ -287,6 +314,7 @@ export type DataCubeMetadataWithComponentValuesQueryVariables = Exact<{
iri: Scalars['String'];
locale: Scalars['String'];
latest?: Maybe<Scalars['Boolean']>;
filters?: Maybe<Scalars['Filters']>;
}>;


Expand All @@ -312,6 +340,7 @@ export type DimensionValuesQueryVariables = Exact<{
dimensionIri: Scalars['String'];
locale: Scalars['String'];
latest?: Maybe<Scalars['Boolean']>;
filters?: Maybe<Scalars['Filters']>;
}>;


Expand All @@ -334,6 +363,7 @@ export type TemporalDimensionValuesQueryVariables = Exact<{
dimensionIri: Scalars['String'];
locale: Scalars['String'];
latest?: Maybe<Scalars['Boolean']>;
filters?: Maybe<Scalars['Filters']>;
}>;


Expand Down Expand Up @@ -404,7 +434,7 @@ export const DimensionMetaDataFragmentDoc = gql`
iri
label
isKeyDimension
values
values(filters: $filters)
unit
... on TemporalDimension {
timeUnit
Expand Down Expand Up @@ -446,7 +476,7 @@ export function useDataCubesQuery(options: Omit<Urql.UseQueryArgs<DataCubesQuery
return Urql.useQuery<DataCubesQuery>({ query: DataCubesDocument, ...options });
};
export const DataCubePreviewDocument = gql`
query DataCubePreview($iri: String!, $locale: String!, $latest: Boolean) {
query DataCubePreview($iri: String!, $locale: String!, $latest: Boolean, $filters: Filters) {
dataCubeByIri(iri: $iri, locale: $locale, latest: $latest) {
iri
title
Expand Down Expand Up @@ -509,7 +539,7 @@ export function useDataCubeMetadataQuery(options: Omit<Urql.UseQueryArgs<DataCub
return Urql.useQuery<DataCubeMetadataQuery>({ query: DataCubeMetadataDocument, ...options });
};
export const DataCubeMetadataWithComponentValuesDocument = gql`
query DataCubeMetadataWithComponentValues($iri: String!, $locale: String!, $latest: Boolean) {
query DataCubeMetadataWithComponentValues($iri: String!, $locale: String!, $latest: Boolean, $filters: Filters) {
dataCubeByIri(iri: $iri, locale: $locale, latest: $latest) {
iri
title
Expand All @@ -528,7 +558,7 @@ export function useDataCubeMetadataWithComponentValuesQuery(options: Omit<Urql.U
return Urql.useQuery<DataCubeMetadataWithComponentValuesQuery>({ query: DataCubeMetadataWithComponentValuesDocument, ...options });
};
export const DimensionValuesDocument = gql`
query DimensionValues($dataCubeIri: String!, $dimensionIri: String!, $locale: String!, $latest: Boolean) {
query DimensionValues($dataCubeIri: String!, $dimensionIri: String!, $locale: String!, $latest: Boolean, $filters: Filters) {
dataCubeByIri(iri: $dataCubeIri, locale: $locale, latest: $latest) {
dimensionByIri(iri: $dimensionIri) {
...dimensionMetaData
Expand All @@ -541,7 +571,7 @@ export function useDimensionValuesQuery(options: Omit<Urql.UseQueryArgs<Dimensio
return Urql.useQuery<DimensionValuesQuery>({ query: DimensionValuesDocument, ...options });
};
export const TemporalDimensionValuesDocument = gql`
query TemporalDimensionValues($dataCubeIri: String!, $dimensionIri: String!, $locale: String!, $latest: Boolean) {
query TemporalDimensionValues($dataCubeIri: String!, $dimensionIri: String!, $locale: String!, $latest: Boolean, $filters: Filters) {
dataCubeByIri(iri: $dataCubeIri, locale: $locale, latest: $latest) {
dimensionByIri(iri: $dimensionIri) {
... on TemporalDimension {
Expand Down
36 changes: 31 additions & 5 deletions app/graphql/resolver-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,11 @@ export type Dimension = {
};


export type DimensionValuesArgs = {
filters?: Maybe<Scalars['Filters']>;
};



export type Measure = Dimension & {
__typename?: 'Measure';
Expand All @@ -119,6 +124,11 @@ export type Measure = Dimension & {
values: Array<Scalars['DimensionValue']>;
};


export type MeasureValuesArgs = {
filters?: Maybe<Scalars['Filters']>;
};

export type NominalDimension = Dimension & {
__typename?: 'NominalDimension';
iri: Scalars['String'];
Expand All @@ -130,6 +140,11 @@ export type NominalDimension = Dimension & {
};


export type NominalDimensionValuesArgs = {
filters?: Maybe<Scalars['Filters']>;
};


export type ObservationsQuery = {
__typename?: 'ObservationsQuery';
/** Observations with their values parsed to native JS types */
Expand All @@ -152,6 +167,11 @@ export type OrdinalDimension = Dimension & {
values: Array<Scalars['DimensionValue']>;
};


export type OrdinalDimensionValuesArgs = {
filters?: Maybe<Scalars['Filters']>;
};

export type Query = {
__typename?: 'Query';
dataCubeByIri?: Maybe<DataCube>;
Expand All @@ -167,6 +187,7 @@ export type QueryDataCubeByIriArgs = {
locale?: Maybe<Scalars['String']>;
iri: Scalars['String'];
latest?: Maybe<Scalars['Boolean']>;
filters?: Maybe<Scalars['Filters']>;
};


Expand Down Expand Up @@ -214,6 +235,11 @@ export type TemporalDimension = Dimension & {
values: Array<Scalars['DimensionValue']>;
};


export type TemporalDimensionValuesArgs = {
filters?: Maybe<Scalars['Filters']>;
};

export enum TimeUnit {
Year = 'Year',
Month = 'Month',
Expand Down Expand Up @@ -395,7 +421,7 @@ export type DimensionResolvers<ContextType = any, ParentType extends ResolversPa
unit?: Resolver<Maybe<ResolversTypes['String']>, ParentType, ContextType>;
scaleType?: Resolver<Maybe<ResolversTypes['String']>, ParentType, ContextType>;
isKeyDimension?: Resolver<ResolversTypes['Boolean'], ParentType, ContextType>;
values?: Resolver<Array<ResolversTypes['DimensionValue']>, ParentType, ContextType>;
values?: Resolver<Array<ResolversTypes['DimensionValue']>, ParentType, ContextType, RequireFields<DimensionValuesArgs, never>>;
}>;

export interface DimensionValueScalarConfig extends GraphQLScalarTypeConfig<ResolversTypes['DimensionValue'], any> {
Expand All @@ -412,7 +438,7 @@ export type MeasureResolvers<ContextType = any, ParentType extends ResolversPare
unit?: Resolver<Maybe<ResolversTypes['String']>, ParentType, ContextType>;
scaleType?: Resolver<Maybe<ResolversTypes['String']>, ParentType, ContextType>;
isKeyDimension?: Resolver<ResolversTypes['Boolean'], ParentType, ContextType>;
values?: Resolver<Array<ResolversTypes['DimensionValue']>, ParentType, ContextType>;
values?: Resolver<Array<ResolversTypes['DimensionValue']>, ParentType, ContextType, RequireFields<MeasureValuesArgs, never>>;
__isTypeOf?: IsTypeOfResolverFn<ParentType, ContextType>;
}>;

Expand All @@ -422,7 +448,7 @@ export type NominalDimensionResolvers<ContextType = any, ParentType extends Reso
unit?: Resolver<Maybe<ResolversTypes['String']>, ParentType, ContextType>;
scaleType?: Resolver<Maybe<ResolversTypes['String']>, ParentType, ContextType>;
isKeyDimension?: Resolver<ResolversTypes['Boolean'], ParentType, ContextType>;
values?: Resolver<Array<ResolversTypes['DimensionValue']>, ParentType, ContextType>;
values?: Resolver<Array<ResolversTypes['DimensionValue']>, ParentType, ContextType, RequireFields<NominalDimensionValuesArgs, never>>;
__isTypeOf?: IsTypeOfResolverFn<ParentType, ContextType>;
}>;

Expand All @@ -444,7 +470,7 @@ export type OrdinalDimensionResolvers<ContextType = any, ParentType extends Reso
unit?: Resolver<Maybe<ResolversTypes['String']>, ParentType, ContextType>;
scaleType?: Resolver<Maybe<ResolversTypes['String']>, ParentType, ContextType>;
isKeyDimension?: Resolver<ResolversTypes['Boolean'], ParentType, ContextType>;
values?: Resolver<Array<ResolversTypes['DimensionValue']>, ParentType, ContextType>;
values?: Resolver<Array<ResolversTypes['DimensionValue']>, ParentType, ContextType, RequireFields<OrdinalDimensionValuesArgs, never>>;
__isTypeOf?: IsTypeOfResolverFn<ParentType, ContextType>;
}>;

Expand All @@ -469,7 +495,7 @@ export type TemporalDimensionResolvers<ContextType = any, ParentType extends Res
unit?: Resolver<Maybe<ResolversTypes['String']>, ParentType, ContextType>;
scaleType?: Resolver<Maybe<ResolversTypes['String']>, ParentType, ContextType>;
isKeyDimension?: Resolver<ResolversTypes['Boolean'], ParentType, ContextType>;
values?: Resolver<Array<ResolversTypes['DimensionValue']>, ParentType, ContextType>;
values?: Resolver<Array<ResolversTypes['DimensionValue']>, ParentType, ContextType, RequireFields<TemporalDimensionValuesArgs, never>>;
__isTypeOf?: IsTypeOfResolverFn<ParentType, ContextType>;
}>;

Expand Down
Loading

0 comments on commit 0901d4c

Please sign in to comment.