vscode-graphql icon indicating copy to clipboard operation
vscode-graphql copied to clipboard

Unable to configure apollo extension

Open mklemarczyk opened this issue 1 year ago โ€ข 33 comments

Hello, I got the last update 2.2.0 and it does not work anymore for my project.

I use the vs code workspace and my apollo config file is in the root folder. I use nx workspace folder structure fo angular project, that means the folder structure is quite deep.

I can provide more details later in the afternoon. Error is written to the console that it does not find the configuration file, even if you open the configuration file. I couldnโ€™t find any helpful information in the verbose logs of the extension.

Last extension version that works for me is 1.20.0. I use apollo client npm in version 3.11.2 and apollo-angular in version 7.0.2.

Any version of extension 2.x has the same issue. I seen that your extension has very low reputation at VS Code Marketplace.

mklemarczyk avatar Aug 29 '24 08:08 mklemarczyk

Hi Maciej,

it would be great if you could share the name & contents of your configuration file (of course without sensitive details), an idea of your folder layout (where is the config file, which folder do you have open), and the exact error message. I'll look into it as soon as I have more information :)

phryneas avatar Aug 29 '24 08:08 phryneas

module.exports = {
  client: {
    service: {
      localSchemaFile: './schema.gql',
    },
  },
  exclude: ['**/*.e2e-spec.ts'],
};

I am also having similar experience. I haven't try earlier version cause i have some files to exclude(which seems not working option on version 1.x). I am trying to link with local schema without using Apollo schema registry.

I have logs which seems not that helpful

