1
0
ohmyform/ui/components/use.imerative.query.ts
Michael Schramm 9c4c325e5a
Switch to single branch (#221)
* remove submodules
* add api and ui files
* update github actions
* use sparse checkout
* update node setup
* update checkout
* update docker
* change permissions
* update mariadb health check
* update changelog
2023-12-02 19:22:40 +01:00

17 lines
451 B
TypeScript

import { ApolloQueryResult, useQuery } from '@apollo/client'
import { DocumentNode } from 'graphql'
import { useCallback } from 'react'
export const useImperativeQuery: <TData, TVariables>(
query: DocumentNode
) => (variables: TVariables) => Promise<ApolloQueryResult<TData>> = (query) => {
const { refetch } = useQuery(query, { skip: true })
return useCallback(
(variables) => {
return refetch(variables)
},
[refetch]
)
}