diff --git a/apps/studio/components/interfaces/Reports/v2/ReportChartV2.tsx b/apps/studio/components/interfaces/Reports/v2/ReportChartV2.tsx
index b84e320db06..769ee3b4bac 100644
--- a/apps/studio/components/interfaces/Reports/v2/ReportChartV2.tsx
+++ b/apps/studio/components/interfaces/Reports/v2/ReportChartV2.tsx
@@ -78,22 +78,20 @@ export const ReportChartV2 = ({
isLoading: isLoadingChart,
error,
isFetching,
- } = useQuery(
- [
+ } = useQuery({
+ queryKey: [
'projects',
projectRef,
'report-v2',
{ reportId: report.id, startDate, endDate, interval, filters },
],
- async () => {
+ queryFn: async () => {
return await report.dataProvider(projectRef, startDate, endDate, interval, filters)
},
- {
- enabled: Boolean(projectRef && canFetch && isAvailable && !report.hide),
- refetchOnWindowFocus: false,
- staleTime: 0,
- }
- )
+ enabled: Boolean(projectRef && canFetch && isAvailable && !report.hide),
+ refetchOnWindowFocus: false,
+ staleTime: 0,
+ })
const chartData = queryResult?.data || []
const dynamicAttributes = queryResult?.attributes || []
diff --git a/apps/studio/components/interfaces/Storage/StorageMenu.BucketList.tsx b/apps/studio/components/interfaces/Storage/StorageMenu.BucketList.tsx
index b49c691a71f..c2d0193ce3d 100644
--- a/apps/studio/components/interfaces/Storage/StorageMenu.BucketList.tsx
+++ b/apps/studio/components/interfaces/Storage/StorageMenu.BucketList.tsx
@@ -4,6 +4,7 @@ import type { ListChildComponentProps } from 'react-window'
import { FixedSizeList as List, areEqual } from 'react-window'
import type { Bucket } from 'data/storage/buckets-query'
+import { cn } from 'ui'
import { BucketRow } from './BucketRow'
type BucketListProps = {
@@ -25,7 +26,7 @@ const VirtualizedBucketRow = memo(
isSelected={isSelected}
projectRef={data.projectRef}
style={style as CSSProperties}
- className={BUCKET_ROW_HEIGHT}
+ className={cn(BUCKET_ROW_HEIGHT)}
/>
)
},
@@ -95,19 +96,15 @@ export const BucketList = ({ buckets, selectedBucketId, projectRef = '' }: Bucke
const numBuckets = buckets.length
if (numBuckets <= 50) {
- return (
-
- {buckets.map((bucket) => (
-
- ))}
-
- )
+ return buckets.map((bucket) => (
+
+ ))
}
return (
diff --git a/apps/studio/components/interfaces/Storage/StorageMenu.tsx b/apps/studio/components/interfaces/Storage/StorageMenu.tsx
index 8ffd4ca64e6..0ee63944eb8 100644
--- a/apps/studio/components/interfaces/Storage/StorageMenu.tsx
+++ b/apps/studio/components/interfaces/Storage/StorageMenu.tsx
@@ -10,7 +10,7 @@ import { useBucketsQuery } from 'data/storage/buckets-query'
import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject'
import { IS_PLATFORM } from 'lib/constants'
import { useStorageExplorerStateSnapshot } from 'state/storage-explorer'
-import { Alert_Shadcn_, AlertDescription_Shadcn_, AlertTitle_Shadcn_, Menu } from 'ui'
+import { Alert_Shadcn_, AlertDescription_Shadcn_, AlertTitle_Shadcn_, cn, Menu } from 'ui'
import { InfoTooltip } from 'ui-patterns/info-tooltip'
import {
InnerSideBarEmptyPanel,
@@ -70,15 +70,12 @@ export const StorageMenu = () => {
[sortedBuckets, searchText]
)
const tempNotSupported = error?.message.includes('Tenant config') && isBranch
+ const isVirtualized = buckets.length > 50
return (
<>
-
-
+
+
@@ -110,8 +107,17 @@ export const StorageMenu = () => {
-
-
+
+
0
+ ? 'mb-3'
+ : 'mb-5'
+ )}
+ >
All buckets} />
{isLoading && (
@@ -165,27 +171,27 @@ export const StorageMenu = () => {
>
)}
+
-
-
Configuration} />
-
-
- Policies
+
+
Configuration} />
+
+
+ Policies
+
+
+ {IS_PLATFORM && (
+
+
+
+
Settings
+ {isListV2UpgradeAvailable && (
+
Upgrade available
+ )}
+
- {IS_PLATFORM && (
-
-
-
-
Settings
- {isListV2UpgradeAvailable && (
-
Upgrade available
- )}
-
-
-
- )}
-
+ )}
>
diff --git a/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/TableEditor/TableQuickstart/QuickstartTemplatesWidget.tsx b/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/TableEditor/TableQuickstart/QuickstartTemplatesWidget.tsx
index e4fb1ee0a31..14d2336a775 100644
--- a/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/TableEditor/TableQuickstart/QuickstartTemplatesWidget.tsx
+++ b/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/TableEditor/TableQuickstart/QuickstartTemplatesWidget.tsx
@@ -1,6 +1,7 @@
import { Columns3, Layers, Table2 } from 'lucide-react'
import { useCallback, useEffect, useState } from 'react'
import { toast } from 'sonner'
+
import { cn, Tooltip, TooltipContent, TooltipTrigger } from 'ui'
import type { TableField } from '../TableEditor.types'
import { tableTemplates } from './templates'
diff --git a/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/TableEditor/TableQuickstart/templates.ts b/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/TableEditor/TableQuickstart/templates.ts
index 68dd6dfe4da..27e101814b9 100644
--- a/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/TableEditor/TableQuickstart/templates.ts
+++ b/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/TableEditor/TableQuickstart/templates.ts
@@ -12,12 +12,7 @@ export const tableTemplates: Record
= {
isPrimary: true,
default: 'gen_random_uuid()',
},
- {
- name: 'user_id',
- type: 'uuid',
- nullable: false,
- unique: true,
- },
+ { name: 'user_id', type: 'uuid', nullable: false, unique: true },
{ name: 'username', type: 'text', nullable: true, unique: true },
{ name: 'display_name', type: 'text', nullable: true },
{ name: 'avatar_url', type: 'text', nullable: true },
@@ -40,11 +35,7 @@ export const tableTemplates: Record = {
isPrimary: true,
default: 'gen_random_uuid()',
},
- {
- name: 'author_id',
- type: 'uuid',
- nullable: false,
- },
+ { name: 'author_id', type: 'uuid', nullable: false },
{ name: 'content', type: 'text', nullable: false },
{ name: 'image_url', type: 'text', nullable: true },
{ name: 'likes_count', type: 'int4', nullable: false, default: '0' },
@@ -65,16 +56,8 @@ export const tableTemplates: Record = {
isPrimary: true,
default: 'gen_random_uuid()',
},
- {
- name: 'follower_id',
- type: 'uuid',
- nullable: false,
- },
- {
- name: 'following_id',
- type: 'uuid',
- nullable: false,
- },
+ { name: 'follower_id', type: 'uuid', nullable: false },
+ { name: 'following_id', type: 'uuid', nullable: false },
{ name: 'created_at', type: 'timestamptz', nullable: false, default: 'now()' },
],
rationale: 'Tracks relationships between followers and followed users',
@@ -120,12 +103,8 @@ export const tableTemplates: Record = {
default: 'gen_random_uuid()',
},
{ name: 'order_number', type: 'text', nullable: false, unique: true },
- {
- name: 'customer_id',
- type: 'uuid',
- nullable: false,
- },
- { name: 'status', type: 'text', nullable: false, default: "'pending'" },
+ { name: 'customer_id', type: 'uuid', nullable: false },
+ { name: 'status', type: 'text', nullable: false, default: 'pending' },
{ name: 'subtotal', type: 'numeric', nullable: false },
{ name: 'tax', type: 'numeric', nullable: false, default: '0' },
{ name: 'shipping', type: 'numeric', nullable: false, default: '0' },
@@ -147,16 +126,8 @@ export const tableTemplates: Record = {
isPrimary: true,
default: 'gen_random_uuid()',
},
- {
- name: 'user_id',
- type: 'uuid',
- nullable: false,
- },
- {
- name: 'product_id',
- type: 'uuid',
- nullable: false,
- },
+ { name: 'user_id', type: 'uuid', nullable: false },
+ { name: 'product_id', type: 'uuid', nullable: false },
{ name: 'quantity', type: 'int4', nullable: false, default: '1' },
{ name: 'added_at', type: 'timestamptz', nullable: false, default: 'now()' },
],
@@ -180,11 +151,7 @@ export const tableTemplates: Record = {
{ name: 'content', type: 'text', nullable: true },
{ name: 'excerpt', type: 'text', nullable: true },
{ name: 'cover_image', type: 'text', nullable: true },
- {
- name: 'author_id',
- type: 'uuid',
- nullable: false,
- },
+ { name: 'author_id', type: 'uuid', nullable: false },
{ name: 'status', type: 'text', nullable: false, default: "'draft'" },
{ name: 'published_at', type: 'timestamptz', nullable: true },
{ name: 'created_at', type: 'timestamptz', nullable: false, default: 'now()' },
@@ -222,11 +189,7 @@ export const tableTemplates: Record = {
isPrimary: true,
default: 'gen_random_uuid()',
},
- {
- name: 'article_id',
- type: 'uuid',
- nullable: false,
- },
+ { name: 'article_id', type: 'uuid', nullable: false },
{ name: 'author_name', type: 'text', nullable: false },
{ name: 'author_email', type: 'text', nullable: false },
{ name: 'content', type: 'text', nullable: false },
@@ -251,13 +214,9 @@ export const tableTemplates: Record = {
{ name: 'title', type: 'text', nullable: false },
{ name: 'description', type: 'text', nullable: true },
{ name: 'completed', type: 'bool', nullable: false, default: 'false' },
- { name: 'priority', type: 'text', nullable: true, default: "'medium'" },
+ { name: 'priority', type: 'text', nullable: true, default: 'medium' },
{ name: 'due_date', type: 'date', nullable: true },
- {
- name: 'user_id',
- type: 'uuid',
- nullable: false,
- },
+ { name: 'user_id', type: 'uuid', nullable: false },
{ name: 'list_id', type: 'uuid', nullable: true },
{ name: 'created_at', type: 'timestamptz', nullable: false, default: 'now()' },
{ name: 'updated_at', type: 'timestamptz', nullable: false, default: 'now()' },
@@ -279,11 +238,7 @@ export const tableTemplates: Record = {
{ name: 'description', type: 'text', nullable: true },
{ name: 'color', type: 'text', nullable: true },
{ name: 'icon', type: 'text', nullable: true },
- {
- name: 'user_id',
- type: 'uuid',
- nullable: false,
- },
+ { name: 'user_id', type: 'uuid', nullable: false },
{ name: 'created_at', type: 'timestamptz', nullable: false, default: 'now()' },
{ name: 'updated_at', type: 'timestamptz', nullable: false, default: 'now()' },
],
@@ -300,11 +255,7 @@ export const tableTemplates: Record = {
isPrimary: true,
default: 'gen_random_uuid()',
},
- {
- name: 'task_id',
- type: 'uuid',
- nullable: false,
- },
+ { name: 'task_id', type: 'uuid', nullable: false },
{ name: 'title', type: 'text', nullable: false },
{ name: 'completed', type: 'bool', nullable: false, default: 'false' },
{ name: 'position', type: 'int4', nullable: false, default: '0' },
@@ -325,11 +276,7 @@ export const tableTemplates: Record = {
isPrimary: true,
default: 'gen_random_uuid()',
},
- {
- name: 'user_id',
- type: 'uuid',
- nullable: true,
- },
+ { name: 'user_id', type: 'uuid', nullable: true },
{ name: 'session_id', type: 'text', nullable: true },
{ name: 'event_type', type: 'text', nullable: false },
{ name: 'properties', type: 'jsonb', nullable: true },
@@ -350,11 +297,7 @@ export const tableTemplates: Record = {
isPrimary: true,
default: 'gen_random_uuid()',
},
- {
- name: 'user_id',
- type: 'uuid',
- nullable: true,
- },
+ { name: 'user_id', type: 'uuid', nullable: true },
{ name: 'session_id', type: 'text', nullable: true },
{ name: 'path', type: 'text', nullable: false },
{ name: 'referrer', type: 'text', nullable: true },
diff --git a/apps/studio/components/layouts/Tabs/NewTab.tsx b/apps/studio/components/layouts/Tabs/NewTab.tsx
index 1eb98dc29eb..99dbe052b96 100644
--- a/apps/studio/components/layouts/Tabs/NewTab.tsx
+++ b/apps/studio/components/layouts/Tabs/NewTab.tsx
@@ -20,7 +20,7 @@ import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject'
import { usePHFlag } from 'hooks/ui/useFlag'
import { uuidv4 } from 'lib/helpers'
import { useProfile } from 'lib/profile'
-import { useAiAssistantStateSnapshot, AssistantMessageType } from 'state/ai-assistant-state'
+import { AssistantMessageType, useAiAssistantStateSnapshot } from 'state/ai-assistant-state'
import { useSqlEditorV2StateSnapshot } from 'state/sql-editor-v2'
import { useTableEditorStateSnapshot } from 'state/table-editor'
import { createTabId, useTabsStateSnapshot } from 'state/tabs'
diff --git a/apps/studio/data/__templates/resource-query.ts b/apps/studio/data/__templates/resource-query.ts
index 0f0b0501376..2aff5ed875c 100644
--- a/apps/studio/data/__templates/resource-query.ts
+++ b/apps/studio/data/__templates/resource-query.ts
@@ -33,14 +33,12 @@ export const useResourceQuery = (
{ projectRef, id }: ResourceVariables,
{ enabled = true, ...options }: UseQueryOptions = {}
) =>
- useQuery(
- resourceKeys.resource(projectRef, id),
- ({ signal }) => getResource({ projectRef, id }, signal),
- {
- enabled: enabled && typeof projectRef !== 'undefined' && typeof id !== 'undefined',
- ...options,
- }
- )
+ useQuery({
+ queryKey: resourceKeys.resource(projectRef, id),
+ queryFn: ({ signal }) => getResource({ projectRef, id }, signal),
+ enabled: enabled && typeof projectRef !== 'undefined' && typeof id !== 'undefined',
+ ...options,
+ })
/**
* useResourcePrefetch is used for prefetching data. For example, starting a query loading before a page is navigated to.
diff --git a/apps/studio/data/__templates/resource-update-mutation.ts b/apps/studio/data/__templates/resource-update-mutation.ts
index 0b8f26ff997..ef292042c98 100644
--- a/apps/studio/data/__templates/resource-update-mutation.ts
+++ b/apps/studio/data/__templates/resource-update-mutation.ts
@@ -34,27 +34,25 @@ export const useResourceUpdateMutation = ({
> = {}) => {
const queryClient = useQueryClient()
- return useMutation(
- (vars) => updateResource(vars),
- {
- async onSuccess(data, variables, context) {
- const { projectRef, id } = variables
+ return useMutation({
+ mutationFn: (vars) => updateResource(vars),
+ async onSuccess(data, variables, context) {
+ const { projectRef, id } = variables
- await Promise.all([
- queryClient.invalidateQueries(resourceKeys.list(projectRef)),
- queryClient.invalidateQueries(resourceKeys.resource(projectRef, id)),
- ])
+ await Promise.all([
+ queryClient.invalidateQueries(resourceKeys.list(projectRef)),
+ queryClient.invalidateQueries(resourceKeys.resource(projectRef, id)),
+ ])
- await onSuccess?.(data, variables, context)
- },
- async onError(data, variables, context) {
- if (onError === undefined) {
- toast.error(`Failed to mutate: ${data.message}`)
- } else {
- onError(data, variables, context)
- }
- },
- ...options,
- }
- )
+ await onSuccess?.(data, variables, context)
+ },
+ async onError(data, variables, context) {
+ if (onError === undefined) {
+ toast.error(`Failed to mutate: ${data.message}`)
+ } else {
+ onError(data, variables, context)
+ }
+ },
+ ...options,
+ })
}
diff --git a/apps/studio/data/__templates/resources-query.ts b/apps/studio/data/__templates/resources-query.ts
index 9d15bd55ee7..8e278b13018 100644
--- a/apps/studio/data/__templates/resources-query.ts
+++ b/apps/studio/data/__templates/resources-query.ts
@@ -28,11 +28,12 @@ export const useResourcesQuery = (
{ projectRef }: ResourcesVariables,
{ enabled = true, ...options }: UseQueryOptions = {}
) =>
- useQuery(
- resourceKeys.list(projectRef),
- ({ signal }) => getResources({ projectRef }, signal),
- { enabled: enabled && typeof projectRef !== 'undefined', ...options }
- )
+ useQuery({
+ queryKey: resourceKeys.list(projectRef),
+ queryFn: ({ signal }) => getResources({ projectRef }, signal),
+ enabled: enabled && typeof projectRef !== 'undefined',
+ ...options,
+ })
/**
* useResourcesPrefetch is used for prefetching data. For example, starting a query loading before a page is navigated to.
diff --git a/apps/studio/data/access-tokens/access-tokens-create-mutation.ts b/apps/studio/data/access-tokens/access-tokens-create-mutation.ts
index c4f2d182383..6a0990ebf4a 100644
--- a/apps/studio/data/access-tokens/access-tokens-create-mutation.ts
+++ b/apps/studio/data/access-tokens/access-tokens-create-mutation.ts
@@ -32,22 +32,20 @@ export const useAccessTokenCreateMutation = ({
> = {}) => {
const queryClient = useQueryClient()
- return useMutation(
- (vars) => createAccessToken(vars),
- {
- async onSuccess(data, variables, context) {
- await queryClient.invalidateQueries(accessTokenKeys.list())
+ return useMutation({
+ mutationFn: (vars) => createAccessToken(vars),
+ async onSuccess(data, variables, context) {
+ await queryClient.invalidateQueries(accessTokenKeys.list())
- await onSuccess?.(data, variables, context)
- },
- async onError(data, variables, context) {
- if (onError === undefined) {
- toast.error(`Failed to create access token: ${data.message}`)
- } else {
- onError(data, variables, context)
- }
- },
- ...options,
- }
- )
+ await onSuccess?.(data, variables, context)
+ },
+ async onError(data, variables, context) {
+ if (onError === undefined) {
+ toast.error(`Failed to create access token: ${data.message}`)
+ } else {
+ onError(data, variables, context)
+ }
+ },
+ ...options,
+ })
}
diff --git a/apps/studio/data/access-tokens/access-tokens-delete-mutation.ts b/apps/studio/data/access-tokens/access-tokens-delete-mutation.ts
index 8d536cd81a8..b4169903648 100644
--- a/apps/studio/data/access-tokens/access-tokens-delete-mutation.ts
+++ b/apps/studio/data/access-tokens/access-tokens-delete-mutation.ts
@@ -30,22 +30,20 @@ export const useAccessTokenDeleteMutation = ({
> = {}) => {
const queryClient = useQueryClient()
- return useMutation(
- (vars) => deleteAccessToken(vars),
- {
- async onSuccess(data, variables, context) {
- await queryClient.invalidateQueries(accessTokenKeys.list())
+ return useMutation({
+ mutationFn: (vars) => deleteAccessToken(vars),
+ async onSuccess(data, variables, context) {
+ await queryClient.invalidateQueries(accessTokenKeys.list())
- await onSuccess?.(data, variables, context)
- },
- async onError(data, variables, context) {
- if (onError === undefined) {
- toast.error(`Failed to delete access token: ${data.message}`)
- } else {
- onError(data, variables, context)
- }
- },
- ...options,
- }
- )
+ await onSuccess?.(data, variables, context)
+ },
+ async onError(data, variables, context) {
+ if (onError === undefined) {
+ toast.error(`Failed to delete access token: ${data.message}`)
+ } else {
+ onError(data, variables, context)
+ }
+ },
+ ...options,
+ })
}
diff --git a/apps/studio/data/access-tokens/access-tokens-query.ts b/apps/studio/data/access-tokens/access-tokens-query.ts
index 44deafedbbf..7e882a7a170 100644
--- a/apps/studio/data/access-tokens/access-tokens-query.ts
+++ b/apps/studio/data/access-tokens/access-tokens-query.ts
@@ -21,8 +21,8 @@ export const useAccessTokensQuery = ({
enabled = true,
...options
}: UseQueryOptions = {}) =>
- useQuery(
- accessTokenKeys.list(),
- ({ signal }) => getAccessTokens(signal),
- options
- )
+ useQuery({
+ queryKey: accessTokenKeys.list(),
+ queryFn: ({ signal }) => getAccessTokens(signal),
+ ...options,
+ })
diff --git a/apps/studio/data/actions/action-detail-query.ts b/apps/studio/data/actions/action-detail-query.ts
index 4e34849c78f..b2957ef8e5f 100644
--- a/apps/studio/data/actions/action-detail-query.ts
+++ b/apps/studio/data/actions/action-detail-query.ts
@@ -23,8 +23,10 @@ export const useActionRunQuery = (
{ ref, run_id }: ActionRunVariables,
{ enabled = true, ...options }: UseQueryOptions = {}
) =>
- useQuery(
- actionKeys.detail(ref, run_id),
- ({ signal }) => getActionRun({ ref, run_id }, signal),
- { enabled: enabled && Boolean(ref) && Boolean(run_id), staleTime: 0, ...options }
- )
+ useQuery({
+ queryKey: actionKeys.detail(ref, run_id),
+ queryFn: ({ signal }) => getActionRun({ ref, run_id }, signal),
+ enabled: enabled && Boolean(ref) && Boolean(run_id),
+ staleTime: 0,
+ ...options,
+ })
diff --git a/apps/studio/data/actions/action-logs-query.ts b/apps/studio/data/actions/action-logs-query.ts
index 218eed45a72..27270834def 100644
--- a/apps/studio/data/actions/action-logs-query.ts
+++ b/apps/studio/data/actions/action-logs-query.ts
@@ -29,8 +29,10 @@ export const useActionRunLogsQuery = (
{ ref, run_id }: ActionLogsVariables,
{ enabled = true, ...options }: UseQueryOptions = {}
) =>
- useQuery(
- actionKeys.detail(ref, run_id),
- ({ signal }) => getActionRunLogs({ ref, run_id }, signal),
- { enabled: enabled && Boolean(ref) && Boolean(run_id), staleTime: 0, ...options }
- )
+ useQuery({
+ queryKey: actionKeys.detail(ref, run_id),
+ queryFn: ({ signal }) => getActionRunLogs({ ref, run_id }, signal),
+ enabled: enabled && Boolean(ref) && Boolean(run_id),
+ staleTime: 0,
+ ...options,
+ })
diff --git a/apps/studio/data/actions/action-runs-query.ts b/apps/studio/data/actions/action-runs-query.ts
index d987fd3494d..64bf56e2a2e 100644
--- a/apps/studio/data/actions/action-runs-query.ts
+++ b/apps/studio/data/actions/action-runs-query.ts
@@ -27,8 +27,10 @@ export const useActionsQuery = (
{ ref }: ActionsVariables,
{ enabled = true, ...options }: UseQueryOptions = {}
) =>
- useQuery(
- actionKeys.list(ref),
- ({ signal }) => listActionRuns({ ref }, signal),
- { enabled: enabled && Boolean(ref), staleTime: 0, ...options }
- )
+ useQuery({
+ queryKey: actionKeys.list(ref),
+ queryFn: ({ signal }) => listActionRuns({ ref }, signal),
+ enabled: enabled && Boolean(ref),
+ staleTime: 0,
+ ...options,
+ })
diff --git a/apps/studio/data/ai/check-api-key-query.ts b/apps/studio/data/ai/check-api-key-query.ts
index 01c78a9af6a..f0c9c61b58d 100644
--- a/apps/studio/data/ai/check-api-key-query.ts
+++ b/apps/studio/data/ai/check-api-key-query.ts
@@ -34,8 +34,9 @@ export const useCheckOpenAIKeyQuery = ({
enabled = true,
...options
}: UseQueryOptions = {}) =>
- useQuery(
- aiKeys.apiKey(),
- ({ signal }) => checkOpenAIKey(signal),
- { enabled: !IS_PLATFORM && enabled, ...options }
- )
+ useQuery({
+ queryKey: aiKeys.apiKey(),
+ queryFn: ({ signal }) => checkOpenAIKey(signal),
+ enabled: !IS_PLATFORM && enabled,
+ ...options,
+ })
diff --git a/apps/studio/data/ai/rate-message-mutation.ts b/apps/studio/data/ai/rate-message-mutation.ts
index 923943e6cfe..8f9907723cf 100644
--- a/apps/studio/data/ai/rate-message-mutation.ts
+++ b/apps/studio/data/ai/rate-message-mutation.ts
@@ -55,20 +55,18 @@ export const useRateMessageMutation = ({
UseMutationOptions,
'mutationFn'
> = {}) => {
- return useMutation(
- (vars) => rateMessage(vars),
- {
- async onSuccess(data, variables, context) {
- await onSuccess?.(data, variables, context)
- },
- async onError(data, variables, context) {
- if (onError === undefined) {
- console.error(`Failed to rate message: ${data.message}`)
- } else {
- onError(data, variables, context)
- }
- },
- ...options,
- }
- )
+ return useMutation({
+ mutationFn: (vars) => rateMessage(vars),
+ async onSuccess(data, variables, context) {
+ await onSuccess?.(data, variables, context)
+ },
+ async onError(data, variables, context) {
+ if (onError === undefined) {
+ console.error(`Failed to rate message: ${data.message}`)
+ } else {
+ onError(data, variables, context)
+ }
+ },
+ ...options,
+ })
}
diff --git a/apps/studio/data/ai/sql-cron-mutation.ts b/apps/studio/data/ai/sql-cron-mutation.ts
index 057dfe826ab..c9c636b0568 100644
--- a/apps/studio/data/ai/sql-cron-mutation.ts
+++ b/apps/studio/data/ai/sql-cron-mutation.ts
@@ -44,20 +44,18 @@ export const useSqlCronGenerateMutation = ({
UseMutationOptions,
'mutationFn'
> = {}) => {
- return useMutation(
- (vars) => generateSqlCron(vars),
- {
- async onSuccess(data, variables, context) {
- await onSuccess?.(data, variables, context)
- },
- async onError(data, variables, context) {
- if (onError === undefined) {
- toast.error(`Failed to generate cron expression: ${data.message}`)
- } else {
- onError(data, variables, context)
- }
- },
- ...options,
- }
- )
+ return useMutation({
+ mutationFn: (vars) => generateSqlCron(vars),
+ async onSuccess(data, variables, context) {
+ await onSuccess?.(data, variables, context)
+ },
+ async onError(data, variables, context) {
+ if (onError === undefined) {
+ toast.error(`Failed to generate cron expression: ${data.message}`)
+ } else {
+ onError(data, variables, context)
+ }
+ },
+ ...options,
+ })
}
diff --git a/apps/studio/data/ai/sql-title-mutation.ts b/apps/studio/data/ai/sql-title-mutation.ts
index 45147665d94..a5bf4c95044 100644
--- a/apps/studio/data/ai/sql-title-mutation.ts
+++ b/apps/studio/data/ai/sql-title-mutation.ts
@@ -48,20 +48,18 @@ export const useSqlTitleGenerateMutation = ({
UseMutationOptions,
'mutationFn'
> = {}) => {
- return useMutation(
- (vars) => generateSqlTitle(vars),
- {
- async onSuccess(data, variables, context) {
- await onSuccess?.(data, variables, context)
- },
- async onError(data, variables, context) {
- if (onError === undefined) {
- toast.error(`Failed to generate title: ${data.message}`)
- } else {
- onError(data, variables, context)
- }
- },
- ...options,
- }
- )
+ return useMutation({
+ mutationFn: (vars) => generateSqlTitle(vars),
+ async onSuccess(data, variables, context) {
+ await onSuccess?.(data, variables, context)
+ },
+ async onError(data, variables, context) {
+ if (onError === undefined) {
+ toast.error(`Failed to generate title: ${data.message}`)
+ } else {
+ onError(data, variables, context)
+ }
+ },
+ ...options,
+ })
}
diff --git a/apps/studio/data/analytics/functions-combined-stats-query.ts b/apps/studio/data/analytics/functions-combined-stats-query.ts
index edb4c095162..c9fa6f38103 100644
--- a/apps/studio/data/analytics/functions-combined-stats-query.ts
+++ b/apps/studio/data/analytics/functions-combined-stats-query.ts
@@ -56,15 +56,14 @@ export const useFunctionsCombinedStatsQuery = = {}
) =>
- useQuery(
- analyticsKeys.functionsCombinedStats(projectRef, { functionId, interval }),
- ({ signal }) => getFunctionsCombinedStats({ projectRef, functionId, interval }, signal),
- {
- enabled:
- enabled &&
- typeof projectRef !== 'undefined' &&
- typeof functionId !== 'undefined' &&
- typeof interval !== 'undefined',
- ...options,
- }
- )
+ useQuery({
+ queryKey: analyticsKeys.functionsCombinedStats(projectRef, { functionId, interval }),
+ queryFn: ({ signal }) =>
+ getFunctionsCombinedStats({ projectRef, functionId, interval }, signal),
+ enabled:
+ enabled &&
+ typeof projectRef !== 'undefined' &&
+ typeof functionId !== 'undefined' &&
+ typeof interval !== 'undefined',
+ ...options,
+ })
diff --git a/apps/studio/data/analytics/functions-req-stats-query.ts b/apps/studio/data/analytics/functions-req-stats-query.ts
index 5a765b4148f..0b974c4b12d 100644
--- a/apps/studio/data/analytics/functions-req-stats-query.ts
+++ b/apps/studio/data/analytics/functions-req-stats-query.ts
@@ -56,15 +56,13 @@ export const useFunctionsReqStatsQuery = (
...options
}: UseQueryOptions = {}
) =>
- useQuery(
- analyticsKeys.functionsReqStats(projectRef, { functionId, interval }),
- ({ signal }) => getFunctionsReqStats({ projectRef, functionId, interval }, signal),
- {
- enabled:
- enabled &&
- typeof projectRef !== 'undefined' &&
- typeof functionId !== 'undefined' &&
- typeof interval !== 'undefined',
- ...options,
- }
- )
+ useQuery({
+ queryKey: analyticsKeys.functionsReqStats(projectRef, { functionId, interval }),
+ queryFn: ({ signal }) => getFunctionsReqStats({ projectRef, functionId, interval }, signal),
+ enabled:
+ enabled &&
+ typeof projectRef !== 'undefined' &&
+ typeof functionId !== 'undefined' &&
+ typeof interval !== 'undefined',
+ ...options,
+ })
diff --git a/apps/studio/data/analytics/functions-resource-usage-query.ts b/apps/studio/data/analytics/functions-resource-usage-query.ts
index ae767d52ebb..45d8d1a4f81 100644
--- a/apps/studio/data/analytics/functions-resource-usage-query.ts
+++ b/apps/studio/data/analytics/functions-resource-usage-query.ts
@@ -56,15 +56,14 @@ export const useFunctionsResourceUsageQuery = = {}
) =>
- useQuery(
- analyticsKeys.functionsResourceUsage(projectRef, { functionId, interval }),
- ({ signal }) => getFunctionsResourceUsage({ projectRef, functionId, interval }, signal),
- {
- enabled:
- enabled &&
- typeof projectRef !== 'undefined' &&
- typeof functionId !== 'undefined' &&
- typeof interval !== 'undefined',
- ...options,
- }
- )
+ useQuery({
+ queryKey: analyticsKeys.functionsResourceUsage(projectRef, { functionId, interval }),
+ queryFn: ({ signal }) =>
+ getFunctionsResourceUsage({ projectRef, functionId, interval }, signal),
+ enabled:
+ enabled &&
+ typeof projectRef !== 'undefined' &&
+ typeof functionId !== 'undefined' &&
+ typeof interval !== 'undefined',
+ ...options,
+ })
diff --git a/apps/studio/data/analytics/infra-monitoring-query.ts b/apps/studio/data/analytics/infra-monitoring-query.ts
index 00f607522d8..e57ecc3a507 100644
--- a/apps/studio/data/analytics/infra-monitoring-query.ts
+++ b/apps/studio/data/analytics/infra-monitoring-query.ts
@@ -78,40 +78,38 @@ export const useInfraMonitoringQuery = (
...options
}: UseQueryOptions = {}
) =>
- useQuery(
- analyticsKeys.infraMonitoring(projectRef, {
+ useQuery({
+ queryKey: analyticsKeys.infraMonitoring(projectRef, {
attribute,
startDate,
endDate,
interval,
databaseIdentifier,
}),
- ({ signal }) =>
+ queryFn: ({ signal }) =>
getInfraMonitoring(
{ projectRef, attribute, startDate, endDate, interval, databaseIdentifier },
signal
),
- {
- enabled:
- enabled &&
- typeof projectRef !== 'undefined' &&
- typeof attribute !== 'undefined' &&
- typeof startDate !== 'undefined' &&
- typeof endDate !== 'undefined',
- select(data) {
- return {
- ...data,
- data: data.data.map((x) => {
- return {
- ...x,
- [attribute]:
- modifier !== undefined ? modifier(Number(x[attribute])) : Number(x[attribute]),
- periodStartFormatted: dayjs(x.period_start).format(dateFormat),
- }
- }),
- } as TData
- },
- staleTime: 1000 * 60, // default good for a minute
- ...options,
- }
- )
+ enabled:
+ enabled &&
+ typeof projectRef !== 'undefined' &&
+ typeof attribute !== 'undefined' &&
+ typeof startDate !== 'undefined' &&
+ typeof endDate !== 'undefined',
+ select(data) {
+ return {
+ ...data,
+ data: data.data.map((x) => {
+ return {
+ ...x,
+ [attribute]:
+ modifier !== undefined ? modifier(Number(x[attribute])) : Number(x[attribute]),
+ periodStartFormatted: dayjs(x.period_start).format(dateFormat),
+ }
+ }),
+ } as TData
+ },
+ staleTime: 1000 * 60,
+ ...options,
+ })
diff --git a/apps/studio/data/analytics/org-daily-stats-query.ts b/apps/studio/data/analytics/org-daily-stats-query.ts
index db4fd96f2ac..ae80bcf4c06 100644
--- a/apps/studio/data/analytics/org-daily-stats-query.ts
+++ b/apps/studio/data/analytics/org-daily-stats-query.ts
@@ -151,16 +151,14 @@ export const useOrgDailyStatsQuery = (
{ orgSlug, startDate, endDate, projectRef }: OrgDailyStatsVariables,
{ enabled = true, ...options }: UseQueryOptions = {}
) =>
- useQuery(
- analyticsKeys.orgDailyStats(orgSlug, { startDate, endDate, projectRef }),
- ({ signal }) => getOrgDailyStats({ orgSlug, startDate, endDate, projectRef }, signal),
- {
- enabled:
- enabled &&
- typeof orgSlug !== 'undefined' &&
- typeof startDate !== 'undefined' &&
- typeof endDate !== 'undefined',
- staleTime: 1000 * 60 * 60, // default good for an hour for now
- ...options,
- }
- )
+ useQuery({
+ queryKey: analyticsKeys.orgDailyStats(orgSlug, { startDate, endDate, projectRef }),
+ queryFn: ({ signal }) => getOrgDailyStats({ orgSlug, startDate, endDate, projectRef }, signal),
+ enabled:
+ enabled &&
+ typeof orgSlug !== 'undefined' &&
+ typeof startDate !== 'undefined' &&
+ typeof endDate !== 'undefined',
+ staleTime: 1000 * 60 * 60,
+ ...options,
+ })
diff --git a/apps/studio/data/analytics/project-daily-stats-query.ts b/apps/studio/data/analytics/project-daily-stats-query.ts
index f8bda24d301..610a87397ca 100644
--- a/apps/studio/data/analytics/project-daily-stats-query.ts
+++ b/apps/studio/data/analytics/project-daily-stats-query.ts
@@ -50,21 +50,20 @@ export const useProjectDailyStatsQuery = (
...options
}: UseQueryOptions = {}
) =>
- useQuery(
- analyticsKeys.infraMonitoring(projectRef, {
+ useQuery({
+ queryKey: analyticsKeys.infraMonitoring(projectRef, {
attribute,
startDate,
endDate,
}),
- ({ signal }) => getProjectDailyStats({ projectRef, attribute, startDate, endDate }, signal),
- {
- enabled:
- enabled &&
- typeof projectRef !== 'undefined' &&
- typeof attribute !== 'undefined' &&
- typeof startDate !== 'undefined' &&
- typeof endDate !== 'undefined',
- staleTime: 1000 * 60 * 30, // default good for 30m, stats only refresh once a day
- ...options,
- }
- )
+ queryFn: ({ signal }) =>
+ getProjectDailyStats({ projectRef, attribute, startDate, endDate }, signal),
+ enabled:
+ enabled &&
+ typeof projectRef !== 'undefined' &&
+ typeof attribute !== 'undefined' &&
+ typeof startDate !== 'undefined' &&
+ typeof endDate !== 'undefined',
+ staleTime: 1000 * 60 * 30,
+ ...options,
+ })
diff --git a/apps/studio/data/analytics/project-log-requests-count-query.ts b/apps/studio/data/analytics/project-log-requests-count-query.ts
index 0d6e5b5863d..8898c8a227a 100644
--- a/apps/studio/data/analytics/project-log-requests-count-query.ts
+++ b/apps/studio/data/analytics/project-log-requests-count-query.ts
@@ -40,14 +40,12 @@ export const useProjectLogRequestsCountQuery = = {}
) =>
- useQuery(
- analyticsKeys.usageApiRequestsCount(projectRef),
- ({ signal }) => getProjectLogRequestsCountStats({ projectRef }, signal),
- {
- enabled: enabled && typeof projectRef !== 'undefined',
- ...options,
- }
- )
+ useQuery({
+ queryKey: analyticsKeys.usageApiRequestsCount(projectRef),
+ queryFn: ({ signal }) => getProjectLogRequestsCountStats({ projectRef }, signal),
+ enabled: enabled && typeof projectRef !== 'undefined',
+ ...options,
+ })
export function prefetchProjectLogRequestsCount(
client: QueryClient,
diff --git a/apps/studio/data/analytics/project-log-stats-query.ts b/apps/studio/data/analytics/project-log-stats-query.ts
index 76167f33d9e..be3379ef521 100644
--- a/apps/studio/data/analytics/project-log-stats-query.ts
+++ b/apps/studio/data/analytics/project-log-stats-query.ts
@@ -60,14 +60,12 @@ export const useProjectLogStatsQuery = (
...options
}: UseQueryOptions = {}
) =>
- useQuery(
- analyticsKeys.usageApiCounts(projectRef, interval),
- ({ signal }) => getProjectLogStats({ projectRef, interval }, signal),
- {
- enabled: enabled && typeof projectRef !== 'undefined' && typeof interval !== 'undefined',
- ...options,
- }
- )
+ useQuery({
+ queryKey: analyticsKeys.usageApiCounts(projectRef, interval),
+ queryFn: ({ signal }) => getProjectLogStats({ projectRef, interval }, signal),
+ enabled: enabled && typeof projectRef !== 'undefined' && typeof interval !== 'undefined',
+ ...options,
+ })
export function prefetchProjectLogStats(
client: QueryClient,
diff --git a/apps/studio/data/api-authorization/api-authorization-approve-mutation.ts b/apps/studio/data/api-authorization/api-authorization-approve-mutation.ts
index 56f52c2eafe..832c71149b5 100644
--- a/apps/studio/data/api-authorization/api-authorization-approve-mutation.ts
+++ b/apps/studio/data/api-authorization/api-authorization-approve-mutation.ts
@@ -36,17 +36,15 @@ export const useApiAuthorizationApproveMutation = ({
UseMutationOptions,
'mutationFn'
> = {}) => {
- return useMutation(
- (vars) => approveApiAuthorization(vars),
- {
- async onError(data, variables, context) {
- if (onError === undefined) {
- toast.error(`Failed to approve authorization request: ${data.message}`)
- } else {
- onError(data, variables, context)
- }
- },
- ...options,
- }
- )
+ return useMutation({
+ mutationFn: (vars) => approveApiAuthorization(vars),
+ async onError(data, variables, context) {
+ if (onError === undefined) {
+ toast.error(`Failed to approve authorization request: ${data.message}`)
+ } else {
+ onError(data, variables, context)
+ }
+ },
+ ...options,
+ })
}
diff --git a/apps/studio/data/api-authorization/api-authorization-decline-mutation.ts b/apps/studio/data/api-authorization/api-authorization-decline-mutation.ts
index 7976a7d94af..bf1eec660ec 100644
--- a/apps/studio/data/api-authorization/api-authorization-decline-mutation.ts
+++ b/apps/studio/data/api-authorization/api-authorization-decline-mutation.ts
@@ -35,17 +35,15 @@ export const useApiAuthorizationDeclineMutation = ({
UseMutationOptions,
'mutationFn'
> = {}) => {
- return useMutation(
- (vars) => declineApiAuthorization(vars),
- {
- async onError(data, variables, context) {
- if (onError === undefined) {
- toast.error(`Failed to decline authorization request: ${data.message}`)
- } else {
- onError(data, variables, context)
- }
- },
- ...options,
- }
- )
+ return useMutation({
+ mutationFn: (vars) => declineApiAuthorization(vars),
+ async onError(data, variables, context) {
+ if (onError === undefined) {
+ toast.error(`Failed to decline authorization request: ${data.message}`)
+ } else {
+ onError(data, variables, context)
+ }
+ },
+ ...options,
+ })
}
diff --git a/apps/studio/data/api-authorization/api-authorization-query.ts b/apps/studio/data/api-authorization/api-authorization-query.ts
index 37d0f58356c..bfe1f9a7cc6 100644
--- a/apps/studio/data/api-authorization/api-authorization-query.ts
+++ b/apps/studio/data/api-authorization/api-authorization-query.ts
@@ -42,11 +42,9 @@ export const useApiAuthorizationQuery = (
{ id }: ApiAuthorizationVariables,
{ enabled = true, ...options }: UseQueryOptions = {}
) =>
- useQuery(
- resourceKeys.resource(id),
- ({ signal }) => getApiAuthorizationDetails({ id }, signal),
- {
- enabled: enabled && typeof id !== 'undefined',
- ...options,
- }
- )
+ useQuery({
+ queryKey: resourceKeys.resource(id),
+ queryFn: ({ signal }) => getApiAuthorizationDetails({ id }, signal),
+ enabled: enabled && typeof id !== 'undefined',
+ ...options,
+ })
diff --git a/apps/studio/data/api-keys/[id]/api-key-id-query.ts b/apps/studio/data/api-keys/[id]/api-key-id-query.ts
index 06aae547d13..87ab4073ae8 100644
--- a/apps/studio/data/api-keys/[id]/api-key-id-query.ts
+++ b/apps/studio/data/api-keys/[id]/api-key-id-query.ts
@@ -37,11 +37,9 @@ export const useAPIKeyIdQuery = (
{ projectRef, id, reveal }: APIKeyVariables,
{ enabled = true, ...options }: UseQueryOptions = {}
) =>
- useQuery(
- apiKeysKeys.single(projectRef, id),
- ({ signal }) => getAPIKeysById({ projectRef, id, reveal }, signal),
- {
- enabled: enabled && typeof projectRef !== 'undefined' && typeof id !== 'undefined',
- ...options,
- }
- )
+ useQuery({
+ queryKey: apiKeysKeys.single(projectRef, id),
+ queryFn: ({ signal }) => getAPIKeysById({ projectRef, id, reveal }, signal),
+ enabled: enabled && typeof projectRef !== 'undefined' && typeof id !== 'undefined',
+ ...options,
+ })
diff --git a/apps/studio/data/api-keys/[id]/api-key-id-update-mutation.ts b/apps/studio/data/api-keys/[id]/api-key-id-update-mutation.ts
index 18751a12448..05cee5366a8 100644
--- a/apps/studio/data/api-keys/[id]/api-key-id-update-mutation.ts
+++ b/apps/studio/data/api-keys/[id]/api-key-id-update-mutation.ts
@@ -47,24 +47,22 @@ export const useResourceUpdateMutation = ({
> = {}) => {
const queryClient = useQueryClient()
- return useMutation(
- (vars) => updateAPIKeysById(vars),
- {
- async onSuccess(data, variables, context) {
- const { projectRef, id } = variables
+ return useMutation({
+ mutationFn: (vars) => updateAPIKeysById(vars),
+ async onSuccess(data, variables, context) {
+ const { projectRef, id } = variables
- await queryClient.invalidateQueries(apiKeysKeys.list(projectRef))
+ await queryClient.invalidateQueries(apiKeysKeys.list(projectRef))
- await onSuccess?.(data, variables, context)
- },
- async onError(data, variables, context) {
- if (onError === undefined) {
- toast.error(`Failed to mutate: ${data.message}`)
- } else {
- onError(data, variables, context)
- }
- },
- ...options,
- }
- )
+ await onSuccess?.(data, variables, context)
+ },
+ async onError(data, variables, context) {
+ if (onError === undefined) {
+ toast.error(`Failed to mutate: ${data.message}`)
+ } else {
+ onError(data, variables, context)
+ }
+ },
+ ...options,
+ })
}
diff --git a/apps/studio/data/api-keys/api-key-create-mutation.ts b/apps/studio/data/api-keys/api-key-create-mutation.ts
index f84d56055ec..b5838231537 100644
--- a/apps/studio/data/api-keys/api-key-create-mutation.ts
+++ b/apps/studio/data/api-keys/api-key-create-mutation.ts
@@ -63,24 +63,22 @@ export const useAPIKeyCreateMutation = ({
> = {}) => {
const queryClient = useQueryClient()
- return useMutation(
- (vars) => createAPIKey(vars),
- {
- async onSuccess(data, variables, context) {
- const { projectRef } = variables
+ return useMutation({
+ mutationFn: (vars) => createAPIKey(vars),
+ async onSuccess(data, variables, context) {
+ const { projectRef } = variables
- await queryClient.invalidateQueries(apiKeysKeys.list(projectRef))
+ await queryClient.invalidateQueries(apiKeysKeys.list(projectRef))
- await onSuccess?.(data, variables, context)
- },
- async onError(data, variables, context) {
- if (onError === undefined) {
- toast.error(`Failed to create API key: ${data.message}`)
- } else {
- onError(data, variables, context)
- }
- },
- ...options,
- }
- )
+ await onSuccess?.(data, variables, context)
+ },
+ async onError(data, variables, context) {
+ if (onError === undefined) {
+ toast.error(`Failed to create API key: ${data.message}`)
+ } else {
+ onError(data, variables, context)
+ }
+ },
+ ...options,
+ })
}
diff --git a/apps/studio/data/api-keys/api-key-delete-mutation.ts b/apps/studio/data/api-keys/api-key-delete-mutation.ts
index 0625eab78d0..d85ab96687f 100644
--- a/apps/studio/data/api-keys/api-key-delete-mutation.ts
+++ b/apps/studio/data/api-keys/api-key-delete-mutation.ts
@@ -35,24 +35,22 @@ export const useAPIKeyDeleteMutation = ({
> = {}) => {
const queryClient = useQueryClient()
- return useMutation(
- (vars) => deleteAPIKey(vars),
- {
- async onSuccess(data, variables, context) {
- const { projectRef } = variables
+ return useMutation({
+ mutationFn: (vars) => deleteAPIKey(vars),
+ async onSuccess(data, variables, context) {
+ const { projectRef } = variables
- await queryClient.invalidateQueries(apiKeysKeys.list(projectRef))
+ await queryClient.invalidateQueries(apiKeysKeys.list(projectRef))
- await onSuccess?.(data, variables, context)
- },
- async onError(data, variables, context) {
- if (onError === undefined) {
- toast.error(`Failed to delete API key: ${data.message}`)
- } else {
- onError(data, variables, context)
- }
- },
- ...options,
- }
- )
+ await onSuccess?.(data, variables, context)
+ },
+ async onError(data, variables, context) {
+ if (onError === undefined) {
+ toast.error(`Failed to delete API key: ${data.message}`)
+ } else {
+ onError(data, variables, context)
+ }
+ },
+ ...options,
+ })
}
diff --git a/apps/studio/data/api-keys/api-keys-query.ts b/apps/studio/data/api-keys/api-keys-query.ts
index 5b746e88be7..596ae00710b 100644
--- a/apps/studio/data/api-keys/api-keys-query.ts
+++ b/apps/studio/data/api-keys/api-keys-query.ts
@@ -70,14 +70,12 @@ export const useAPIKeysQuery = (
{ projectRef, reveal = false }: APIKeysVariables,
{ enabled = true, ...options }: UseQueryOptions = {}
) => {
- return useQuery(
- apiKeysKeys.list(projectRef, reveal),
- ({ signal }) => getAPIKeys({ projectRef, reveal }, signal),
- {
- enabled: enabled && typeof projectRef !== 'undefined',
- ...options,
- }
- )
+ return useQuery({
+ queryKey: apiKeysKeys.list(projectRef, reveal),
+ queryFn: ({ signal }) => getAPIKeys({ projectRef, reveal }, signal),
+ enabled: enabled && typeof projectRef !== 'undefined',
+ ...options,
+ })
}
export const getKeys = (apiKeys: APIKey[] = []) => {
diff --git a/apps/studio/data/api-keys/legacy-api-key-toggle-mutation.ts b/apps/studio/data/api-keys/legacy-api-key-toggle-mutation.ts
index 0f0a07c43e3..fc2a370a606 100644
--- a/apps/studio/data/api-keys/legacy-api-key-toggle-mutation.ts
+++ b/apps/studio/data/api-keys/legacy-api-key-toggle-mutation.ts
@@ -35,26 +35,24 @@ export const useToggleLegacyAPIKeysMutation = ({
> = {}) => {
const queryClient = useQueryClient()
- return useMutation(
- (vars) => toggleLegacyAPIKeys(vars),
- {
- async onSuccess(data, variables, context) {
- const { projectRef } = variables
+ return useMutation({
+ mutationFn: (vars) => toggleLegacyAPIKeys(vars),
+ async onSuccess(data, variables, context) {
+ const { projectRef } = variables
- await queryClient.invalidateQueries(apiKeysKeys.status(projectRef))
+ await queryClient.invalidateQueries(apiKeysKeys.status(projectRef))
- await onSuccess?.(data, variables, context)
- },
- async onError(data, variables, context) {
- if (onError === undefined) {
- toast.error(
- `Failed to ${variables.enabled ? 're-enable' : 'disable'} JWT-based API keys: ${data.message}`
- )
- } else {
- onError(data, variables, context)
- }
- },
- ...options,
- }
- )
+ await onSuccess?.(data, variables, context)
+ },
+ async onError(data, variables, context) {
+ if (onError === undefined) {
+ toast.error(
+ `Failed to ${variables.enabled ? 're-enable' : 'disable'} JWT-based API keys: ${data.message}`
+ )
+ } else {
+ onError(data, variables, context)
+ }
+ },
+ ...options,
+ })
}
diff --git a/apps/studio/data/api-keys/legacy-api-keys-status-query.ts b/apps/studio/data/api-keys/legacy-api-keys-status-query.ts
index 73f509780f1..9d314ea5407 100644
--- a/apps/studio/data/api-keys/legacy-api-keys-status-query.ts
+++ b/apps/studio/data/api-keys/legacy-api-keys-status-query.ts
@@ -33,11 +33,9 @@ export const useLegacyAPIKeysStatusQuery = (
...options
}: UseQueryOptions = {}
) =>
- useQuery(
- apiKeysKeys.status(projectRef),
- ({ signal }) => getLegacyAPIKeysStatus({ projectRef }, signal),
- {
- enabled: IS_PLATFORM && enabled && typeof projectRef !== 'undefined',
- ...options,
- }
- )
+ useQuery({
+ queryKey: apiKeysKeys.status(projectRef),
+ queryFn: ({ signal }) => getLegacyAPIKeysStatus({ projectRef }, signal),
+ enabled: IS_PLATFORM && enabled && typeof projectRef !== 'undefined',
+ ...options,
+ })
diff --git a/apps/studio/data/api-settings/create-and-expose-api-schema-mutation.ts b/apps/studio/data/api-settings/create-and-expose-api-schema-mutation.ts
index c3f2f2c0b53..60946310a34 100644
--- a/apps/studio/data/api-settings/create-and-expose-api-schema-mutation.ts
+++ b/apps/studio/data/api-settings/create-and-expose-api-schema-mutation.ts
@@ -65,7 +65,8 @@ export const useCreateAndExposeAPISchemaMutation = ({
CreateAndExposeAPISchemaData,
ResponseError,
CreateAndExposeAPISchemaVariables
- >((vars) => createAndExposeApiSchema(vars), {
+ >({
+ mutationFn: (vars) => createAndExposeApiSchema(vars),
async onSuccess(data, variables, context) {
const { projectRef } = variables
await Promise.all([
diff --git a/apps/studio/data/auth/auth-config-query.ts b/apps/studio/data/auth/auth-config-query.ts
index 337b30f4bac..9d84e0634df 100644
--- a/apps/studio/data/auth/auth-config-query.ts
+++ b/apps/studio/data/auth/auth-config-query.ts
@@ -37,14 +37,12 @@ export const useAuthConfigQuery = (
...options
}: UseQueryOptions = {}
) =>
- useQuery(
- authKeys.authConfig(projectRef),
- ({ signal }) => getProjectAuthConfig({ projectRef }, signal),
- {
- enabled: enabled && IS_PLATFORM && typeof projectRef !== 'undefined',
- ...options,
- }
- )
+ useQuery({
+ queryKey: authKeys.authConfig(projectRef),
+ queryFn: ({ signal }) => getProjectAuthConfig({ projectRef }, signal),
+ enabled: enabled && IS_PLATFORM && typeof projectRef !== 'undefined',
+ ...options,
+ })
export const useAuthConfigPrefetch = ({ projectRef }: AuthConfigVariables) => {
const client = useQueryClient()
diff --git a/apps/studio/data/auth/auth-config-update-mutation.ts b/apps/studio/data/auth/auth-config-update-mutation.ts
index 6d4e1597983..019bfe1699a 100644
--- a/apps/studio/data/auth/auth-config-update-mutation.ts
+++ b/apps/studio/data/auth/auth-config-update-mutation.ts
@@ -37,22 +37,20 @@ export const useAuthConfigUpdateMutation = ({
> = {}) => {
const queryClient = useQueryClient()
- return useMutation(
- (vars) => updateAuthConfig(vars),
- {
- async onSuccess(data, variables, context) {
- const { projectRef } = variables
- await queryClient.invalidateQueries(authKeys.authConfig(projectRef))
- await onSuccess?.(data, variables, context)
- },
- async onError(data, variables, context) {
- if (onError === undefined) {
- toast.error(`Failed to update auth configuration: ${data.message}`)
- } else {
- onError(data, variables, context)
- }
- },
- ...options,
- }
- )
+ return useMutation({
+ mutationFn: (vars) => updateAuthConfig(vars),
+ async onSuccess(data, variables, context) {
+ const { projectRef } = variables
+ await queryClient.invalidateQueries(authKeys.authConfig(projectRef))
+ await onSuccess?.(data, variables, context)
+ },
+ async onError(data, variables, context) {
+ if (onError === undefined) {
+ toast.error(`Failed to update auth configuration: ${data.message}`)
+ } else {
+ onError(data, variables, context)
+ }
+ },
+ ...options,
+ })
}
diff --git a/apps/studio/data/auth/auth-hooks-update-mutation.ts b/apps/studio/data/auth/auth-hooks-update-mutation.ts
index 8b8ebecffe6..535901a9615 100644
--- a/apps/studio/data/auth/auth-hooks-update-mutation.ts
+++ b/apps/studio/data/auth/auth-hooks-update-mutation.ts
@@ -33,22 +33,20 @@ export const useAuthHooksUpdateMutation = ({
> = {}) => {
const queryClient = useQueryClient()
- return useMutation(
- (vars) => updateAuthHooks(vars),
- {
- async onSuccess(data, variables, context) {
- const { projectRef } = variables
- await queryClient.invalidateQueries(authKeys.authConfig(projectRef))
- await onSuccess?.(data, variables, context)
- },
- async onError(data, variables, context) {
- if (onError === undefined) {
- toast.error(`Failed to update auth hooks: ${data.message}`)
- } else {
- onError(data, variables, context)
- }
- },
- ...options,
- }
- )
+ return useMutation({
+ mutationFn: (vars) => updateAuthHooks(vars),
+ async onSuccess(data, variables, context) {
+ const { projectRef } = variables
+ await queryClient.invalidateQueries(authKeys.authConfig(projectRef))
+ await onSuccess?.(data, variables, context)
+ },
+ async onError(data, variables, context) {
+ if (onError === undefined) {
+ toast.error(`Failed to update auth hooks: ${data.message}`)
+ } else {
+ onError(data, variables, context)
+ }
+ },
+ ...options,
+ })
}
diff --git a/apps/studio/data/auth/session-access-token-query.ts b/apps/studio/data/auth/session-access-token-query.ts
index 095a57d48fa..c5f042e1288 100644
--- a/apps/studio/data/auth/session-access-token-query.ts
+++ b/apps/studio/data/auth/session-access-token-query.ts
@@ -22,8 +22,8 @@ export const useSessionAccessTokenQuery = ({
enabled = true,
...options
}: UseQueryOptions = {}) =>
- useQuery(
- authKeys.accessToken(),
- () => getSessionAccessToken(),
- options
- )
+ useQuery({
+ queryKey: authKeys.accessToken(),
+ queryFn: () => getSessionAccessToken(),
+ ...options,
+ })
diff --git a/apps/studio/data/auth/user-create-mutation.ts b/apps/studio/data/auth/user-create-mutation.ts
index 533c8e2df41..1db52c575a9 100644
--- a/apps/studio/data/auth/user-create-mutation.ts
+++ b/apps/studio/data/auth/user-create-mutation.ts
@@ -39,24 +39,22 @@ export const useUserCreateMutation = ({
> = {}) => {
const queryClient = useQueryClient()
- return useMutation(
- (vars) => createUser(vars),
- {
- async onSuccess(data, variables, context) {
- const { projectRef } = variables
+ return useMutation({
+ mutationFn: (vars) => createUser(vars),
+ async onSuccess(data, variables, context) {
+ const { projectRef } = variables
- await Promise.all([queryClient.invalidateQueries(authKeys.usersInfinite(projectRef))])
+ await Promise.all([queryClient.invalidateQueries(authKeys.usersInfinite(projectRef))])
- await onSuccess?.(data, variables, context)
- },
- async onError(data, variables, context) {
- if (onError === undefined) {
- toast.error(`Failed to create user: ${data.message}`)
- } else {
- onError(data, variables, context)
- }
- },
- ...options,
- }
- )
+ await onSuccess?.(data, variables, context)
+ },
+ async onError(data, variables, context) {
+ if (onError === undefined) {
+ toast.error(`Failed to create user: ${data.message}`)
+ } else {
+ onError(data, variables, context)
+ }
+ },
+ ...options,
+ })
}
diff --git a/apps/studio/data/auth/user-delete-mfa-factors-mutation.ts b/apps/studio/data/auth/user-delete-mfa-factors-mutation.ts
index 149952ad71a..7ae5937528b 100644
--- a/apps/studio/data/auth/user-delete-mfa-factors-mutation.ts
+++ b/apps/studio/data/auth/user-delete-mfa-factors-mutation.ts
@@ -29,21 +29,19 @@ export const useUserDeleteMFAFactorsMutation = ({
UseMutationOptions,
'mutationFn'
> = {}) => {
- return useMutation(
- (vars) => deleteMFAFactors(vars),
- {
- async onSuccess(data, variables, context) {
- // [Joshen] If we need to invalidate any queries
- await onSuccess?.(data, variables, context)
- },
- async onError(data, variables, context) {
- if (onError === undefined) {
- toast.error(`Failed to delete the user's MFA factors: ${data.message}`)
- } else {
- onError(data, variables, context)
- }
- },
- ...options,
- }
- )
+ return useMutation({
+ mutationFn: (vars) => deleteMFAFactors(vars),
+ async onSuccess(data, variables, context) {
+ // [Joshen] If we need to invalidate any queries
+ await onSuccess?.(data, variables, context)
+ },
+ async onError(data, variables, context) {
+ if (onError === undefined) {
+ toast.error(`Failed to delete the user's MFA factors: ${data.message}`)
+ } else {
+ onError(data, variables, context)
+ }
+ },
+ ...options,
+ })
}
diff --git a/apps/studio/data/auth/user-delete-mutation.ts b/apps/studio/data/auth/user-delete-mutation.ts
index 0b67188f052..62e0c671fc2 100644
--- a/apps/studio/data/auth/user-delete-mutation.ts
+++ b/apps/studio/data/auth/user-delete-mutation.ts
@@ -31,26 +31,24 @@ export const useUserDeleteMutation = ({
> = {}) => {
const queryClient = useQueryClient()
- return useMutation(
- (vars) => deleteUser(vars),
- {
- async onSuccess(data, variables, context) {
- const { projectRef, skipInvalidation = false } = variables
+ return useMutation({
+ mutationFn: (vars) => deleteUser(vars),
+ async onSuccess(data, variables, context) {
+ const { projectRef, skipInvalidation = false } = variables
- if (!skipInvalidation) {
- await Promise.all([queryClient.invalidateQueries(authKeys.usersInfinite(projectRef))])
- }
+ if (!skipInvalidation) {
+ await Promise.all([queryClient.invalidateQueries(authKeys.usersInfinite(projectRef))])
+ }
- await onSuccess?.(data, variables, context)
- },
- async onError(data, variables, context) {
- if (onError === undefined) {
- toast.error(`Failed to delete user: ${data.message}`)
- } else {
- onError(data, variables, context)
- }
- },
- ...options,
- }
- )
+ await onSuccess?.(data, variables, context)
+ },
+ async onError(data, variables, context) {
+ if (onError === undefined) {
+ toast.error(`Failed to delete user: ${data.message}`)
+ } else {
+ onError(data, variables, context)
+ }
+ },
+ ...options,
+ })
}
diff --git a/apps/studio/data/auth/user-invite-mutation.ts b/apps/studio/data/auth/user-invite-mutation.ts
index 42bff571c6d..77fcfd13e31 100644
--- a/apps/studio/data/auth/user-invite-mutation.ts
+++ b/apps/studio/data/auth/user-invite-mutation.ts
@@ -31,24 +31,22 @@ export const useUserInviteMutation = ({
> = {}) => {
const queryClient = useQueryClient()
- return useMutation(
- (vars) => inviteUser(vars),
- {
- async onSuccess(data, variables, context) {
- const { projectRef } = variables
+ return useMutation({
+ mutationFn: (vars) => inviteUser(vars),
+ async onSuccess(data, variables, context) {
+ const { projectRef } = variables
- await Promise.all([queryClient.invalidateQueries(authKeys.usersInfinite(projectRef))])
+ await Promise.all([queryClient.invalidateQueries(authKeys.usersInfinite(projectRef))])
- await onSuccess?.(data, variables, context)
- },
- async onError(data, variables, context) {
- if (onError === undefined) {
- toast.error(`Failed to invite user: ${data.message}`)
- } else {
- onError(data, variables, context)
- }
- },
- ...options,
- }
- )
+ await onSuccess?.(data, variables, context)
+ },
+ async onError(data, variables, context) {
+ if (onError === undefined) {
+ toast.error(`Failed to invite user: ${data.message}`)
+ } else {
+ onError(data, variables, context)
+ }
+ },
+ ...options,
+ })
}
diff --git a/apps/studio/data/auth/user-reset-password-mutation.ts b/apps/studio/data/auth/user-reset-password-mutation.ts
index aeaef00b5d8..d39a5a9a692 100644
--- a/apps/studio/data/auth/user-reset-password-mutation.ts
+++ b/apps/studio/data/auth/user-reset-password-mutation.ts
@@ -31,21 +31,19 @@ export const useUserResetPasswordMutation = ({
UseMutationOptions,
'mutationFn'
> = {}) => {
- return useMutation(
- (vars) => resetPassword(vars),
- {
- async onSuccess(data, variables, context) {
- // [Joshen] If we need to invalidate any queries
- await onSuccess?.(data, variables, context)
- },
- async onError(data, variables, context) {
- if (onError === undefined) {
- toast.error(`Failed to reset user password: ${data.message}`)
- } else {
- onError(data, variables, context)
- }
- },
- ...options,
- }
- )
+ return useMutation({
+ mutationFn: (vars) => resetPassword(vars),
+ async onSuccess(data, variables, context) {
+ // [Joshen] If we need to invalidate any queries
+ await onSuccess?.(data, variables, context)
+ },
+ async onError(data, variables, context) {
+ if (onError === undefined) {
+ toast.error(`Failed to reset user password: ${data.message}`)
+ } else {
+ onError(data, variables, context)
+ }
+ },
+ ...options,
+ })
}
diff --git a/apps/studio/data/auth/user-send-magic-link-mutation.ts b/apps/studio/data/auth/user-send-magic-link-mutation.ts
index 22037ab8938..127fb33a313 100644
--- a/apps/studio/data/auth/user-send-magic-link-mutation.ts
+++ b/apps/studio/data/auth/user-send-magic-link-mutation.ts
@@ -31,21 +31,19 @@ export const useUserSendMagicLinkMutation = ({
UseMutationOptions,
'mutationFn'
> = {}) => {
- return useMutation(
- (vars) => sendMagicLink(vars),
- {
- async onSuccess(data, variables, context) {
- // [Joshen] If we need to invalidate any queries
- await onSuccess?.(data, variables, context)
- },
- async onError(data, variables, context) {
- if (onError === undefined) {
- toast.error(`Failed to send magic link: ${data.message}`)
- } else {
- onError(data, variables, context)
- }
- },
- ...options,
- }
- )
+ return useMutation({
+ mutationFn: (vars) => sendMagicLink(vars),
+ async onSuccess(data, variables, context) {
+ // [Joshen] If we need to invalidate any queries
+ await onSuccess?.(data, variables, context)
+ },
+ async onError(data, variables, context) {
+ if (onError === undefined) {
+ toast.error(`Failed to send magic link: ${data.message}`)
+ } else {
+ onError(data, variables, context)
+ }
+ },
+ ...options,
+ })
}
diff --git a/apps/studio/data/auth/user-send-otp-mutation.ts b/apps/studio/data/auth/user-send-otp-mutation.ts
index 1ba5d3239fe..6072fcb969c 100644
--- a/apps/studio/data/auth/user-send-otp-mutation.ts
+++ b/apps/studio/data/auth/user-send-otp-mutation.ts
@@ -31,21 +31,19 @@ export const useUserSendOTPMutation = ({
UseMutationOptions,
'mutationFn'
> = {}) => {
- return useMutation(
- (vars) => sendOTP(vars),
- {
- async onSuccess(data, variables, context) {
- // [Joshen] If we need to invalidate any queries
- await onSuccess?.(data, variables, context)
- },
- async onError(data, variables, context) {
- if (onError === undefined) {
- toast.error(`Failed to send magic link: ${data.message}`)
- } else {
- onError(data, variables, context)
- }
- },
- ...options,
- }
- )
+ return useMutation({
+ mutationFn: (vars) => sendOTP(vars),
+ async onSuccess(data, variables, context) {
+ // [Joshen] If we need to invalidate any queries
+ await onSuccess?.(data, variables, context)
+ },
+ async onError(data, variables, context) {
+ if (onError === undefined) {
+ toast.error(`Failed to send magic link: ${data.message}`)
+ } else {
+ onError(data, variables, context)
+ }
+ },
+ ...options,
+ })
}
diff --git a/apps/studio/data/auth/user-update-mutation.ts b/apps/studio/data/auth/user-update-mutation.ts
index 19cf3ae3b9f..01209b20125 100644
--- a/apps/studio/data/auth/user-update-mutation.ts
+++ b/apps/studio/data/auth/user-update-mutation.ts
@@ -34,22 +34,20 @@ export const useUserUpdateMutation = ({
> = {}) => {
const queryClient = useQueryClient()
- return useMutation(
- (vars) => updateUser(vars),
- {
- async onSuccess(data, variables, context) {
- const { projectRef } = variables
- await queryClient.invalidateQueries(authKeys.usersInfinite(projectRef))
- await onSuccess?.(data, variables, context)
- },
- async onError(data, variables, context) {
- if (onError === undefined) {
- toast.error(`Failed to update user: ${data.message}`)
- } else {
- onError(data, variables, context)
- }
- },
- ...options,
- }
- )
+ return useMutation({
+ mutationFn: (vars) => updateUser(vars),
+ async onSuccess(data, variables, context) {
+ const { projectRef } = variables
+ await queryClient.invalidateQueries(authKeys.usersInfinite(projectRef))
+ await onSuccess?.(data, variables, context)
+ },
+ async onError(data, variables, context) {
+ if (onError === undefined) {
+ toast.error(`Failed to update user: ${data.message}`)
+ } else {
+ onError(data, variables, context)
+ }
+ },
+ ...options,
+ })
}
diff --git a/apps/studio/data/auth/users-count-query.ts b/apps/studio/data/auth/users-count-query.ts
index 9c8730eff10..67052362022 100644
--- a/apps/studio/data/auth/users-count-query.ts
+++ b/apps/studio/data/auth/users-count-query.ts
@@ -65,14 +65,14 @@ export const useUsersCountQuery = (
}: UsersCountVariables,
{ enabled = true, ...options }: UseQueryOptions = {}
) =>
- useQuery(
- authKeys.usersCount(projectRef, {
+ useQuery({
+ queryKey: authKeys.usersCount(projectRef, {
keywords,
filter,
providers,
forceExactCount,
}),
- ({ signal }) =>
+ queryFn: ({ signal }) =>
getUsersCount(
{
projectRef,
@@ -84,8 +84,6 @@ export const useUsersCountQuery = (
},
signal
),
- {
- enabled: enabled && typeof projectRef !== 'undefined',
- ...options,
- }
- )
+ enabled: enabled && typeof projectRef !== 'undefined',
+ ...options,
+ })
diff --git a/apps/studio/data/auth/validate-spam-mutation.ts b/apps/studio/data/auth/validate-spam-mutation.ts
index 78a46ac777d..920a025f7d7 100644
--- a/apps/studio/data/auth/validate-spam-mutation.ts
+++ b/apps/studio/data/auth/validate-spam-mutation.ts
@@ -32,20 +32,18 @@ export const useValidateSpamMutation = ({
UseMutationOptions,
'mutationFn'
> = {}) => {
- return useMutation(
- (vars) => validateSpam(vars),
- {
- async onSuccess(data, variables, context) {
- await onSuccess?.(data, variables, context)
- },
- async onError(data, variables, context) {
- if (onError === undefined) {
- toast.error(`Failed to validate template: ${data.message}`)
- } else {
- onError(data, variables, context)
- }
- },
- ...options,
- }
- )
+ return useMutation({
+ mutationFn: (vars) => validateSpam(vars),
+ async onSuccess(data, variables, context) {
+ await onSuccess?.(data, variables, context)
+ },
+ async onError(data, variables, context) {
+ if (onError === undefined) {
+ toast.error(`Failed to validate template: ${data.message}`)
+ } else {
+ onError(data, variables, context)
+ }
+ },
+ ...options,
+ })
}
diff --git a/apps/studio/data/banned-ips/banned-ips-delete-mutations.ts b/apps/studio/data/banned-ips/banned-ips-delete-mutations.ts
index dc0a462fc99..3fff21f34ba 100644
--- a/apps/studio/data/banned-ips/banned-ips-delete-mutations.ts
+++ b/apps/studio/data/banned-ips/banned-ips-delete-mutations.ts
@@ -31,24 +31,22 @@ export const useBannedIPsDeleteMutation = ({
...options
}: Omit, 'mutationFn'> = {}) => {
const queryClient = useQueryClient()
- return useMutation(
- (vars) => deleteBannedIPs(vars),
- {
- async onSuccess(data, variables, context) {
- const { projectRef } = variables
+ return useMutation({
+ mutationFn: (vars) => deleteBannedIPs(vars),
+ async onSuccess(data, variables, context) {
+ const { projectRef } = variables
- await queryClient.invalidateQueries(BannedIPKeys.list(projectRef))
+ await queryClient.invalidateQueries(BannedIPKeys.list(projectRef))
- await onSuccess?.(data, variables, context)
- },
- async onError(data, variables, context) {
- if (onError === undefined) {
- toast.error(`Failed to unban ips: ${data.message}`)
- } else {
- onError(data, variables, context)
- }
- },
- ...options,
- }
- )
+ await onSuccess?.(data, variables, context)
+ },
+ async onError(data, variables, context) {
+ if (onError === undefined) {
+ toast.error(`Failed to unban ips: ${data.message}`)
+ } else {
+ onError(data, variables, context)
+ }
+ },
+ ...options,
+ })
}
diff --git a/apps/studio/data/banned-ips/banned-ips-query.ts b/apps/studio/data/banned-ips/banned-ips-query.ts
index 89964f60477..710b68c3fb0 100644
--- a/apps/studio/data/banned-ips/banned-ips-query.ts
+++ b/apps/studio/data/banned-ips/banned-ips-query.ts
@@ -30,11 +30,9 @@ export const useBannedIPsQuery = (
{ projectRef }: BannedIPVariables,
{ enabled = true, ...options }: UseQueryOptions = {}
) =>
- useQuery(
- BannedIPKeys.list(projectRef),
- ({ signal }) => getBannedIPs({ projectRef }, signal),
- {
- enabled: enabled && typeof projectRef !== 'undefined',
- ...options,
- }
- )
+ useQuery({
+ queryKey: BannedIPKeys.list(projectRef),
+ queryFn: ({ signal }) => getBannedIPs({ projectRef }, signal),
+ enabled: enabled && typeof projectRef !== 'undefined',
+ ...options,
+ })
diff --git a/apps/studio/data/branches/branch-create-mutation.ts b/apps/studio/data/branches/branch-create-mutation.ts
index 2b338ea0560..08d426c1f20 100644
--- a/apps/studio/data/branches/branch-create-mutation.ts
+++ b/apps/studio/data/branches/branch-create-mutation.ts
@@ -52,22 +52,20 @@ export const useBranchCreateMutation = ({
'mutationFn'
> = {}) => {
const queryClient = useQueryClient()
- return useMutation(
- (vars) => createBranch(vars),
- {
- async onSuccess(data, variables, context) {
- const { projectRef } = variables
- await queryClient.invalidateQueries(branchKeys.list(projectRef))
- await onSuccess?.(data, variables, context)
- },
- async onError(data, variables, context) {
- if (onError === undefined) {
- toast.error(`Failed to create branch: ${data.message}`)
- } else {
- onError(data, variables, context)
- }
- },
- ...options,
- }
- )
+ return useMutation({
+ mutationFn: (vars) => createBranch(vars),
+ async onSuccess(data, variables, context) {
+ const { projectRef } = variables
+ await queryClient.invalidateQueries(branchKeys.list(projectRef))
+ await onSuccess?.(data, variables, context)
+ },
+ async onError(data, variables, context) {
+ if (onError === undefined) {
+ toast.error(`Failed to create branch: ${data.message}`)
+ } else {
+ onError(data, variables, context)
+ }
+ },
+ ...options,
+ })
}
diff --git a/apps/studio/data/branches/branch-delete-mutation.ts b/apps/studio/data/branches/branch-delete-mutation.ts
index fe0adb6d8d3..1b9ca55e56e 100644
--- a/apps/studio/data/branches/branch-delete-mutation.ts
+++ b/apps/studio/data/branches/branch-delete-mutation.ts
@@ -31,33 +31,31 @@ export const useBranchDeleteMutation = ({
'mutationFn'
> = {}) => {
const queryClient = useQueryClient()
- return useMutation(
- (vars) => deleteBranch(vars),
- {
- async onSuccess(data, variables, context) {
- const { branchRef, projectRef } = variables
- setTimeout(() => {
- queryClient.invalidateQueries(branchKeys.list(projectRef))
- }, 5000)
+ return useMutation({
+ mutationFn: (vars) => deleteBranch(vars),
+ async onSuccess(data, variables, context) {
+ const { branchRef, projectRef } = variables
+ setTimeout(() => {
+ queryClient.invalidateQueries(branchKeys.list(projectRef))
+ }, 5000)
- const branches: BranchesData | undefined = queryClient.getQueryData(
- branchKeys.list(projectRef)
- )
- if (branches) {
- const updatedBranches = branches.filter((branch) => branch.project_ref !== branchRef)
- queryClient.setQueryData(branchKeys.list(projectRef), updatedBranches)
- }
+ const branches: BranchesData | undefined = queryClient.getQueryData(
+ branchKeys.list(projectRef)
+ )
+ if (branches) {
+ const updatedBranches = branches.filter((branch) => branch.project_ref !== branchRef)
+ queryClient.setQueryData(branchKeys.list(projectRef), updatedBranches)
+ }
- await onSuccess?.(data, variables, context)
- },
- async onError(data, variables, context) {
- if (onError === undefined) {
- toast.error(`Failed to delete branch: ${data.message}`)
- } else {
- onError(data, variables, context)
- }
- },
- ...options,
- }
- )
+ await onSuccess?.(data, variables, context)
+ },
+ async onError(data, variables, context) {
+ if (onError === undefined) {
+ toast.error(`Failed to delete branch: ${data.message}`)
+ } else {
+ onError(data, variables, context)
+ }
+ },
+ ...options,
+ })
}
diff --git a/apps/studio/data/branches/branch-diff-query.ts b/apps/studio/data/branches/branch-diff-query.ts
index bdc83572fee..a3976d63a65 100644
--- a/apps/studio/data/branches/branch-diff-query.ts
+++ b/apps/studio/data/branches/branch-diff-query.ts
@@ -47,11 +47,9 @@ export const useBranchDiffQuery = (
...options
}: Omit, 'queryKey' | 'queryFn'> = {}
) =>
- useQuery(
- branchKeys.diff(projectRef, branchRef),
- () => getBranchDiff({ branchRef, includedSchemas }),
- {
- enabled: IS_PLATFORM && enabled && Boolean(branchRef),
- ...options,
- }
- )
+ useQuery({
+ queryKey: branchKeys.diff(projectRef, branchRef),
+ queryFn: () => getBranchDiff({ branchRef, includedSchemas }),
+ enabled: IS_PLATFORM && enabled && Boolean(branchRef),
+ ...options,
+ })
diff --git a/apps/studio/data/branches/branch-merge-mutation.ts b/apps/studio/data/branches/branch-merge-mutation.ts
index b6a1fd56918..9c2c8bf24d7 100644
--- a/apps/studio/data/branches/branch-merge-mutation.ts
+++ b/apps/studio/data/branches/branch-merge-mutation.ts
@@ -63,24 +63,22 @@ export const useBranchMergeMutation = ({
'mutationFn'
> = {}) => {
const queryClient = useQueryClient()
- return useMutation(
- (vars) => mergeBranch(vars),
- {
- async onSuccess(data, variables, context) {
- const { baseProjectRef } = variables
- await queryClient.invalidateQueries(branchKeys.list(baseProjectRef))
- await onSuccess?.(data, variables, context)
- },
- async onError(data, variables, context) {
- if (onError === undefined) {
- let errorMessage = data.message || 'Unknown error occurred'
+ return useMutation({
+ mutationFn: (vars) => mergeBranch(vars),
+ async onSuccess(data, variables, context) {
+ const { baseProjectRef } = variables
+ await queryClient.invalidateQueries(branchKeys.list(baseProjectRef))
+ await onSuccess?.(data, variables, context)
+ },
+ async onError(data, variables, context) {
+ if (onError === undefined) {
+ let errorMessage = data.message || 'Unknown error occurred'
- toast.error(`Failed to merge branch: ${errorMessage}`)
- } else {
- onError(data, variables, context)
- }
- },
- ...options,
- }
- )
+ toast.error(`Failed to merge branch: ${errorMessage}`)
+ } else {
+ onError(data, variables, context)
+ }
+ },
+ ...options,
+ })
}
diff --git a/apps/studio/data/branches/branch-push-mutation.ts b/apps/studio/data/branches/branch-push-mutation.ts
index 1ffb4ac909a..3b36d83ff0a 100644
--- a/apps/studio/data/branches/branch-push-mutation.ts
+++ b/apps/studio/data/branches/branch-push-mutation.ts
@@ -31,22 +31,20 @@ export const useBranchPushMutation = ({
'mutationFn'
> = {}) => {
const queryClient = useQueryClient()
- return useMutation(
- (vars) => pushBranch(vars),
- {
- async onSuccess(data, variables, context) {
- const { projectRef } = variables
- await queryClient.invalidateQueries(branchKeys.list(projectRef))
- await onSuccess?.(data, variables, context)
- },
- async onError(data, variables, context) {
- if (onError === undefined) {
- toast.error(`Failed to push branch: ${data.message}`)
- } else {
- onError(data, variables, context)
- }
- },
- ...options,
- }
- )
+ return useMutation({
+ mutationFn: (vars) => pushBranch(vars),
+ async onSuccess(data, variables, context) {
+ const { projectRef } = variables
+ await queryClient.invalidateQueries(branchKeys.list(projectRef))
+ await onSuccess?.(data, variables, context)
+ },
+ async onError(data, variables, context) {
+ if (onError === undefined) {
+ toast.error(`Failed to push branch: ${data.message}`)
+ } else {
+ onError(data, variables, context)
+ }
+ },
+ ...options,
+ })
}
diff --git a/apps/studio/data/branches/branch-query.ts b/apps/studio/data/branches/branch-query.ts
index 81fee2ba79b..03c83a3e88f 100644
--- a/apps/studio/data/branches/branch-query.ts
+++ b/apps/studio/data/branches/branch-query.ts
@@ -29,11 +29,9 @@ export const useBranchQuery = (
{ projectRef, branchRef }: BranchVariables,
{ enabled = true, ...options }: UseQueryOptions = {}
) =>
- useQuery(
- branchKeys.detail(projectRef, branchRef),
- ({ signal }) => getBranch({ branchRef }, signal),
- {
- enabled: IS_PLATFORM && enabled && Boolean(branchRef),
- ...options,
- }
- )
+ useQuery({
+ queryKey: branchKeys.detail(projectRef, branchRef),
+ queryFn: ({ signal }) => getBranch({ branchRef }, signal),
+ enabled: IS_PLATFORM && enabled && Boolean(branchRef),
+ ...options,
+ })
diff --git a/apps/studio/data/branches/branch-reset-mutation.ts b/apps/studio/data/branches/branch-reset-mutation.ts
index f54e61a35c6..fd2b21f6a6b 100644
--- a/apps/studio/data/branches/branch-reset-mutation.ts
+++ b/apps/studio/data/branches/branch-reset-mutation.ts
@@ -31,22 +31,20 @@ export const useBranchResetMutation = ({
'mutationFn'
> = {}) => {
const queryClient = useQueryClient()
- return useMutation(
- (vars) => resetBranch(vars),
- {
- async onSuccess(data, variables, context) {
- const { projectRef } = variables
- await queryClient.invalidateQueries(branchKeys.list(projectRef))
- await onSuccess?.(data, variables, context)
- },
- async onError(data, variables, context) {
- if (onError === undefined) {
- toast.error(`Failed to reset branch: ${data.message}`)
- } else {
- onError(data, variables, context)
- }
- },
- ...options,
- }
- )
+ return useMutation({
+ mutationFn: (vars) => resetBranch(vars),
+ async onSuccess(data, variables, context) {
+ const { projectRef } = variables
+ await queryClient.invalidateQueries(branchKeys.list(projectRef))
+ await onSuccess?.(data, variables, context)
+ },
+ async onError(data, variables, context) {
+ if (onError === undefined) {
+ toast.error(`Failed to reset branch: ${data.message}`)
+ } else {
+ onError(data, variables, context)
+ }
+ },
+ ...options,
+ })
}
diff --git a/apps/studio/data/branches/branch-update-mutation.ts b/apps/studio/data/branches/branch-update-mutation.ts
index 2ea12830fd0..f8233395ba9 100644
--- a/apps/studio/data/branches/branch-update-mutation.ts
+++ b/apps/studio/data/branches/branch-update-mutation.ts
@@ -48,22 +48,20 @@ export const useBranchUpdateMutation = ({
'mutationFn'
> = {}) => {
const queryClient = useQueryClient()
- return useMutation(
- (vars) => updateBranch(vars),
- {
- async onSuccess(data, variables, context) {
- const { projectRef } = variables
- await queryClient.invalidateQueries(branchKeys.list(projectRef))
- await onSuccess?.(data, variables, context)
- },
- async onError(data, variables, context) {
- if (onError === undefined) {
- toast.error(`Failed to update branch: ${data.message}`)
- } else {
- onError(data, variables, context)
- }
- },
- ...options,
- }
- )
+ return useMutation({
+ mutationFn: (vars) => updateBranch(vars),
+ async onSuccess(data, variables, context) {
+ const { projectRef } = variables
+ await queryClient.invalidateQueries(branchKeys.list(projectRef))
+ await onSuccess?.(data, variables, context)
+ },
+ async onError(data, variables, context) {
+ if (onError === undefined) {
+ toast.error(`Failed to update branch: ${data.message}`)
+ } else {
+ onError(data, variables, context)
+ }
+ },
+ ...options,
+ })
}
diff --git a/apps/studio/data/branches/branches-query.ts b/apps/studio/data/branches/branches-query.ts
index 69aad2f835a..cf4f95f4b17 100644
--- a/apps/studio/data/branches/branches-query.ts
+++ b/apps/studio/data/branches/branches-query.ts
@@ -38,8 +38,9 @@ export const useBranchesQuery = (
{ projectRef }: BranchesVariables,
{ enabled = true, ...options }: UseQueryOptions = {}
) =>
- useQuery(
- branchKeys.list(projectRef),
- ({ signal }) => getBranches({ projectRef }, signal),
- { enabled: IS_PLATFORM && enabled && Boolean(projectRef), ...options }
- )
+ useQuery({
+ queryKey: branchKeys.list(projectRef),
+ queryFn: ({ signal }) => getBranches({ projectRef }, signal),
+ enabled: IS_PLATFORM && enabled && Boolean(projectRef),
+ ...options,
+ })
diff --git a/apps/studio/data/config/disk-attributes-query.ts b/apps/studio/data/config/disk-attributes-query.ts
index 84c55f721cf..eb5f49cb59e 100644
--- a/apps/studio/data/config/disk-attributes-query.ts
+++ b/apps/studio/data/config/disk-attributes-query.ts
@@ -39,11 +39,12 @@ export const useDiskAttributesQuery = (
...options
}: UseQueryOptions = {}
) =>
- useQuery(
- configKeys.diskAttributes(projectRef),
- ({ signal }) => getDiskAttributes({ projectRef }, signal),
- { enabled: enabled && typeof projectRef !== 'undefined', ...options }
- )
+ useQuery({
+ queryKey: configKeys.diskAttributes(projectRef),
+ queryFn: ({ signal }) => getDiskAttributes({ projectRef }, signal),
+ enabled: enabled && typeof projectRef !== 'undefined',
+ ...options,
+ })
export const useRemainingDurationForDiskAttributeUpdate = ({
projectRef,
diff --git a/apps/studio/data/config/disk-attributes-update-mutation.ts b/apps/studio/data/config/disk-attributes-update-mutation.ts
index 8a289448f3a..e50d3dbec24 100644
--- a/apps/studio/data/config/disk-attributes-update-mutation.ts
+++ b/apps/studio/data/config/disk-attributes-update-mutation.ts
@@ -54,22 +54,20 @@ export const useUpdateDiskAttributesMutation = ({
'mutationFn'
> = {}) => {
const queryClient = useQueryClient()
- return useMutation(
- (vars) => updateDiskAttributes(vars),
- {
- async onSuccess(data, variables, context) {
- const { ref } = variables
- await queryClient.invalidateQueries(configKeys.diskAttributes(ref))
- await onSuccess?.(data, variables, context)
- },
- async onError(data, variables, context) {
- if (onError === undefined) {
- toast.error(`Failed to update disk attributes: ${data.message}`)
- } else {
- onError(data, variables, context)
- }
- },
- ...options,
- }
- )
+ return useMutation({
+ mutationFn: (vars) => updateDiskAttributes(vars),
+ async onSuccess(data, variables, context) {
+ const { ref } = variables
+ await queryClient.invalidateQueries(configKeys.diskAttributes(ref))
+ await onSuccess?.(data, variables, context)
+ },
+ async onError(data, variables, context) {
+ if (onError === undefined) {
+ toast.error(`Failed to update disk attributes: ${data.message}`)
+ } else {
+ onError(data, variables, context)
+ }
+ },
+ ...options,
+ })
}
diff --git a/apps/studio/data/config/disk-autoscale-config-query.ts b/apps/studio/data/config/disk-autoscale-config-query.ts
index bde9263c2fc..6d44f7f8b0b 100644
--- a/apps/studio/data/config/disk-autoscale-config-query.ts
+++ b/apps/studio/data/config/disk-autoscale-config-query.ts
@@ -35,8 +35,9 @@ export const useDiskAutoscaleCustomConfigQuery = = {}
) =>
- useQuery(
- configKeys.diskAutoscaleConfig(projectRef),
- ({ signal }) => getDiskAutoscaleCustomConfig({ projectRef }, signal),
- { enabled: enabled && typeof projectRef !== 'undefined', ...options }
- )
+ useQuery({
+ queryKey: configKeys.diskAutoscaleConfig(projectRef),
+ queryFn: ({ signal }) => getDiskAutoscaleCustomConfig({ projectRef }, signal),
+ enabled: enabled && typeof projectRef !== 'undefined',
+ ...options,
+ })
diff --git a/apps/studio/data/config/disk-autoscale-config-update-mutation.ts b/apps/studio/data/config/disk-autoscale-config-update-mutation.ts
index e9c37ceb744..6da6272a279 100644
--- a/apps/studio/data/config/disk-autoscale-config-update-mutation.ts
+++ b/apps/studio/data/config/disk-autoscale-config-update-mutation.ts
@@ -53,7 +53,8 @@ export const useUpdateDiskAutoscaleConfigMutation = ({
UpdateDiskAutoscaleConfigData,
ResponseError,
UpdateDiskAutoscaleConfigVariables
- >((vars) => updateDiskAutoscaleConfig(vars), {
+ >({
+ mutationFn: (vars) => updateDiskAutoscaleConfig(vars),
async onSuccess(data, variables, context) {
const { projectRef } = variables
await queryClient.invalidateQueries(configKeys.diskAutoscaleConfig(projectRef))
diff --git a/apps/studio/data/config/disk-breakdown-query.ts b/apps/studio/data/config/disk-breakdown-query.ts
index 5f5f42c5ce9..757a289735c 100644
--- a/apps/studio/data/config/disk-breakdown-query.ts
+++ b/apps/studio/data/config/disk-breakdown-query.ts
@@ -52,8 +52,9 @@ export const useDiskBreakdownQuery = (
{ projectRef, connectionString }: DiskBreakdownVariables,
{ enabled = true, ...options }: UseQueryOptions = {}
) =>
- useQuery(
- configKeys.diskBreakdown(projectRef),
- ({ signal }) => getDiskBreakdown({ projectRef, connectionString }, signal),
- { enabled: enabled && typeof projectRef !== 'undefined', ...options }
- )
+ useQuery({
+ queryKey: configKeys.diskBreakdown(projectRef),
+ queryFn: ({ signal }) => getDiskBreakdown({ projectRef, connectionString }, signal),
+ enabled: enabled && typeof projectRef !== 'undefined',
+ ...options,
+ })
diff --git a/apps/studio/data/config/disk-utilization-query.ts b/apps/studio/data/config/disk-utilization-query.ts
index 5d8b786f3e8..3e7a5f394f0 100644
--- a/apps/studio/data/config/disk-utilization-query.ts
+++ b/apps/studio/data/config/disk-utilization-query.ts
@@ -33,8 +33,9 @@ export const useDiskUtilizationQuery = (
...options
}: UseQueryOptions = {}
) =>
- useQuery(
- configKeys.diskUtilization(projectRef),
- ({ signal }) => getDiskUtilization({ projectRef }, signal),
- { enabled: enabled && typeof projectRef !== 'undefined', ...options }
- )
+ useQuery({
+ queryKey: configKeys.diskUtilization(projectRef),
+ queryFn: ({ signal }) => getDiskUtilization({ projectRef }, signal),
+ enabled: enabled && typeof projectRef !== 'undefined',
+ ...options,
+ })
diff --git a/apps/studio/data/config/jwt-secret-update-mutation.ts b/apps/studio/data/config/jwt-secret-update-mutation.ts
index 672ce8d9ab6..d3debe12df6 100644
--- a/apps/studio/data/config/jwt-secret-update-mutation.ts
+++ b/apps/studio/data/config/jwt-secret-update-mutation.ts
@@ -43,18 +43,16 @@ export const useJwtSecretUpdateMutation = ({
> = {}) => {
const queryClient = useQueryClient()
- return useMutation(
- (vars) => updateJwtSecret(vars),
- {
- async onSuccess(data, variables, context) {
- const { projectRef } = variables
- await queryClient.invalidateQueries(configKeys.jwtSecretUpdatingStatus(projectRef))
- await onSuccess?.(data, variables, context)
- },
- async onError(data, variables, context) {
- await onError?.(data, variables, context)
- },
- ...options,
- }
- )
+ return useMutation({
+ mutationFn: (vars) => updateJwtSecret(vars),
+ async onSuccess(data, variables, context) {
+ const { projectRef } = variables
+ await queryClient.invalidateQueries(configKeys.jwtSecretUpdatingStatus(projectRef))
+ await onSuccess?.(data, variables, context)
+ },
+ async onError(data, variables, context) {
+ await onError?.(data, variables, context)
+ },
+ ...options,
+ })
}
diff --git a/apps/studio/data/config/jwt-secret-updating-status-query.ts b/apps/studio/data/config/jwt-secret-updating-status-query.ts
index 40decc00215..3f0a7167c87 100644
--- a/apps/studio/data/config/jwt-secret-updating-status-query.ts
+++ b/apps/studio/data/config/jwt-secret-updating-status-query.ts
@@ -53,26 +53,24 @@ export const useJwtSecretUpdatingStatusQuery = {
const client = useQueryClient()
- return useQuery(
- configKeys.jwtSecretUpdatingStatus(projectRef),
- ({ signal }) => getJwtSecretUpdatingStatus({ projectRef }, signal),
- {
- enabled: enabled && typeof projectRef !== 'undefined',
- refetchInterval(data) {
- if (!data) {
- return false
- }
+ return useQuery({
+ queryKey: configKeys.jwtSecretUpdatingStatus(projectRef),
+ queryFn: ({ signal }) => getJwtSecretUpdatingStatus({ projectRef }, signal),
+ enabled: enabled && typeof projectRef !== 'undefined',
+ refetchInterval(data) {
+ if (!data) {
+ return false
+ }
- const { jwtSecretUpdateStatus } = data as unknown as JwtSecretUpdatingStatusResponse
+ const { jwtSecretUpdateStatus } = data as unknown as JwtSecretUpdatingStatusResponse
- const interval = jwtSecretUpdateStatus === JwtSecretUpdateStatus.Updating ? 1000 : false
+ const interval = jwtSecretUpdateStatus === JwtSecretUpdateStatus.Updating ? 1000 : false
- return interval
- },
- onSuccess() {
- client.invalidateQueries(configKeys.postgrest(projectRef))
- },
- ...options,
- }
- )
+ return interval
+ },
+ onSuccess() {
+ client.invalidateQueries(configKeys.postgrest(projectRef))
+ },
+ ...options,
+ })
}
diff --git a/apps/studio/data/config/project-compliance-config-mutation.ts b/apps/studio/data/config/project-compliance-config-mutation.ts
index 89317a31cf6..5e8740fcf8d 100644
--- a/apps/studio/data/config/project-compliance-config-mutation.ts
+++ b/apps/studio/data/config/project-compliance-config-mutation.ts
@@ -37,22 +37,20 @@ export const useComplianceConfigUpdateMutation = ({
> = {}) => {
const queryClient = useQueryClient()
- return useMutation(
- (vars) => updateComplianceConfig(vars),
- {
- async onSuccess(data, variables, context) {
- const { projectRef } = variables
- await queryClient.invalidateQueries(configKeys.settingsV2(projectRef))
- await onSuccess?.(data, variables, context)
- },
- async onError(data, variables, context) {
- if (onError === undefined) {
- toast.error(`Failed to update project compliance configuration: ${data.message}`)
- } else {
- onError(data, variables, context)
- }
- },
- ...options,
- }
- )
+ return useMutation({
+ mutationFn: (vars) => updateComplianceConfig(vars),
+ async onSuccess(data, variables, context) {
+ const { projectRef } = variables
+ await queryClient.invalidateQueries(configKeys.settingsV2(projectRef))
+ await onSuccess?.(data, variables, context)
+ },
+ async onError(data, variables, context) {
+ if (onError === undefined) {
+ toast.error(`Failed to update project compliance configuration: ${data.message}`)
+ } else {
+ onError(data, variables, context)
+ }
+ },
+ ...options,
+ })
}
diff --git a/apps/studio/data/config/project-creation-postgres-versions-query.ts b/apps/studio/data/config/project-creation-postgres-versions-query.ts
index 649d3d82279..1f3ecfdf9cc 100644
--- a/apps/studio/data/config/project-creation-postgres-versions-query.ts
+++ b/apps/studio/data/config/project-creation-postgres-versions-query.ts
@@ -43,19 +43,17 @@ export const useProjectCreationPostgresVersionsQuery = = {}
) => {
- return useQuery(
- configKeys.projectCreationPostgresVersions(organizationSlug, cloudProvider, dbRegion),
- ({ signal }) =>
+ return useQuery({
+ queryKey: configKeys.projectCreationPostgresVersions(organizationSlug, cloudProvider, dbRegion),
+ queryFn: ({ signal }) =>
getPostgresCreationVersions({ organizationSlug, cloudProvider, dbRegion }, signal),
- {
- enabled:
- enabled &&
- typeof organizationSlug !== 'undefined' &&
- organizationSlug !== '_' &&
- typeof dbRegion !== 'undefined',
- ...options,
- }
- )
+ enabled:
+ enabled &&
+ typeof organizationSlug !== 'undefined' &&
+ organizationSlug !== '_' &&
+ typeof dbRegion !== 'undefined',
+ ...options,
+ })
}
export const useAvailableOrioleImageVersion = (
diff --git a/apps/studio/data/config/project-disk-resize-mutation.ts b/apps/studio/data/config/project-disk-resize-mutation.ts
index 29b63ca358c..c5e81ae511d 100644
--- a/apps/studio/data/config/project-disk-resize-mutation.ts
+++ b/apps/studio/data/config/project-disk-resize-mutation.ts
@@ -40,25 +40,23 @@ export const useProjectDiskResizeMutation = ({
> = {}) => {
const queryClient = useQueryClient()
- return useMutation(
- (vars) => resizeProjectDisk(vars),
- {
- async onSuccess(data, variables, context) {
- const { projectRef } = variables
- queryClient.setQueriesData(usageKeys.usage(projectRef), (prev: any) => {
- if (!prev) return prev
- return { ...prev, disk_volume_size_gb: variables.volumeSize }
- })
- await onSuccess?.(data, variables, context)
- },
- async onError(data, variables, context) {
- if (onError === undefined) {
- toast.error(`Failed to resize project disk: ${data.message}`)
- } else {
- onError(data, variables, context)
- }
- },
- ...options,
- }
- )
+ return useMutation({
+ mutationFn: (vars) => resizeProjectDisk(vars),
+ async onSuccess(data, variables, context) {
+ const { projectRef } = variables
+ queryClient.setQueriesData(usageKeys.usage(projectRef), (prev: any) => {
+ if (!prev) return prev
+ return { ...prev, disk_volume_size_gb: variables.volumeSize }
+ })
+ await onSuccess?.(data, variables, context)
+ },
+ async onError(data, variables, context) {
+ if (onError === undefined) {
+ toast.error(`Failed to resize project disk: ${data.message}`)
+ } else {
+ onError(data, variables, context)
+ }
+ },
+ ...options,
+ })
}
diff --git a/apps/studio/data/config/project-postgrest-config-query.ts b/apps/studio/data/config/project-postgrest-config-query.ts
index fa31a67be08..67c14ee48f1 100644
--- a/apps/studio/data/config/project-postgrest-config-query.ts
+++ b/apps/studio/data/config/project-postgrest-config-query.ts
@@ -39,11 +39,9 @@ export const useProjectPostgrestConfigQuery = = {}
) =>
- useQuery(
- configKeys.postgrest(projectRef),
- ({ signal }) => getProjectPostgrestConfig({ projectRef }, signal),
- {
- enabled: enabled && typeof projectRef !== 'undefined',
- ...options,
- }
- )
+ useQuery({
+ queryKey: configKeys.postgrest(projectRef),
+ queryFn: ({ signal }) => getProjectPostgrestConfig({ projectRef }, signal),
+ enabled: enabled && typeof projectRef !== 'undefined',
+ ...options,
+ })
diff --git a/apps/studio/data/config/project-postgrest-config-update-mutation.ts b/apps/studio/data/config/project-postgrest-config-update-mutation.ts
index 7cc3fafc694..510bbb08247 100644
--- a/apps/studio/data/config/project-postgrest-config-update-mutation.ts
+++ b/apps/studio/data/config/project-postgrest-config-update-mutation.ts
@@ -59,7 +59,8 @@ export const useProjectPostgrestConfigUpdateMutation = ({
ProjectPostgrestConfigUpdateData,
ResponseError,
ProjectPostgrestConfigUpdateVariables
- >((vars) => updateProjectPostgrestConfig(vars), {
+ >({
+ mutationFn: (vars) => updateProjectPostgrestConfig(vars),
async onSuccess(data, variables, context) {
const { projectRef } = variables
queryClient.invalidateQueries(configKeys.postgrest(projectRef))
diff --git a/apps/studio/data/config/project-settings-v2-query.ts b/apps/studio/data/config/project-settings-v2-query.ts
index 759c0a784c7..2037b326d46 100644
--- a/apps/studio/data/config/project-settings-v2-query.ts
+++ b/apps/studio/data/config/project-settings-v2-query.ts
@@ -49,19 +49,17 @@ export const useProjectSettingsV2Query = (
'*'
)
- return useQuery(
- configKeys.settingsV2(projectRef),
- ({ signal }) => getProjectSettings({ projectRef }, signal),
- {
- enabled: enabled && typeof projectRef !== 'undefined',
- refetchInterval(_data) {
- const data = _data as ProjectSettings | undefined
- const apiKeys = data?.service_api_keys ?? []
- const interval =
- canReadAPIKeys && data?.status !== 'INACTIVE' && apiKeys.length === 0 ? 2000 : 0
- return interval
- },
- ...options,
- }
- )
+ return useQuery({
+ queryKey: configKeys.settingsV2(projectRef),
+ queryFn: ({ signal }) => getProjectSettings({ projectRef }, signal),
+ enabled: enabled && typeof projectRef !== 'undefined',
+ refetchInterval(_data) {
+ const data = _data as ProjectSettings | undefined
+ const apiKeys = data?.service_api_keys ?? []
+ const interval =
+ canReadAPIKeys && data?.status !== 'INACTIVE' && apiKeys.length === 0 ? 2000 : 0
+ return interval
+ },
+ ...options,
+ })
}
diff --git a/apps/studio/data/config/project-storage-config-query.ts b/apps/studio/data/config/project-storage-config-query.ts
index be158636207..82cc191b194 100644
--- a/apps/studio/data/config/project-storage-config-query.ts
+++ b/apps/studio/data/config/project-storage-config-query.ts
@@ -45,8 +45,9 @@ export const useProjectStorageConfigQuery = (
...options
}: UseQueryOptions = {}
) =>
- useQuery(
- configKeys.storage(projectRef),
- ({ signal }) => getProjectStorageConfig({ projectRef }, signal),
- { enabled: enabled && IS_PLATFORM && typeof projectRef !== 'undefined', ...options }
- )
+ useQuery({
+ queryKey: configKeys.storage(projectRef),
+ queryFn: ({ signal }) => getProjectStorageConfig({ projectRef }, signal),
+ enabled: enabled && IS_PLATFORM && typeof projectRef !== 'undefined',
+ ...options,
+ })
diff --git a/apps/studio/data/config/project-storage-config-update-mutation.ts b/apps/studio/data/config/project-storage-config-update-mutation.ts
index 3ded8ea5326..c5fd5406565 100644
--- a/apps/studio/data/config/project-storage-config-update-mutation.ts
+++ b/apps/studio/data/config/project-storage-config-update-mutation.ts
@@ -47,7 +47,8 @@ export const useProjectStorageConfigUpdateUpdateMutation = ({
ProjectStorageConfigUpdateUpdateData,
ResponseError,
ProjectStorageConfigUpdateUpdateVariables
- >((vars) => updateProjectStorageConfigUpdate(vars), {
+ >({
+ mutationFn: (vars) => updateProjectStorageConfigUpdate(vars),
async onSuccess(data, variables, context) {
const { projectRef } = variables
await queryClient.invalidateQueries(configKeys.storage(projectRef))
diff --git a/apps/studio/data/config/project-temp-disable-read-only-mutation.ts b/apps/studio/data/config/project-temp-disable-read-only-mutation.ts
index e5827a4f2db..3769f48ec59 100644
--- a/apps/studio/data/config/project-temp-disable-read-only-mutation.ts
+++ b/apps/studio/data/config/project-temp-disable-read-only-mutation.ts
@@ -29,21 +29,19 @@ export const useDisableReadOnlyModeMutation = ({
'mutationFn'
> = {}) => {
const queryClient = useQueryClient()
- return useMutation(
- (vars) => tempDisableReadOnlyMode(vars),
- {
- async onSuccess(data, variables, context) {
- setTimeout(() => queryClient.invalidateQueries(usageKeys.resourceWarnings()), 2000)
- await onSuccess?.(data, variables, context)
- },
- async onError(data, variables, context) {
- if (onError === undefined) {
- toast.error(`Failed to disable read only mode: ${data.message}`)
- } else {
- onError(data, variables, context)
- }
- },
- ...options,
- }
- )
+ return useMutation({
+ mutationFn: (vars) => tempDisableReadOnlyMode(vars),
+ async onSuccess(data, variables, context) {
+ setTimeout(() => queryClient.invalidateQueries(usageKeys.resourceWarnings()), 2000)
+ await onSuccess?.(data, variables, context)
+ },
+ async onError(data, variables, context) {
+ if (onError === undefined) {
+ toast.error(`Failed to disable read only mode: ${data.message}`)
+ } else {
+ onError(data, variables, context)
+ }
+ },
+ ...options,
+ })
}
diff --git a/apps/studio/data/config/project-unpause-postgres-versions-query.ts b/apps/studio/data/config/project-unpause-postgres-versions-query.ts
index 72aa72dc42a..9ddcc6b1d18 100644
--- a/apps/studio/data/config/project-unpause-postgres-versions-query.ts
+++ b/apps/studio/data/config/project-unpause-postgres-versions-query.ts
@@ -39,12 +39,10 @@ export const useProjectUnpausePostgresVersionsQuery = = {}
) => {
- return useQuery(
- configKeys.projectUnpausePostgresVersions(projectRef),
- ({ signal }) => getPostgresUnpauseVersions({ projectRef }, signal),
- {
- enabled: enabled && typeof projectRef !== 'undefined',
- ...options,
- }
- )
+ return useQuery({
+ queryKey: configKeys.projectUnpausePostgresVersions(projectRef),
+ queryFn: ({ signal }) => getPostgresUnpauseVersions({ projectRef }, signal),
+ enabled: enabled && typeof projectRef !== 'undefined',
+ ...options,
+ })
}
diff --git a/apps/studio/data/config/project-upgrade-eligibility-query.ts b/apps/studio/data/config/project-upgrade-eligibility-query.ts
index 90ddc5962c3..53516146481 100644
--- a/apps/studio/data/config/project-upgrade-eligibility-query.ts
+++ b/apps/studio/data/config/project-upgrade-eligibility-query.ts
@@ -39,17 +39,15 @@ export const useProjectUpgradeEligibilityQuery = = {}
) => {
const { data: project } = useProjectDetailQuery({ ref: projectRef })
- return useQuery(
- configKeys.upgradeEligibility(projectRef),
- ({ signal }) => getProjectUpgradeEligibility({ projectRef }, signal),
- {
- enabled:
- enabled &&
- project !== undefined &&
- project.status === PROJECT_STATUS.ACTIVE_HEALTHY &&
- typeof projectRef !== 'undefined' &&
- IS_PLATFORM,
- ...options,
- }
- )
+ return useQuery