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

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

Open
Foresteam opened this issue Jun 1, 2023 · 0 comments
Open

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

Foresteam opened this issue Jun 1, 2023 · 0 comments

Comments

@Foresteam
Copy link

Foresteam commented Jun 1, 2023

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, then:

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
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

1 participant