Get parts on profile to update when user saves a new part

This commit is contained in:
Kurt Hutten
2020-12-30 12:45:47 +11:00
parent fff0956746
commit 62b26b969e
7 changed files with 55 additions and 33 deletions

View File

@@ -0,0 +1,22 @@
import { useQuery } from '@redwoodjs/web'
import { useAuth } from '@redwoodjs/auth'
const QUERY = gql`
query FIND_USER_BY_ID($id: String!) {
user: user(id: $id) {
id
image
userName
name
}
}
`
export default function () {
const { currentUser } = useAuth()
const { data, loading } = useQuery(QUERY, {
skip: !currentUser?.sub,
variables: { id: currentUser?.sub },
})
return { user: data?.user, loading }
}