.vscode/extensions/apollographql.vscode-apollo-2.2.0/lib/language-server/server.js:1035
`)}t(Swn,"dedentBlockStringValue");function Ewn(a){le  //...and so on
[Error - 6:14:03 PM] Server process exited with code 1.
[Error - 6:14:03 PM] Client Apollo GraphQL: connection to server is erroring.
Channel closed

my apollo/server version is: "@apollo/server": 4.9.5,

Can i get any help?

bhpark1013 avatar Aug 30 '24 09:08 bhpark1013

I'm going to do a bit of digging what code that points to. Meanwhile: is this already from the "Apollo" output or is there maybe additional information there? image

phryneas avatar Aug 30 '24 11:08 phryneas

@bhpark1013 also, could I please get the full unshortened error with the full stack trace? That might actually tell me something :)

phryneas avatar Aug 30 '24 12:08 phryneas

Assuming that this error comes somewhere out of the corner of code you are pointing to, it would come from mergeTypeDefs from "@graphql-tools/merge" - do you have anything special in your schema?

phryneas avatar Aug 30 '24 12:08 phryneas

For the configuration we have:

// Configuration for the GraphQL-Apollo plugin for VS Code to verify the GraphQL documents with Topology Manager service.
module.exports = {
  client: {
    includes: ['./libs/data-access-services/api/src/lib/contracts/**/*.graphql'],
    service: {
      name: 'apis-manager',
      url: 'http://127.0.0.1:21160/apis/graphQL/',
      // optionally turn off SSL validation check
      skipSSLValidation: true
    }
  }
};

Configuration is located in root folder of nx workspace. Example of folder structure : https://github.com/nrwl/nx-examples/tree/master

VS Code output logs apollo-graphql.log

mklemarczyk avatar Aug 30 '24 13:08 mklemarczyk

@mklemarczyk Hmm, that looks like it's not crashing, but there's just not a lot happening...

Just to be sure: your server is running, and you also see an introspection query come in there?

PS: shouldn't make a difference, but for a http connection, you won't need skipSSLValidation.

phryneas avatar Aug 30 '24 13:08 phryneas

As for now, I suspect that your problems might come somewhere from these changes, but I can't put my finger on it :/

https://github.com/apollographql/vscode-graphql/pull/160/files#diff-d675ce2b91731f4d5c3cdb539cea2811a6c1c5bfebcc59b64e56b16db8471333

phryneas avatar Aug 30 '24 14:08 phryneas

Are you actually using https and just omitted that in the logs? It seems that switching from isomorphic-fetch to the node implementation with undici might have broken this line:

https://github.com/apollographql/vscode-graphql/blob/d760281ed41f6b37be3589db892b84fd3d55c06a/src/language-server/providers/schema/endpoint.ts#L34

Seems I might need to swap in a dispatcher there instead... :/

phryneas avatar Aug 30 '24 14:08 phryneas

If this is your problem, could you maybe check out if #190 fixes the problem for you? I have to go OOO right now, but I'll spend more time on this on monday.

phryneas avatar Aug 30 '24 14:08 phryneas

Hello @phryneas our server is local HTTP server, without any security. That option you mentioned I think was a workaroud from long time ago, it works in old version (1.20.0) without it as well.

Yes there is IntrospectionQuery logged in server for both extension 1.20.0 and 2.2.0. I did not tried your change from PR yet.

For any hover in graphql there is no result.

[Trace - 4:51:54 PM] Received response 'textDocument/hover - (13)' in 2ms.
No result returned.

mklemarczyk avatar Aug 30 '24 14:08 mklemarczyk

Could you try to execute the Apollo: Show Status command?

that would look something like

------------------------------
๐Ÿš€ Apollo GraphQL v2.2.0
------------------------------
โœ… Service Loaded!
๐Ÿ†” Service ID: localMultiSchema
๐Ÿท Schema Tag: current
๐Ÿ“ˆ Number of Types: 16 (0 client types)
------------------------------

and tell us if your schema could be loaded and how many types were recognized.

phryneas avatar Sep 02 '24 07:09 phryneas

This is what I got in the logs image

Config (apollo.config.js) is located as it is written in logs that I provided and its content is as I send in previous messages. It works fine with 1.x but 2.x has some problems. :/

mklemarczyk avatar Sep 05 '24 11:09 mklemarczyk

@mklemarczyk Just to validate, you are getting that while you have an editor open with a file that was previously recognized?

This could be something with the includes/excludes then... I'll have to take a look. We updated a lot of dependencies going into 2.x

phryneas avatar Sep 05 '24 11:09 phryneas

Yes, I confirm, for the same exact configuration file, no configuration done in VS Code what so ever (default extension settings). I do not have includes/excludes defined in apollo configuration file defined. I assume you are talking about extensions code than.

mklemarczyk avatar Sep 05 '24 11:09 mklemarczyk

@mklemarczyk Didn't you have includes in this comment? https://github.com/apollographql/vscode-graphql/issues/187#issuecomment-2321227216

My assumption is that because we updated one of the dependencies (e.g. we jumped multiple major versions of glob), that doesn't match your files correctly anymore ๐Ÿค”

phryneas avatar Sep 05 '24 15:09 phryneas

@mklemarczyk I've created this custom build that logs a bit more and should hopefully shed some light here.


vscode-apollo-0.0.0-build.1725552078.pr.195.commit.e20f10b.zip.

To install the extension, download the file, unzip it and install it in VS Code by selecting "Install from VSIX..." in the Extensions view.

Alternatively, run

code --install-extension vscode-apollo-0.0.0-build.1725552078.pr.195.commit.e20f10b.vsix --force

from the command line.


Could you please try that out? No need to enable trace logging, this should show up in the Output panel even without that.

It should show us your include and exclude patterns, which of your files were successfully found, and if the schema is downloaded & extended correctly.

phryneas avatar Sep 05 '24 16:09 phryneas

I'm also having this problem. Here is the output for me when running the special extension:

(node:7328) Warning: Setting the NODE_TLS_REJECT_UNAUTHORIZED environment variable to '0' makes TLS connections and HTTPS requests insecure by disabling certificate verification.
(Use `Code --trace-warnings ...` to show where the warning was created)
[INFO] intializing project with config file file:///<CORRECT PATH>/apollo.config.js
[INFO] includes: [src/graphql/**/*.graphql]
[INFO] excludes: [**/node_modules, **/__tests__]
[INFO] found files: 'ALL OF THE GRAPHQL'
[INFO] Loading schema for client project<OUR GRAPH ID>
[INFO] Adding client metadata to schema nodes
[INFO] Successfully handled schema
[INFO] Loading schema for client project<OUR GRAPH ID>
[INFO] Adding client metadata to schema nodes
[INFO] Successfully handled schema
------------------------------
๐Ÿš€ Apollo GraphQL v0.0.0-build.1725552078.pr.195.commit.e20f10b
------------------------------
โŒ 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).

I redacted our graph id and parts of the paths, but those shouldn't be relevant.

Zache avatar Sep 12 '24 08:09 Zache

@Zache thank you for the report! Just to be clear, you are executing the Apollo: Show Status command while your cursor is in an editor of one of the .graphql files that are listed under [INFO] found files: ?

phryneas avatar Sep 12 '24 08:09 phryneas

Unsure where my cursor was, but I have a GraphQL file (listed by the extension in a redacted part) open. In case you meant the caret I also donโ€™t know where it was either. Iโ€™ll report back when Iโ€™m at my computer again

On Thu, 12 Sep 2024 at 10:55, Lenz Weber-Tronic @.***> wrote:

@Zache https://github.com/Zache thank you for the report! Just to be clear, you are executing the Apollo: Show Status command while your cursor is in an editor of one of the .graphql files that are listed under [INFO] found files: ?

โ€” Reply to this email directly, view it on GitHub https://github.com/apollographql/vscode-graphql/issues/187#issuecomment-2345672720, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA3AXQHI3KYUVSM2373DMQ3ZWFJHRAVCNFSM6AAAAABNJ3YUZSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGNBVGY3TENZSGA . You are receiving this because you were mentioned.Message ID: @.***>

Zache avatar Sep 12 '24 09:09 Zache

@Zache Yeah, that's quite important - the extension is only active inside of files in your includes, and that "Show Status" command will only give you the right feedback if your "active editor" has one of those files opened. I know it's a bit complex, but since we support multiple differently configured projects inside the same workspace (e.g. monorepos), we have to make that distinction.

phryneas avatar Sep 12 '24 09:09 phryneas

@phryneas I tried it again, this time making sure that my cursor and caret was in an included .graphql file. But I still get the same error. Maybe it could be of interest that if I click the ๐Ÿš€Apollo button down in the status bar it prints the extension name, but not the status error. I'm pretty certain that used to print the status also...

Zache avatar Sep 12 '24 12:09 Zache

@Zache That is really curious. I'll try a few more things tomorrow, but I have to admit that at this point I feel a bit lost - we have no real clues here.

If you have any more ideas what could make your environment unique, or could even come up with a minimal reproduction, I'd be very grateful.

phryneas avatar Sep 12 '24 16:09 phryneas

Hello @phryneas I was not able to download the file you mentioned. I get 404 error. https://github.com/apollographql/vscode-graphql/actions/runs/10723970223/artifacts/1897164825

In some free time I will record you a video with the issue later today.

mklemarczyk avatar Sep 18 '24 09:09 mklemarczyk

@mklemarczyk yeah that build only stays around for two weeks - here is a new one :)


You can download the latest build of the extension for this PR here: vscode-apollo-0.0.0-build-1726659863.pr-195.commit-a14272e.zip.

To install the extension, download the file, unzip it and install it in VS Code by selecting "Install from VSIX..." in the Extensions view.

Alternatively, run

code --install-extension vscode-apollo-0.0.0-build-1726659863.pr-195.commit-a14272e.vsix --force

from the command line.

phryneas avatar Sep 18 '24 11:09 phryneas

image This showed that error, did not load anything.

The hidden parts are my username, and project folder name.

Those are other extensions that I use image

mklemarczyk avatar Sep 18 '24 16:09 mklemarczyk

@mklemarczyk I believe you just found a bug that I shipped yesterday ๐Ÿ˜… There's a lot of work going on around "config file loading" because the ways that shipped with recent versions of cosmiconfig is unfortunately just not doing the things we want it to do anymore.

I just opened a PR to fix this bug over in #211 and will have a new build to try in a moment :)

phryneas avatar Sep 19 '24 08:09 phryneas

Okay, new build coming up - thank you for your patience!


You can download the latest build of the extension for this PR here: vscode-apollo-0.0.0-build-1726752845.pr-195.commit-2c7e56c.zip.

To install the extension, download the file, unzip it and install it in VS Code by selecting "Install from VSIX..." in the Extensions view.

Alternatively, run

code --install-extension vscode-apollo-0.0.0-build-1726752845.pr-195.commit-2c7e56c.vsix --force

from the command line.

phryneas avatar Sep 19 '24 08:09 phryneas

Now I'm getting errors The error was: ReferenceError: module is not defined in ES module scope, but get around that. I also had a problem where we used require to get some dotenv code running, but I think I could remove that since the extension documentation says it can read from .env files.

One thing I don't think I have mentioned is that I do get a little blue "play" button to open in Apollo Studio and that works without any problem. But I still don't get Intellisense

Zache avatar Sep 23 '24 10:09 Zache

@Zache those errors should have been solved with friday's release. Could you please verify that you are on 2.3.2?

If you are still encountering, could you share some of the things in your config file that might help me reproduce the problem?

phryneas avatar Sep 23 '24 10:09 phryneas