graphql / vscode-graphql

MIGRATED: VSCode GraphQL extension (autocompletion, go-to definition, syntax highlighting)
https://marketplace.visualstudio.com/items?itemName=Prisma.vscode-graphql
MIT License
557 stars 71 forks source link

Intellisense stopped working in .gql files after updating to v0.3 #204

Closed vitosamson closed 4 years ago

vitosamson commented 4 years ago

Actual Behavior

Since updating to v0.3 of the extension, intellisense has stopped working. Interestingly, "Execute Query" still works, and error reporting works for incorrect fields (in one project, but not the others – there are three projects with separate schemas), but I can't get any intellisense or autocompletion.

I'm pretty sure I've correctly updated my config to what v0.3 expects:

graphql.config.yml

projects:
  admin:
    schemaPath: portals/admin/__generated__/admin.schema.json
    documents:
      - 'portals/admin/**/graphql/**/*.{gql,ts,tsx}'
      - 'portals/admin/lib/api/graphQL/urql/cacheUpdaters.ts'
      - 'portals/admin/lib/api/graphQL/urql/subscriptions.gql'
    extensions:
      endpoints:
        default:
          url: http://localhost:3000/v1

  login:
    schemaPath: portals/login/__generated__/login.schema.json
    documents:
      - 'portals/login/**/graphql/**/*.{gql,ts,tsx}'
    extensions:
      endpoints:
        default:
          url: http://localhost:3000/v1/consumer

  consumer:
    schemaPath: portals/consumer/__generated__/consumer.schema.json
    documents:
      - 'portals/consumer/**/graphql/**/*.{gql,ts,tsx}'
      - 'portals/consumer/lib/graphql/subscriptions.gql'
    extensions:
      endpoints:
        default:
          url: http://localhost:3000/v1/consumer

This config works exactly as expected in the last v0.2 release.

Further, looking at the language server logs, when I open a consumer project document, it seems to be incorrectly reporting it as being in the admin project and therefore gives incorrect errors about fields/queries not being present:

[Error - 4:48:12 PM] Request textDocument/documentSymbol failed.
  Message: Request textDocument/documentSymbol failed with message: A cached document cannot be found.
  Code: -32603 
8/27/2020, 4:48:12 PM [4] (pid: 1720) graphql-language-service-usage-logs: {"type":"usage","messageType":"textDocument/didOpen","projectName":"admin","fileName":"file:///agents/portals/consumer/views/Quote/Results/graphql/quoteResultsQuery.gql"}

Expected Behavior

Intellisense and multiple projects should work.

Steps to Reproduce the Problem Or Description

Upgrade to v0.3, unsure beyond that.

Specifications

Logs Of TS Server || GraphQL Language Service

[Error - 4:48:12 PM] Request textDocument/documentSymbol failed.
  Message: Request textDocument/documentSymbol failed with message: A cached document cannot be found.
  Code: -32603 
8/27/2020, 4:48:12 PM [4] (pid: 1720) graphql-language-service-usage-logs: {"type":"usage","messageType":"textDocument/didOpen","projectName":"admin","fileName":"file:///agents/portals/consumer/views/Quote/Results/graphql/quoteResultsQuery.gql"}
acao commented 4 years ago

graphql/graphiql#2347 might be a duplicate of this, and might be why you are having this issue

acao commented 4 years ago

closing this as a dupe of graphql/graphiql#2347

please track the fix in the impacted repository here! https://github.com/graphql/graphiql/issues/1655

vitosamson commented 4 years ago

I'm not sure this is an exact duplicate of graphql/graphiql#2347 but I don't know enough about the internals here so maybe they're connected.

Even in the first project, language features only partially work – incorrect fields are properly reported as errors but intellisense doesn't work.

acao commented 4 years ago

hey i overlooked something! please update to graphql-config@3 format if you can. see the readme. you are still using schemaPath it looks like, instead of schema pointer(s)

after that, can you discuss any further bugs here where the LSP server lives? https://github.com/graphql/graphiql/issues/1655

vitosamson commented 4 years ago

I just tried it again with schema instead of schemaPath, but it's still showing the same issues. It looks like everything else is correct for the graphql-config@3 format. I also tried removing the extension field from each project just to narrow it down a bit, and that didn't help either.

acao commented 4 years ago

ok! sounds like an LSP issue then. closing this for graphql/graphiql#1655