Skip to content

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

@PuffCab

Description

@PuffCab

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions