44d74e399f
* Remove React redundant import on `analyze-bundles` example Co-authored-by: Marcus Silva <mvfsillva@gmail.com> * Remove React redundant import on `api-routes-apollo-server-and-client-auth` example Co-authored-by: Marcus Silva <mvfsillva@gmail.com> * Remove React redundant import on `custom-server` example Co-authored-by: Marcus Silva <mvfsillva@gmail.com> * Remove React redundant import on `custom-server-actionhero` example Co-authored-by: Marcus Silva <mvfsillva@gmail.com> Co-authored-by: Marcus Silva <mvfsillva@gmail.com>
29 lines
665 B
JavaScript
29 lines
665 B
JavaScript
import { useEffect } from 'react'
|
|
import { useMutation, useApolloClient } from '@apollo/react-hooks'
|
|
import gql from 'graphql-tag'
|
|
import { useRouter } from 'next/router'
|
|
import { withApollo } from '../apollo/client'
|
|
|
|
const SignOutMutation = gql`
|
|
mutation SignOutMutation {
|
|
signOut
|
|
}
|
|
`
|
|
|
|
function SignOut() {
|
|
const client = useApolloClient()
|
|
const router = useRouter()
|
|
const [signOut] = useMutation(SignOutMutation)
|
|
|
|
useEffect(() => {
|
|
signOut().then(() => {
|
|
client.resetStore().then(() => {
|
|
router.push('/signin')
|
|
})
|
|
})
|
|
}, [signOut, router, client])
|
|
|
|
return <p>Signing out...</p>
|
|
}
|
|
|
|
export default withApollo(SignOut)
|