import { ApolloClient, HttpLink, InMemoryCache, gql } from '@apollo/client';
import { ApolloProvider } from '@apollo/client/react';
import List from './List';
import './App.css';
import { Suspense } from 'react';
import { ErrorBoundary } from 'react-error-boundary';

function App() {
  const client = new ApolloClient({
    link: new HttpLink({ uri: 'http://localhost:3001/graphql' }),
    cache: new InMemoryCache(),
  });

  return (
    <ApolloProvider client={client}>
      <Suspense fallback={<div>Lade Bücher...</div>}>
        <ErrorBoundary fallback={<div>Es ist ein Fehler aufgetreten</div>}>
          <List />
        </ErrorBoundary>
      </Suspense>
    </ApolloProvider>
  );
}

export default App;

