graphql / graphiql

GraphiQL & the GraphQL LSP Reference Ecosystem for building browser & IDE tools.
MIT License
15.97k stars 1.72k forks source link

vscode-graphql autocomplete not working #2390

Open DPangerl opened 2 years ago

DPangerl commented 2 years ago

Hi everyone,

i have a hard time figuring out how to config this extension so autocomplete works for my graphql types and fields. Of course i went through the readme but neither config did the trick.

My confilg looks like this:

module.exports = {
  schema: "http://localhost:4667/graphql",
  documents: "src/**/*.{graphql,js,ts,jsx,tsx}",
  extensions: {
    languageService: {
      cacheSchemaFileForLookup: true,
      enableValidation: false,
    },
  },
};

I have a src-folder and the config file is in the root level.

Most of the time the server crashes with:

5/6/2022, 4:02:18 PM [1] (pid: 22159) graphql-language-service-usage-logs: invalid/unknown file in graphql config documents entry:
 'src/**/*.{graphql,js,ts,jsx,tsx}'

When i start the graphql server, the following errors are thrown too:

Type "root" already exists in the schema. It cannot also be defined in this type definition.

Field "root.query" already exists in the schema. It cannot also be defined in this type extension.

Field "root.mutation" already exists in the schema. It cannot also be defined in this type extension.

If i remove the documents-property the server starts. But autocomplete does not work at all.

If i hit ctrl-space, this is what I get:

Bildschirmfoto 2022-05-06 um 16 10 09

If i type a Sit looks like this

Bildschirmfoto 2022-05-06 um 16 10 20

And my own types are also not recognized at all:

Bildschirmfoto 2022-05-06 um 16 10 35

I struggle with this extension since at least a year… I even switched to PHPStorm once (their extension works perfectly but the IDE is missing features)

I guess it shouId not be this hard to get this working. I really would appreciate it if someone could help me with this.
Thanks in advance and best regards

Daniel

2shrestha22 commented 1 year ago

Same problem here with Linux works fine in Mac. @DPangerl have you tried removing documents: "src/**/*.{graphql,js,ts,jsx,tsx}", line?

ygkn commented 1 year ago

Hi. I got same error in Linux (Ubuntu 22.04, Node v18.12.1) and after removing documents entry works well.

DPangerl commented 1 year ago

I've noticed that there is indeed autocompletion, but not like I would have expected it. Asuming I have a type called User and i want it to add as filed type, the autocomplete shows just the default entries. As soon as I have typed the first character U, the suggestions will show up (also e.g UserSession etc.). However, no comments or other info is displayed, so I even can't tell if its the autocomplete or another vs code tool.

Compare to the capabilities of the webstorm plugin this is not really much – but at least it gives you a hint

By the way, i reduced my setup to a single project and one single schema.graphql file… no stitching, no gql-tag

{
  "name": "Backend Graphql Schema",
  "schema": "src/graphql/schema.graphql"
}
onx2 commented 2 months ago

I'm having a similar issue -- no autocomplete in Ubuntu 22 LTS but I don't get any output log errors. See line 9 - there should be quite a few options and I confirmed this set up works for MacOS.

Removing the documents entry does not solve problem for me.

config

export default {
  schema: "src/schema.generated.ts",
  documents: "src/**/*.graphql",
};

image

image