I want to run my index.js file to access graphql endpoints so i can be able to query the data, access it but i keep getting the ‘ module not found’ error code.
import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App.jsx';
import 'bootstrap/dist/css/bootstrap.css';
import { ApolloClient, InMemoryCache, ApolloProvider } from '@apollo/client';
import { ApolloServer, gql } from 'apollo-server-express';
import { typeDefs } from './Schema/type-defs';
import { resolvers } from './Schema/resolvers';
const server = new ApolloServer({
typeDefs,
resolvers,
});
const client = new ApolloClient({
uri: 'https://localhost:4000',
cache: new InMemoryCache(),
});
ReactDOM.render(
<ApolloProvider client={client}>
<App />
</ApolloProvider>,
document.getElementById('root')
);
console.log('GraphQL server running at https://localhost:4000/graphql');
I have tried checking if the file is in the directory where nodejs can find it.
1
1 Answer
I’m assuming you have issues with importing from apollo-server-express. Per the documentation, this package is now deprecated. You should use @apollo/server instead.
On a related note, you are mixing server code into your React application, which will run on the client. These two things should run as completely separate applications.


Did you mean
nodemon? Also it would be helpful to cut and paste errors verbatim rather than paraphrasing them. Importantly which module is not found?1 hour ago