Skip to content

Commit

Permalink
feat(profile): add query types
Browse files Browse the repository at this point in the history
  • Loading branch information
zerubeus committed May 9, 2020
1 parent 48f6217 commit 6cb8304
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/components/modules/Profile/Profile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { FirebaseUser } from 'services/auth'
import TextField from '@material-ui/core/TextField'
import { TApi_Users } from '../../../graphqlTypes'
import { useFormik } from 'formik'
import { MeQuery, MeQueryVariables } from '../../../hasuraTypes'

type PropType = {
me: FirebaseUser
Expand Down Expand Up @@ -71,10 +72,13 @@ const NEW_USER_QUERY = gql`
const Profile: React.FC<PropType> = ({ me }) => {
const [isEditProfile, setEditProfile] = useState(false)
const classes = useStyles()
const currentUserId = useMemo(() => _get(me, 'uid'), [me])
const { loading: queryLoading, error: queryError, data: queryData } = useQuery(USER_QUERY, {
variables: { id: currentUserId },
})
const currentUserId = useMemo(() => _get(me, 'uid', ''), [me])
const { loading: queryLoading, error: queryError, data: queryData } = useQuery<MeQuery, MeQueryVariables>(
USER_QUERY,
{
variables: { id: currentUserId },
}
)

const meData: TApi_Users = _get(queryData, 'users.[0]')

Expand Down

0 comments on commit 6cb8304

Please sign in to comment.