[GroupBy] Add views filters to groupBy query (#14762)

Closes https://github.com/twentyhq/core-team-issues/issues/1560

If viewId is defined in a groupBy query, we want to apply all filters of
the view to the query.
This required to move a lot of code from twenty-front to twenty-shared
to convert the filters as stored in the db into graphql filters,
applying the right combinations between filters etc., which was
previously only done in the FE.

This PR does not handle any field filters, it will be done in a later pr
This commit is contained in:
Marie
2025-09-30 09:58:55 +02:00
committed by GitHub
parent 80fa4c6c26
commit da3c3d2b9d
174 changed files with 1192 additions and 483 deletions
@@ -1,188 +0,0 @@
export type UUIDFilterValue = string;
export type IsFilter = 'NULL' | 'NOT_NULL';
export type UUIDFilter = {
eq?: UUIDFilterValue;
in?: UUIDFilterValue[];
neq?: UUIDFilterValue;
is?: IsFilter;
};
export type RelationFilter = {
is?: IsFilter;
in?: UUIDFilterValue[];
};
export type BooleanFilter = {
eq?: boolean;
is?: IsFilter;
};
export type StringFilter = {
eq?: string;
in?: string[];
neq?: string;
startsWith?: string;
like?: string;
ilike?: string;
regex?: string;
iregex?: string;
is?: IsFilter;
};
export type RatingFilter = {
eq?: string;
in?: string[];
is?: IsFilter;
};
export type FloatFilter = {
eq?: number;
gt?: number;
gte?: number;
in?: number[];
lt?: number;
lte?: number;
neq?: number;
is?: IsFilter;
};
/**
* Always use a DateFilter in the variables of a query, and never directly in the query.
*
* Because pg_graphql only works with ISO strings if it is passed to variables.
*/
export type DateFilter = {
eq?: string;
gt?: string;
gte?: string;
in?: string[];
lt?: string;
lte?: string;
neq?: string;
is?: IsFilter;
};
export type CurrencyFilter = {
amountMicros?: FloatFilter;
currencyCode?: SelectFilter;
};
export type URLFilter = {
url?: StringFilter;
label?: StringFilter;
};
export type FullNameFilter = {
firstName?: StringFilter;
lastName?: StringFilter;
};
export type AddressFilter = {
addressStreet1?: StringFilter;
addressStreet2?: StringFilter;
addressCity?: StringFilter;
addressState?: StringFilter;
addressCountry?: StringFilter;
addressPostcode?: StringFilter;
};
export type LinksFilter = {
primaryLinkUrl?: StringFilter;
primaryLinkLabel?: StringFilter;
secondaryLinks?: RawJsonFilter;
};
export type ActorFilter = {
name?: StringFilter;
source?: SelectFilter;
};
export type EmailsFilter = {
primaryEmail?: StringFilter;
additionalEmails?: RawJsonFilter;
};
export type PhonesFilter = {
primaryPhoneNumber?: StringFilter;
primaryPhoneCallingCode?: StringFilter;
additionalPhones?: RawJsonFilter;
};
export type SelectFilter = {
is?: IsFilter;
in?: string[];
eq?: string;
};
export type MultiSelectFilter = {
is?: IsFilter;
isEmptyArray?: boolean;
containsAny?: string[];
};
export type ArrayFilter = {
is?: IsFilter;
isEmptyArray?: boolean;
containsIlike?: string;
};
export type RawJsonFilter = {
like?: string;
is?: IsFilter;
};
export type RichTextV2LeafFilter = {
ilike?: string;
};
export type RichTextV2Filter = {
blocknote?: RichTextV2LeafFilter;
markdown?: RichTextV2LeafFilter;
};
export type TSVectorFilter = {
search: string;
};
export type LeafFilter =
| UUIDFilter
| StringFilter
| FloatFilter
| DateFilter
| CurrencyFilter
| URLFilter
| FullNameFilter
| BooleanFilter
| AddressFilter
| LinksFilter
| ActorFilter
| PhonesFilter
| ArrayFilter
| RawJsonFilter
| RichTextV2Filter
| TSVectorFilter
| undefined;
export type AndObjectRecordFilter = {
and?: RecordGqlOperationFilter[];
};
export type OrObjectRecordFilter = {
or?: RecordGqlOperationFilter[] | RecordGqlOperationFilter;
};
export type NotObjectRecordFilter = {
not?: RecordGqlOperationFilter;
};
export type LeafObjectRecordFilter = {
[fieldName: string]: LeafFilter;
};
export type RecordGqlOperationFilter =
| LeafObjectRecordFilter
| AndObjectRecordFilter
| OrObjectRecordFilter
| NotObjectRecordFilter;
@@ -1,6 +1,6 @@
import { type RecordGqlOperationFilter } from '@/object-record/graphql/types/RecordGqlOperationFilter';
import { type RecordGqlOperationOrderBy } from '@/object-record/graphql/types/RecordGqlOperationOrderBy';
import { type QueryCursorDirection } from '@/object-record/utils/generateFindManyRecordsQuery';
import { type RecordGqlOperationFilter } from 'twenty-shared/types';
export type RecordGqlOperationVariables = {
filter?: RecordGqlOperationFilter;