apollographql / apollographql/apollo-tooling

TS + Vite + Vue: ❌ Service stats could not be loaded

Open
#2,683 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
3k
Forks
460
PR merge metrics
No merged PRs in 30d

Description

**Intended outcome:**
Intellisense should work, extension shouldn't error.

**Actual outcome:**
Extension suggests me reconsidering my config file or even creating one, but the fact is i already have the file, and it was tested and did work in a CommonJS project, where i didn't use any bundlers and the type of project was default (not "module").

When i simply copy-pasted it, it began to argue like this:
```
[ERROR] A config file failed to load with options: {"configPath":"/mnt/nhome/foresteam/Documents/nodejs/vitrina/apolloVue","requireConfig":true}.
The error was: Error [ERR_REQUIRE_ESM]: require() of ES Module /mnt/nhome/foresteam/Documents/nodejs/vitrina/apolloVue/apollo.config.js from /home/foresteam/.vscode-oss/extensions/apollographql.vscode-apollo-1.19.11/node_modules/import-fresh/index.js not supported.
apollo.config.js is treated as an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which declares all .js files in that package scope as ES modules.
Instead rename apollo.config.js to end in .cjs, change the requiring code to use dynamic import() which is available in all CommonJS modules, or change "type": "module" to "type": "commonjs" in /mnt/nhome/foresteam/Documents/nodejs/vitrina/apolloVue/package.json to treat all .js files as CommonJS (using .mjs for all ES modules instead).

at Object.loadConfig (/home/foresteam/.vscode-oss/extensions/apollographql.vscode-apollo-1.19.11/lib/language-server/config/loadConfig.js:44:27)
at async GraphQLWorkspace.reloadProjectForConfig (/home/foresteam/.vscode-oss/extensions/apollographql.vscode-apollo-1.19.11/lib/language-server/workspace.js:108:22)
at /home/foresteam/.vscode-oss/extensions/apollographql.vscode-apollo-1.19.11/src/extension.ts:80:17
at handleNotification (/home/foresteam/.vscode-oss/extensions/apollographql.vscode-apollo-1.19.11/node_modules/vscode-jsonrpc/lib/main.js:489:43)
at processMessageQueue (/home/foresteam/.vscode-oss/extensions/apollographql.vscode-apollo-1.19.11/node_modules/vscode-jsonrpc/lib/main.js:260:17)
at Immediate._onImmediate (/home/foresteam/.vscode-oss/extensions/apollographql.vscode-apollo-1.19.11/node_modules/vscode-jsonrpc/lib/main.js:247:13)
```
Since i renamed the file to **.cjs**, i simply get this, no matter what i do to the config:
```
❌ Service stats could not be loaded. This may be because you're missing an apollo.config.js file or it is misconfigured. For more information about configuring Apollo projects, see the guide here (https://go.apollo.dev/t/config).
```
If i "reload schema", it prints this:
```
⚠️ It looks like there are 0 files associated with this Apollo Project. This may be because you don't have any files yet, or your includes/excludes fields are configured incorrectly, and Apollo can't find your files. For help configuring Apollo projects, see this guide: https://go.apollo.dev/t/config
```

**How to reproduce the issue:**

Download [project.tar.gz](https://github.com/apollographql/apollo-tooling/files/11628579/issue.tar.gz), then:
```bash
yarn -D
```
The not working intellisense can be seen in ```src/test.graphql``` and ```src/App.vue```.

**Versions**

* apollographql.vscode-apollo v1.19.11
* graphql.vscode-graphql-syntax v1.1.0
* vue.volar v1.6.4
* vue.vscode-typescript-vue-plugin v1.6.5
* antfu.vite v0.2.5
* **VSCodium: v1.78.2, x64**

Contributor guide

Open the contributing guide

Research direction

Run `yarn -D` with the provided project archive, then inspect the Apollo configuration and the failing examples in `src/test.graphql` and `src/App.vue`. Trace the configuration-loading path shown in `lib/language-server/config/loadConfig.js` and verify behavior for the project's module format. Done means IntelliSense works without the service-stats or zero-files errors in the reproduction.

Written by the indexing model from the issue text.

Assessment

Tech stack
graphql, typescript
Domain
developer-experience, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.