apollographql / apollo-tooling

✏️ Apollo CLI for client tooling (Mostly replaced by Rover)
https://apollographql.com
MIT License
3.04k stars 470 forks source link

VSCode commands not found: extension not loading correctly? #690

Closed cspotcode closed 6 years ago

cspotcode commented 6 years ago

In VSCode, I just upgraded to the Apollo extension version 1.1.9. Trying to invoke both contributed commands shows a VSCode "command not found" error.

image

image

How do I view logs for the extension? I'm not sure how to diagnose this issue.

vschoettke commented 6 years ago

The published extension is invalid. tl;dr the compiled files are missing.

I saw the following in the Developer Tools:

[Extension Host] Here is the error stack:  Error: Cannot find module '/Users/vincent/.vscode/extensions/apollographql.vscode-apollo-1.1.9/lib/extension'
    at Function.Module._resolveFilename (module.js:543:15)
    at Function.Module._load (module.js:473:25)

Looking into the corresponding extension folder I saw that there is no lib folder. Checking with the downloadable .vsix file confirmed this.

You can get a working version from the source if you build the extension yourself with the npm install && npm run package-extension (the result vscode-apollo-1.1.9.vsix file lands in the vscode-apollo folder. For whatever reason I also had to copy the node_modules/apollo-tools inside the extension to node_modules/@apollographql/apollo-tools.

cspotcode commented 6 years ago

Oh bummer. Is there a place to download an older version of the .vscx?

On Mon, Nov 12, 2018, 6:00 PM Vincent Schoettke notifications@github.com wrote:

The published extension is invalid. tl;dr the compiled files are missing.

I saw the following in the Developer Tools:

[Extension Host] Here is the error stack: Error: Cannot find module '/Users/vincent/.vscode/extensions/apollographql.vscode-apollo-1.1.9/lib/extension' at Function.Module._resolveFilename (module.js:543:15) at Function.Module._load (module.js:473:25)

Looking into the corresponding extension folder I saw that there is no lib folder. Checking with the downloadable .vsix file confirmed this.

You can get a working version from the source if you build the extension yourself with the npm install && npm run package-extension (the result vscode-apollo-1.1.9.vsix file lands in the vscode-apollo folder. For whatever reason I also had to copy the node_modules/apollo-tools inside the extension to node_modules/@apollographql/apollo-tools.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/apollographql/apollo-tooling/issues/690#issuecomment-438059840, or mute the thread https://github.com/notifications/unsubscribe-auth/AAW-uGAjfUm5yknJUogBHF5xXGqvit9Nks5uuf2HgaJpZM4YahxU .

vschoettke commented 6 years ago

1.1.7 is available here: https://marketplace.visualstudio.com/_apis/public/gallery/publishers/apollographql/vsextensions/vscode-apollo/1.1.7/vspackage

trevor-scheer commented 6 years ago

Apologies! Looks like I published a bad build earlier today. This should be fixed now with 1.1.10. Thank you for submitting the issue and suggesting workarounds in the mean time 👍

NgxDev commented 5 years ago

:( still having the same issue in 1.4.0 also tried 1.1.7 and 1.1.10 as suggested above, but it's all the same: command 'apollographql/reloadService' not found

trevor-scheer commented 5 years ago

@MrCroft is this still happening for you in v1.4.5? We haven't heard any other complaints about this, nor have I been able to reproduce. If you don't mind, try deleting the downloaded version as well before reinstalling. On a mac, the extensions are stored at ~/.vscode/extensions/apollographql.vscode-apollo-x.x.x

furier commented 5 years ago

Also having issues, and I just followed @trevor-scheer advice to delete the extension folder and reinstall the extension.

image

here is my apollo.config.js file at the root of the angular project alongside package.json

module.exports = {
  client: {
    service: {
      name: 'bs-graphql',
      localSchemaFile: './schema.json',
    },
    includes: ['./src/app/**/*.gql', './src/app/**/*.graphql'],
  }
};

When I have the apollo.config.js file open in the editor and click the apollographql button on the bar at the bottom of VS Code, like this.

image

The console outputs:

🚀 Apollo GraphQL v1.4.5
------------------------------
✅ Service Loaded!
🆔 Service ID: bs-graphql
🏷 Schema Tag: current
📈 Number of Types: 535 (0 client types)

However when I do the same having any other file open than apollo.config.js

The console outputs:

🚀 Apollo GraphQL v1.4.5
------------------------------
❌ 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://bit.ly/2ByILPj).
trevor-scheer commented 5 years ago

@furier thanks for that info!

A couple things to try:

Is it possible for you to share this project with me to reproduce locally? Or provide a minimum reproduction?

warmbowski commented 5 years ago

I have the exact same problems as @furier. Same Apollo GraphQL version. One of the other oddities is that when I switch to the OUTPUT tab, in the pulldown of services, I see Apollo GraphQL listed twice. One has no output, but the other has the output like in @furier screenshot. I think the service only loads one when VSCode starts up (the one with no output), but if you click the ApolloGraphQL in the status bar, the second one appears in the list and contains the output. Not sure if that's a problem, but wanted to mention it because that seems weird.

Unlike the OP, two of the three Apollo commands work for me (only Apollo:Show Status fails).

I also wanted to mention that there is another issue that mentions that folks can get Apollo GraphQL to work with Engine, but not with remote or local schema (#902 ), and so I wanted to mention that here in case theres some connection.

warmbowski commented 5 years ago

@furier, I got it working. It was a problem in the includes config. I made the change from includes: ['./examples/**/*.{ts,tsx}'], to includes: ['examples/**/*.{ts,tsx}'], and my syntax highlighting and auto-complete started working. And I no longer got the "❌ Service stats could not be loaded. . ." error message when in my component files. So it seems that the includes globs cannot start with ./. This seems like a bug to me, since I would expect to be able to use either syntax (I prefer ./).

warmbowski commented 5 years ago

I'm pretty sure that the problem lies in the line of code linked below, and it's based on the way path.relative() works. So there will be no match with globs that start with ./ in the apollo-language-server.

https://github.com/apollographql/apollo-tooling/blob/master/packages/apollo-language-server/src/fileSet.ts#L31

warmbowski commented 5 years ago

Or it could be the way minimatch() treats ./relative/**/*.{ts,tsx} and relative/**/*.{ts,tsx}differently, when they are essentially the same. I can't decide and would love to hear some other folks' input.

trevor-scheer commented 5 years ago

@warmbowski thanks for looking around, this is great information. Would you mind opening a new issue for this specifically? We'd love a PR that fixes this if anyone is interested in solving the issue 😄

furier commented 5 years ago

@trevor-scheer thanks it works now with the path changes. :)

Relaxe111 commented 5 years ago

I have same issue with v1.6.4 also it was with v.1.5.2 it works with v 1.5.0 here is my appolo.config.js:

module.exports = {
    client: {
        service: { 
          name: 'localhost',
          url: "http://localhost:5000/graphql", 

        },
        skipSSLValidation: true,
        excludes: ['node_modules/**/*'],
        includes: ["src/**/*.{ts,gql,tsx,js,jsx,graphql}"],
      },
    };

for v 1.6.4:

🚀 Apollo GraphQL v1.6.4
------------------------------
❌ 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://bit.ly/2ByILPj).

for v 1.5.0:

------------------------------
🚀 Apollo GraphQL v1.5.0
------------------------------
✅ Service Loaded!
🆔 Service ID: localhost
🏷 Schema Tag: current
📈 Number of Types: 223 (0 client types)
------------------------------
peterholak commented 5 years ago

Had this happen on Windows recently with the latest version. Uninstalling the extension, restarting VS Code, and reinstalling fixed the problem.

SpaghettiC0des commented 4 years ago

Had this happen on Windows recently with the latest version. Uninstalling the extension, restarting VS Code, and reinstalling fixed the problem.

This resolves the issue for me, after an hour of frustration. Thanks, man!

cglacet commented 3 years ago

I still have the issue, re-installing does temporarily solve the issue, but after a while it crashes again. (version v1.19.6)

In case that matters, it's a test server running locally, and I can still ping the server for its schema manually so it's not a server problem.

Restarting vscode also seems to work.