Connect the bar chart to the group by resolver (#14885)
Closes https://github.com/twentyhq/core-team-issues/issues/1535 Video QA: https://github.com/user-attachments/assets/153fa3f1-08d9-4952-9456-635c602e1f57 https://github.com/user-attachments/assets/d3111afb-4c84-4f57-8a56-5cf666748c86 There are still some formatting and design issues (the labels which are on top of each other and the values which should be formatted) that will be fixed in a future PR --------- Co-authored-by: ehconitin <nitinkoche03@gmail.com>
This commit is contained in:
+35
@@ -0,0 +1,35 @@
|
||||
import gql from 'graphql-tag';
|
||||
|
||||
import { type ObjectMetadataItem } from '@/object-metadata/types/ObjectMetadataItem';
|
||||
import { capitalize } from 'twenty-shared/utils';
|
||||
import { getGroupByQueryName } from '../../../utils/getGroupByQueryName';
|
||||
|
||||
export const generateGroupByQuery = ({
|
||||
objectMetadataItem,
|
||||
aggregateOperations,
|
||||
}: {
|
||||
objectMetadataItem: ObjectMetadataItem;
|
||||
aggregateOperations: string[];
|
||||
}) => {
|
||||
const capitalizedSingular = capitalize(objectMetadataItem.nameSingular);
|
||||
const queryName = `${capitalize(objectMetadataItem.namePlural)}GroupBy`;
|
||||
const queryFieldName = getGroupByQueryName(objectMetadataItem);
|
||||
|
||||
return gql`
|
||||
query ${queryName}(
|
||||
$groupBy: [${capitalizedSingular}GroupByInput!]
|
||||
$filter: ${capitalizedSingular}FilterInput
|
||||
$orderBy: [${capitalizedSingular}OrderByWithGroupByInput!]
|
||||
$viewId: UUID
|
||||
) {
|
||||
${queryFieldName}(
|
||||
groupBy: $groupBy
|
||||
filter: $filter
|
||||
orderBy: $orderBy
|
||||
viewId: $viewId
|
||||
) {
|
||||
groupByDimensionValues${aggregateOperations.length > 0 ? `\n ${aggregateOperations.join('\n ')}` : ''}
|
||||
}
|
||||
}
|
||||
`;
|
||||
};
|
||||
Reference in New Issue
Block a user