Sync stripe tables (#5475)
Stripe tables do not support `hasNextPage` and `totalCount`. This may be because of stripe wrapper do not properly support `COUNT` request. Waiting on pg_graphql answer [here](https://github.com/supabase/pg_graphql/issues/519). This PR: - removes `totalCount` and `hasNextPage` form queries for remote objects. Even if it works for postgres, this may really be inefficient - adapt the `fetchMore` functions so it works despite `hasNextPage` missing - remove `totalCount` display for remotes - fix `orderBy` --------- Co-authored-by: Thomas Trompette <thomast@twenty.com>
This commit is contained in:
@ -7,6 +7,7 @@ import { RecordGqlRefEdge } from '@/object-record/cache/types/RecordGqlRefEdge';
|
||||
import { getEdgeTypename } from '@/object-record/cache/utils/getEdgeTypename';
|
||||
import { isObjectRecordConnectionWithRefs } from '@/object-record/cache/utils/isObjectRecordConnectionWithRefs';
|
||||
import { RecordGqlNode } from '@/object-record/graphql/types/RecordGqlNode';
|
||||
import { isDefined } from '~/utils/isDefined';
|
||||
|
||||
/*
|
||||
TODO: for now new records are added to all cached record lists, no matter what the variables (filters, orderBy, etc.) are.
|
||||
@ -61,11 +62,10 @@ export const triggerCreateRecordsOptimisticEffect = ({
|
||||
rootQueryCachedObjectRecordConnection,
|
||||
);
|
||||
|
||||
const rootQueryCachedRecordTotalCount =
|
||||
readField<number>(
|
||||
'totalCount',
|
||||
rootQueryCachedObjectRecordConnection,
|
||||
) || 0;
|
||||
const rootQueryCachedRecordTotalCount = readField<number | undefined>(
|
||||
'totalCount',
|
||||
rootQueryCachedObjectRecordConnection,
|
||||
);
|
||||
|
||||
const nextRootQueryCachedRecordEdges = rootQueryCachedRecordEdges
|
||||
? [...rootQueryCachedRecordEdges]
|
||||
@ -113,7 +113,9 @@ export const triggerCreateRecordsOptimisticEffect = ({
|
||||
return {
|
||||
...rootQueryCachedObjectRecordConnection,
|
||||
edges: nextRootQueryCachedRecordEdges,
|
||||
totalCount: rootQueryCachedRecordTotalCount + 1,
|
||||
totalCount: isDefined(rootQueryCachedRecordTotalCount)
|
||||
? rootQueryCachedRecordTotalCount + 1
|
||||
: undefined,
|
||||
};
|
||||
},
|
||||
},
|
||||
|
||||
@ -50,11 +50,10 @@ export const triggerDeleteRecordsOptimisticEffect = ({
|
||||
rootQueryCachedObjectRecordConnection,
|
||||
);
|
||||
|
||||
const totalCount =
|
||||
readField<number>(
|
||||
'totalCount',
|
||||
rootQueryCachedObjectRecordConnection,
|
||||
) || 0;
|
||||
const totalCount = readField<number | undefined>(
|
||||
'totalCount',
|
||||
rootQueryCachedObjectRecordConnection,
|
||||
);
|
||||
|
||||
const nextCachedEdges =
|
||||
cachedEdges?.filter((cachedEdge) => {
|
||||
@ -77,7 +76,9 @@ export const triggerDeleteRecordsOptimisticEffect = ({
|
||||
return {
|
||||
...rootQueryCachedObjectRecordConnection,
|
||||
edges: nextCachedEdges,
|
||||
totalCount: totalCount - recordIdsToDelete.length,
|
||||
totalCount: isDefined(totalCount)
|
||||
? totalCount - recordIdsToDelete.length
|
||||
: undefined,
|
||||
};
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user