text: import React from "react";
  import ReactDOM from "react-dom";
  import "./index.css";
  import App from "./App";
  
  import {
    ApolloClient,
    InMemoryCache,
    ApolloProvider,
    HttpLink,
    
    createHttpLink,
  } from "@apollo/client";
  import { setContext } from "@apollo/client/link/context";
  import { onError } from "@apollo/client/link/error";
  
  import "./style/style.css";
  
  const errorLink = onError(({ graphqlErrors, networkError }) => {
    if (graphqlErrors) {
      graphqlErrors.map(({ message, location, path }) => {
        alert(`Graphql Error ${message}`);
      });
    }
  });
  
  // const link = from([
  //   errorLink,
  //   new HttpLink({
  //     uri: "http://localhost:8000/graphql",
  //     credentials: "same-origin",
  //   }),
  // ]);
  
  // const client = new ApolloClient({
  //   cache: new InMemoryCache(),
  //   uri: "http://localhost:8000/graphql",
  //   // link: link,
  //   // fetchOptions: {
  //   //   mode: "no-cors",
  //   // },
  // });
  
  
  const httpLink = createHttpLink({
    uri: "http://localhost:8000/graphql",
  });
  
  const authLink = setContext((_, { headers }) => {
    // get the authentication token from local storage if it exists
    const token = localStorage.getItem("jwtToken");
    // return the headers to the context so httpLink can read them
    return {
      headers: {
        ...headers,
        Authorization: token ? `Bearer ${token}` : "",
      },
    };
  });
  
  export const client = new ApolloClient({
    link: authLink.concat(httpLink),
    cache: new InMemoryCache(),
    fetchOptions: {
      mode: "no-cors",
    },
  });
  
  ReactDOM.render(
    <React.StrictMode>
      <ApolloProvider client={client}>
        <App />
      </ApolloProvider>
    </React.StrictMode>,
    document.getElementById("root")
  );
  