Skip to content

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

@Foresteam

Description

@Foresteam

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

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