Add composite fields to aggregation (#8518)

## Context
This PR introduces a first aggregation for a composite field

## Test
<img width="1074" alt="Screenshot 2024-11-15 at 15 37 05"
src="https://github.com/user-attachments/assets/db2563f9-26b7-421f-9431-48fc13bce49e">
This commit is contained in:
Weiko
2024-11-18 12:02:57 +01:00
committed by GitHub
parent 2f5dc26545
commit 0f1cf0e4e9
6 changed files with 54 additions and 12 deletions

View File

@ -19,6 +19,7 @@ export type AggregationField = {
type: GraphQLScalarType;
description: string;
fromField: string;
fromSubField?: string;
aggregationOperation: AGGREGATION_OPERATIONS;
};
@ -79,6 +80,16 @@ export const getAvailableAggregationsFromObjectFields = (
};
}
if (field.type === FieldMetadataType.CURRENCY) {
acc[`avg${capitalize(field.name)}AmountMicros`] = {
type: GraphQLFloat,
description: `Average amount contained in the field ${field.name}`,
fromField: field.name,
fromSubField: 'amountMicros',
aggregationOperation: AGGREGATION_OPERATIONS.avg,
};
}
return acc;
}, {});
};