Add default limit when fetching records (#14532)
- set default limit on front find many hooks - use default constant in rest api find many endpoint - set a max limit in rest api find many endpoint
This commit is contained in:
+2
@@ -10,6 +10,7 @@ import { RecordTableContextProvider } from '@/object-record/record-table/compone
|
||||
import { ViewComponentInstanceContext } from '@/views/states/contexts/ViewComponentInstanceContext';
|
||||
import { type MockedResponse } from '@apollo/client/testing';
|
||||
import gql from 'graphql-tag';
|
||||
import { QUERY_DEFAULT_LIMIT_RECORDS } from 'twenty-shared/constants';
|
||||
import { getJestMetadataAndApolloMocksWrapper } from '~/testing/jest/getJestMetadataAndApolloMocksWrapper';
|
||||
import { JestRecordIndexContextProviderWrapper } from '~/testing/jest/JestRecordIndexContextProviderWrapper';
|
||||
import {
|
||||
@@ -630,6 +631,7 @@ const mocks: MockedResponse[] = [
|
||||
variables: {
|
||||
filter: {},
|
||||
orderBy: [{ position: 'AscNullsFirst' }],
|
||||
limit: QUERY_DEFAULT_LIMIT_RECORDS,
|
||||
},
|
||||
},
|
||||
result: jest.fn(() => ({
|
||||
|
||||
@@ -16,6 +16,7 @@ import { type OnFindManyRecordsCompleted } from '@/object-record/types/OnFindMan
|
||||
import { getQueryIdentifier } from '@/object-record/utils/getQueryIdentifier';
|
||||
|
||||
import { type RecordGqlOperationFilter } from '@/object-record/graphql/types/RecordGqlOperationFilter';
|
||||
import { QUERY_DEFAULT_LIMIT_RECORDS } from 'twenty-shared/constants';
|
||||
|
||||
export type UseFindManyRecordsParams<T> = ObjectMetadataItemIdentifier &
|
||||
RecordGqlOperationVariables & {
|
||||
@@ -31,13 +32,13 @@ export const useFindManyRecords = <T extends ObjectRecord = ObjectRecord>({
|
||||
objectNameSingular,
|
||||
filter,
|
||||
orderBy,
|
||||
limit,
|
||||
skip,
|
||||
recordGqlFields,
|
||||
fetchPolicy,
|
||||
onError,
|
||||
onCompleted,
|
||||
cursorFilter,
|
||||
limit = QUERY_DEFAULT_LIMIT_RECORDS,
|
||||
withSoftDeleted = false,
|
||||
}: UseFindManyRecordsParams<T>) => {
|
||||
const { objectMetadataItem } = useObjectMetadataItem({
|
||||
|
||||
@@ -15,6 +15,7 @@ import { cursorFamilyState } from '@/object-record/states/cursorFamilyState';
|
||||
import { hasNextPageFamilyState } from '@/object-record/states/hasNextPageFamilyState';
|
||||
import { type ObjectRecord } from '@/object-record/types/ObjectRecord';
|
||||
import { getQueryIdentifier } from '@/object-record/utils/getQueryIdentifier';
|
||||
import { QUERY_DEFAULT_LIMIT_RECORDS } from 'twenty-shared/constants';
|
||||
|
||||
type UseLazyFindManyRecordsParams<T> = Omit<
|
||||
UseFindManyRecordsParams<T>,
|
||||
@@ -25,7 +26,7 @@ export const useLazyFindManyRecords = <T extends ObjectRecord = ObjectRecord>({
|
||||
objectNameSingular,
|
||||
filter,
|
||||
orderBy,
|
||||
limit,
|
||||
limit = QUERY_DEFAULT_LIMIT_RECORDS,
|
||||
recordGqlFields,
|
||||
fetchPolicy = 'cache-first',
|
||||
}: UseLazyFindManyRecordsParams<T>) => {
|
||||
|
||||
Reference in New Issue
Block a user