import React from 'react'; import './App.css'; import {gql, useQuery, useSubscription} from "@apollo/client"; interface User { id: number code: string name: string } interface Account { id: number code: string balance: number user: User } interface AccountResult { fetchAccounts: Array } const ACCOUNTS = gql` { fetchAccounts { id code balance user { code name } } } ` const HELLO = gql` subscription { hello } ` function App() { const {error, loading, data} = useQuery(ACCOUNTS) // const {error, loading, data} = useSubscription(HELLO) console.log(data) return ( <>

Accounts

{ loading || !data ?

Loading...

: data.fetchAccounts.map(account => ( <>
Account ID: {account.id}
Account Code: {account.code}
Account User: {account.user.name}
) ) //

{`${data.hello}`}

} ); } export default App;