-
-
Notifications
You must be signed in to change notification settings - Fork 41
Description
Describe the bug
When using the useInfiniteOffsetPaginationQuery
hook to paginate through data fetched from a table, an error occurs when attempting to revalidate the cache of its relations after mutating the table relations. This error arises specifically when using the revalidateTables
or revalidateRelations
options in conjunction with the useUpsertMutation
hook.
Uncaught TypeError: (intermediate value)(intermediate value)(intermediate value).map is not a function
at useInfiniteOffsetPaginationQuery (index.mjs:841:51)
at OrdersTable (Table.tsx:86:39)
at renderWithHooks (react-dom.development.js:9745:28)
at updateFunctionComponent (react-dom.development.js:14159:32)
at beginWork$1 (react-dom.development.js:15948:32)
at beginWork (react-dom.development.js:22789:28)
at performUnitOfWork (react-dom.development.js:21852:24)
at workLoopSync (react-dom.development.js:21617:17)
at renderRootSync (react-dom.development.js:21584:21)
at recoverFromConcurrentError (react-dom.development.js:20917:30)
at performSyncWorkOnRoot (react-dom.development.js:21134:34)
at flushSyncWorkAcrossRoots_impl (react-dom.development.js:9119:33)
at flushSyncWorkOnAllRoots (react-dom.development.js:9085:13)
at processRootScheduleInMicrotask (react-dom.development.js:9207:13)
at eval (react-dom.development.js:9353:21)
To Reproduce
- Use the
useInfiniteOffsetPaginationQuery
hook to paginate through data fetched from a table, such as 'orders', using database joins. - Utilize the
useUpsertMutation
hook to mutate a table, for instance, the 'payments' table. - Specify
revalidateTables
orrevalidateRelations
options to trigger cache revalidation of related tables. - Attempt to trigger cache revalidation by performing a mutation on the 'payments' table.
let query = supabase
.from('orders')
.select('id,clientId,status,price,receivedAt,finishedAt,deliveredAt,payments(id,amount,method,date)')
.eq('status', status)
.order(orderBy, { ascending });
if (filters.clients.length) {
query = query.in('clientId', clients);
}
const { currentPage: orders, setPage, pageIndex, isValidating } =
useInfiniteOffsetPaginationQuery(query, { pageSize: 20 });
const { trigger: upsertPayment, isMutating: isPaymentLoading } = useUpsertMutation(
supabase.from('payments'), ['id'], 'id,orderId',
{
revalidateTables: [{ table: 'orders' }],
// revalidateRelations: [{ relation: 'orders', relationIdColumn: 'id', fKeyColumn: 'orderId' }],
},
);
// upsertPayment([payment]);
Expected behavior
The cache revalidation should occur successfully without causing any errors, allowing for updated data to be reflected in the paginated results fetched by the useInfiniteOffsetPaginationQuery
hook.
Actual behavior
An error is thrown, indicating that (intermediate value)(intermediate value)(intermediate value).map is not a function
, disrupting the application flow and rendering the UI unusable.