Search code examples
reactjsgraphqlapollo

'ApolloProvider' is not exported from 'apollo-client' in React


When I run my client, it gives me this error

error message

This is what's in my App.js,

import {ApolloClient, InMemoryCache, ApolloProvider} from 'apollo-client'


//--------styles-------
import './App.css';


//Apollo client setup
const client = new ApolloClient({
  uri: 'http://localhost:4000/graphql',
   cache: new InMemoryCache( ),
});


function App() {
  return (

    <ApolloProvider client={client}>
       <div className="App">
          <h1>Hellooooo</h1>
        </div>
    </ApolloProvider>
   
  );
}

export default App;

I created another app with graphql, it worked perfectly fine with this v

import { ApolloClient, InMemoryCache, ApolloProvider } from '@apollo/client';

but when I tried to import like this in my new app, it didnt work either. Please help me figure out what the issue is. Appreciate your help.


Solution

  • I deleted node modules folder and reinstalled all the modules. I didn't get the error afterwards. Not sure what the issue was, but this worked.