1.0.9 • Published 3 years ago
apollo-jotai v1.0.9
Jotai Apollo
Instalation
$ yarn add apollo-jotai
$ npm apollo-jotai
Usage
import { useAtomWithApollo, jotaiApolloAtom } from 'apollo-jotai'
const atom = jotaiApolloAtom(async (get, set, client) => {
const { data } = await client.query<Query, QueryVariables>({ query: QueryDocument })
return data
})
const Component = () => {
const [{ data, loading, error }, request] = useAtomWithApollo(atom)
useEffect(() => {
request()
}, [])
...
}