diff --git a/src/apollo/defs.ts b/src/apollo/defs.ts index 4c4abc1..e6f0504 100644 --- a/src/apollo/defs.ts +++ b/src/apollo/defs.ts @@ -43,6 +43,10 @@ const USER = gql` email id name + forms { + id + title + } } } ` diff --git a/src/components/UserPage/index.tsx b/src/components/UserPage/index.tsx index 4bd5c57..7a86e92 100644 --- a/src/components/UserPage/index.tsx +++ b/src/components/UserPage/index.tsx @@ -1,20 +1,39 @@ import { useQuery } from '@apollo/client' import React from 'react' import { USER } from '../../apollo' +import { User } from '../../apollo/typeDefs.gen' + +interface UserQuery { + user: User +} const UserPage: React.FC = () => { - const { data, error, loading } = useQuery(USER) + const { data, error, loading } = useQuery(USER) if (loading) return

Loading...

if (error) return

{error.message}

- const { name, email, id } = data.user + const { user } = data! return (
-

Username: {name}

-

Email: {email}

-

User ID: {id}

+

Username: {user.name}

+

Email: {user.email}

+

User ID: {user.id}

+ {user.forms && ( + <> +

Forms list

+ + + )}
) }