Skip to content

Commit

Permalink
fix: import
Browse files Browse the repository at this point in the history
  • Loading branch information
psteinroe committed Sep 12, 2023
1 parent b474b26 commit f80f8a4
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 14 deletions.
6 changes: 6 additions & 0 deletions .changeset/rotten-rings-listen.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@supabase-cache-helpers/postgrest-react-query": patch
"@supabase-cache-helpers/postgrest-swr": patch
---

fix: use new exports from core package
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BuildQueryOps } from '@supabase-cache-helpers/postgrest-core';
import { BuildNormalizedQueryOps } from '@supabase-cache-helpers/postgrest-core';
import { useQueryClient } from '@tanstack/react-query';

import { decode } from './key';
Expand All @@ -13,11 +13,14 @@ export const useQueriesForTableLoader = (table: string) => {
.getQueryCache()
.getAll()
.map((c) => c.queryKey)
.reduce<ReturnType<BuildQueryOps['queriesForTable']>>((prev, curr) => {
const decodedKey = decode(curr);
if (decodedKey?.table === table) {
prev.push(getPostgrestFilter(decodedKey.queryKey).params);
}
return prev;
}, []);
.reduce<ReturnType<BuildNormalizedQueryOps['queriesForTable']>>(
(prev, curr) => {
const decodedKey = decode(curr);
if (decodedKey?.table === table) {
prev.push(getPostgrestFilter(decodedKey.queryKey).params);
}
return prev;
},
[]
);
};
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {
buildQuery,
buildNormalizedQuery,
PostgrestMutatorOpts,
} from '@supabase-cache-helpers/postgrest-core';
import { GetResult } from '@supabase/postgrest-js/dist/module/select-query-parser';
Expand Down Expand Up @@ -105,7 +105,7 @@ function useSubscriptionQuery<
filter,
async (payload) => {
let data: T['Row'] | R = payload.new ?? payload.old;
const selectQuery = buildQuery({ queriesForTable, query });
const selectQuery = buildNormalizedQuery({ queriesForTable, query });
if (
payload.eventType !==
REALTIME_POSTGRES_CHANGES_LISTEN_EVENT.DELETE &&
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BuildQueryOps } from '@supabase-cache-helpers/postgrest-core';
import { BuildNormalizedQueryOps } from '@supabase-cache-helpers/postgrest-core';
import { useSWRConfig } from 'swr';

import { decode } from './decode';
Expand All @@ -10,7 +10,7 @@ export const useQueriesForTableLoader = (table: string) => {

return () =>
Array.from(cache.keys()).reduce<
ReturnType<BuildQueryOps['queriesForTable']>
ReturnType<BuildNormalizedQueryOps['queriesForTable']>
>((prev, curr) => {
const decodedKey = decode(curr);
if (decodedKey?.table === table) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {
buildQuery,
buildNormalizedQuery,
PostgrestMutatorOpts,
QueryWithoutWildcard,
} from '@supabase-cache-helpers/postgrest-core';
Expand Down Expand Up @@ -108,7 +108,7 @@ function useSubscriptionQuery<
filter,
async (payload) => {
let data: T['Row'] | R = payload.new ?? payload.old;
const selectQuery = buildQuery({ queriesForTable, query });
const selectQuery = buildNormalizedQuery({ queriesForTable, query });
if (
payload.eventType !==
REALTIME_POSTGRES_CHANGES_LISTEN_EVENT.DELETE &&
Expand Down

0 comments on commit f80f8a4

Please sign in to comment.