Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to use apollo.config.js with Vite React app #2688

Open
PuffCab opened this issue Sep 27, 2023 · 1 comment
Open

how to use apollo.config.js with Vite React app #2688

PuffCab opened this issue Sep 27, 2023 · 1 comment

Comments

@PuffCab
Copy link

PuffCab commented Sep 27, 2023

I am trying to use Apollo extension in a React application created with Vite.

I create apollo.config.js at the root folder, following the intructions, like this :
module.exports = { client: { service: { name: "my-graphql-app", url: "http://localhost:4000/graphql", }, }, };

But i get the error "'module' is not defined." , since it is not an E6 Module.
Therefore Apollo extension cannot find the file, getting this error from the extension :
Service stats could not be loaded. This may be because you're missing an apollo.config.js file or it is misconfigured.

How could I convert it to an E6 Module, or how should i create the config file to be able to use it in a React App using Vite?

If I use CreateReactApp to create the React app, then there is no issue.

@idonov
Copy link

idonov commented Dec 30, 2023

Just had the same issue with Vite.
Simple fix, just rename it to apollo.config.cjs so Vite will treat it as CommonJS

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants