Skip to content

Commit

Permalink
Merge pull request #295 from psteinroe/chore/upgrade-react-query-peer…
Browse files Browse the repository at this point in the history
…-deps

chore/upgrade react query peer deps
  • Loading branch information
psteinroe committed Oct 18, 2023
2 parents a501afa + 263c0c7 commit e0ffaef
Show file tree
Hide file tree
Showing 20 changed files with 499 additions and 429 deletions.
6 changes: 6 additions & 0 deletions .changeset/poor-avocados-judge.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@supabase-cache-helpers/postgrest-react-query": minor
"@supabase-cache-helpers/storage-react-query": minor
---

chore: add support for react-query v5
2 changes: 1 addition & 1 deletion docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"nextra-theme-docs": "^2.2.19",
"react": "18.2.0",
"react-dom": "18.2.0",
"typescript": "5.0.2"
"typescript": "5.2.2"
},
"devDependencies": {
"autoprefixer": "^10.4.13",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export const UpsertContactModal: FC<UpsertContactModalProps> = ({
}) => {
const supabase = useSupabaseClient<Database>()

const { mutateAsync: upsert, isLoading } = useUpsertMutation(
const { mutateAsync: upsert, isPending } = useUpsertMutation(
supabase.from("contact"),
["id"],
null,
Expand Down Expand Up @@ -124,11 +124,11 @@ export const UpsertContactModal: FC<UpsertContactModalProps> = ({
</div>
</div>
<DialogFooter>
<Button type="submit" disabled={isLoading}>
{isLoading ? (
<Button type="submit" disabled={isPending}>
{isPending ? (
<Loader2 className="mr-2 h-4 w-4 animate-spin" />
) : null}{" "}
{isLoading ? "Loading" : "Submit"}
{isPending ? "Loading" : "Submit"}
</Button>
</DialogFooter>
</form>
Expand Down
6 changes: 3 additions & 3 deletions examples/react-query/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@
"@supabase-cache-helpers/storage-react-query": "workspace:*",
"@supabase/auth-helpers-nextjs": "^0.5.6",
"@supabase/auth-helpers-react": "^0.3.1",
"@tanstack/react-query": "^4.29.12",
"@tanstack/react-query": "^5.0.0",
"@vercel/analytics": "^0.1.11",
"class-variance-authority": "^0.4.0",
"class-variance-authority": "0.7.0",
"clsx": "^1.2.1",
"cmdk": "^0.1.21",
"lucide-react": "0.105.0-alpha.4",
Expand Down Expand Up @@ -80,6 +80,6 @@
"postcss": "^8.4.14",
"prettier": "2.8.8",
"tailwindcss": "^3.1.7",
"typescript": "^4.5.3"
"typescript": "5.2.2"
}
}
1 change: 0 additions & 1 deletion examples/react-query/tsconfig.tsbuildinfo

This file was deleted.

4 changes: 2 additions & 2 deletions examples/swr/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"@supabase/auth-helpers-react": "^0.3.1",
"@supabase/supabase-js": "2.26.0",
"@vercel/analytics": "^0.1.11",
"class-variance-authority": "^0.4.0",
"class-variance-authority": "0.7.0",
"clsx": "^1.2.1",
"cmdk": "^0.1.21",
"lucide-react": "0.105.0-alpha.4",
Expand Down Expand Up @@ -81,6 +81,6 @@
"postcss": "^8.4.14",
"prettier": "2.8.8",
"tailwindcss": "^3.1.7",
"typescript": "^4.5.3"
"typescript": "^5.2.2"
}
}
2 changes: 1 addition & 1 deletion packages/eslint-config-custom/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"eslint-config-universe": "11.3.0"
},
"devDependencies": {
"typescript": "5.0.4"
"typescript": "5.2.2"
},
"publishConfig": {
"access": "public"
Expand Down
2 changes: 1 addition & 1 deletion packages/postgrest-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,6 @@
"jest": "29.7.0",
"ts-jest": "29.1.0",
"tsup": "7.2.0",
"typescript": "5.0.4"
"typescript": "5.2.2"
}
}
4 changes: 2 additions & 2 deletions packages/postgrest-react-query/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"directory": "packages/postgrest-react-query"
},
"peerDependencies": {
"@tanstack/react-query": "^4.0.0",
"@tanstack/react-query": "^4.0.0 || ^5.0.0",
"react": "^16.11.0 || ^17.0.0 || ^18.0.0",
"@supabase/postgrest-js": "^1.0.0"
},
Expand All @@ -74,7 +74,7 @@
"react": "18.2.0",
"@types/react": "18.2.0",
"react-dom": "18.2.0",
"typescript": "5.0.4"
"typescript": "5.2.2"
},
"dependencies": {
"@supabase-cache-helpers/postgrest-core": "workspace:*"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export function useDeleteItem<Type extends Record<string, unknown>>(
.map((c) => c.queryKey),
getPostgrestFilter,
mutate: (key, fn) => {
queryClient.setQueriesData(key, fn);
queryClient.setQueriesData({ queryKey: key }, fn);
},
decode,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export function useUpsertItem<Type extends Record<string, unknown>>(
.map((c) => c.queryKey),
getPostgrestFilter,
mutate: (key, fn) => {
queryClient.setQueriesData(key, fn);
queryClient.setQueriesData({ queryKey: key }, fn);
},
decode,
}
Expand Down
10 changes: 5 additions & 5 deletions packages/postgrest-react-query/src/query/use-query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,16 +136,16 @@ function useQuery<Result>(
const { data, ...rest } = useReactQuery<
AnyPostgrestResponse<Result>,
PostgrestError
>(
encode<Result>(query, false),
async () => {
>({
queryKey: encode<Result>(query, false),
queryFn: async () => {
if (isPostgrestBuilder(query)) {
query = query.throwOnError();
}
return await query;
},
config
);
...config,
});

return { data: data?.data, count: data?.count ?? null, ...rest };
}
Expand Down
2 changes: 1 addition & 1 deletion packages/postgrest-swr/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
"react": "18.2.0",
"@types/react": "18.2.0",
"react-dom": "18.2.0",
"typescript": "5.0.4"
"typescript": "5.2.2"
},
"dependencies": {
"@supabase-cache-helpers/postgrest-core": "workspace:*"
Expand Down
2 changes: 1 addition & 1 deletion packages/storage-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,6 @@
"ts-jest": "29.1.0",
"@supabase-cache-helpers/tsconfig": "workspace:*",
"tsup": "7.2.0",
"typescript": "5.0.4"
"typescript": "5.2.2"
}
}
4 changes: 2 additions & 2 deletions packages/storage-react-query/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"directory": "packages/storage-react-query"
},
"peerDependencies": {
"@tanstack/react-query": "^4.0.0",
"@tanstack/react-query": "^4.0.0 || ^5.0.0",
"react": "^16.11.0 || ^17.0.0 || ^18.0.0",
"@supabase/storage-js": "^2.4.0"
},
Expand All @@ -74,7 +74,7 @@
"react": "18.2.0",
"@types/react": "18.2.0",
"react-dom": "18.2.0",
"typescript": "5.0.4"
"typescript": "5.2.2"
},
"dependencies": {
"@supabase-cache-helpers/storage-core": "workspace:*"
Expand Down
10 changes: 5 additions & 5 deletions packages/storage-react-query/src/query/use-directory-urls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ function useDirectoryFileUrls(
return useReactQuery<
(FileObject & { url: string })[] | undefined,
StorageError
>(
encode([fileApi, path]),
() => createDirectoryUrlsFetcher(mode, config)(fileApi, path),
config
);
>({
queryKey: encode([fileApi, path]),
queryFn: () => createDirectoryUrlsFetcher(mode, config)(fileApi, path),
...config,
});
}

export { useDirectoryFileUrls };
10 changes: 5 additions & 5 deletions packages/storage-react-query/src/query/use-directory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ function useDirectory(
'queryKey' | 'queryFn'
>
): UseReactQueryResult<FileObject[] | undefined, StorageError> {
return useReactQuery(
encode([fileApi, path]),
() => fetchDirectory(fileApi, path),
config
);
return useReactQuery({
queryKey: encode([fileApi, path]),
queryFn: () => fetchDirectory(fileApi, path),
...config,
});
}

export { useDirectory };
10 changes: 5 additions & 5 deletions packages/storage-react-query/src/query/use-file-url.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ function useFileUrl(
> &
URLFetcherConfig
): UseReactQueryResult<string | undefined, StorageError> {
return useReactQuery<string | undefined, StorageError>(
encode([fileApi, path]),
() => createUrlFetcher(mode, config)(fileApi, path),
config
);
return useReactQuery<string | undefined, StorageError>({
queryKey: encode([fileApi, path]),
queryFn: () => createUrlFetcher(mode, config)(fileApi, path),
...config,
});
}

export { useFileUrl };
2 changes: 1 addition & 1 deletion packages/storage-swr/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
"react": "18.2.0",
"@types/react": "18.2.0",
"react-dom": "18.2.0",
"typescript": "5.0.4"
"typescript": "5.2.2"
},
"dependencies": {
"@supabase-cache-helpers/storage-core": "workspace:*"
Expand Down
Loading

3 comments on commit e0ffaef

@vercel
Copy link

@vercel vercel bot commented on e0ffaef Oct 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

supabase-cache-helpers-react-query – ./examples/react-query

supabase-cache-helpers-react-query-psteinroe.vercel.app
supabase-cache-helpers-react-query.vercel.app
supabase-cache-helpers-react-query-git-main-psteinroe.vercel.app

@vercel
Copy link

@vercel vercel bot commented on e0ffaef Oct 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on e0ffaef Oct 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

supabase-cache-helpers-swr-demo – ./examples/swr

supabase-cache-helpers-swr-demo-psteinroe.vercel.app
supabase-cache-helpers-swr-demo-git-main-psteinroe.vercel.app
supabase-cache-helpers-swr.vercel.app

Please sign in to comment.