Hey Ciox how are you?
As the issue mention, you should wrap your <App /> around <Apolloprovide> like this:
import React from "react";
import ReactDOM from "react-dom";
import { ApolloProvider } from "@apollo/react-hooks";
import App from "./containers/App";
import client from "./utils/apolloClient";
import { BrowserRouter as Router } from "react-router-dom";
import "./index.css";
ReactDOM.render(
<Router>
<ApolloProvider client={client}>
<App />
</ApolloProvider>
</Router>,
document.getElementById("root")
);
You must import the client:
import client from "./utils/apolloClient";
and:
<ApolloProvider client={client}>
However you need to create this client in the ./src/utils/apolloClient.js file:
import { ApolloClient } from "apollo-client";
import { InMemoryCache } from "apollo-cache-inmemory";
import { HttpLink } from "apollo-link-http";
const cache = new InMemoryCache();
const link = new HttpLink({
uri: `${process.env.REACT_APP_BACKEND_URL}/graphql`
});
const client = new ApolloClient({
cache,
link
});
export default client;
Hope it will help you!