mirror of
https://github.com/supabase/supabase.git
synced 2026-05-23 10:21:37 +08:00
* Move all studio files from /studio to /apps/studio. * Move studio specific prettier ignores. * Fix the ui references from studio. * Fix the css imports. * Fix all package.json issues. * Fix the prettier setup for the studio app. * Add .turbo folder to prettierignore. * Fix the github workflows.
33 lines
928 B
TypeScript
33 lines
928 B
TypeScript
import { toast } from 'react-hot-toast'
|
|
import { useMutation, UseMutationOptions } from '@tanstack/react-query'
|
|
import { executeSql, ExecuteSqlData, ExecuteSqlVariables } from './execute-sql-query'
|
|
import { ResponseError } from 'types'
|
|
|
|
/* Execute Query */
|
|
|
|
export const useExecuteSqlMutation = ({
|
|
onSuccess,
|
|
onError,
|
|
...options
|
|
}: Omit<
|
|
UseMutationOptions<ExecuteSqlData, ResponseError, ExecuteSqlVariables>,
|
|
'mutationFn'
|
|
> = {}) => {
|
|
return useMutation<ExecuteSqlData, ResponseError, ExecuteSqlVariables>(
|
|
(args) => executeSql(args),
|
|
{
|
|
async onSuccess(data, variables, context) {
|
|
await onSuccess?.(data, variables, context)
|
|
},
|
|
async onError(data, variables, context) {
|
|
if (onError === undefined) {
|
|
toast.error(`Failed to execute SQL: ${data.message}`)
|
|
} else {
|
|
onError(data, variables, context)
|
|
}
|
|
},
|
|
...options,
|
|
}
|
|
)
|
|
}
|