graphql / graphiql

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

CLI: stream server does not work #3538

Open abaldawa opened 8 months ago

abaldawa commented 8 months ago

Is there an existing issue for this?

Current Behavior

No code completion in ".graphql" schema file inside vs code? Please see the video. I have installed both official extensions for vs code here and here but its still not giving any code completion.

Webstorm works fine without any settings but VS code does not show any autocomplete in ".graphql" file. Any help would be appreciated as after searching the web/this github repo, I still was not able to find the solution.

video https://github.com/graphql/graphiql/assets/5449692/c2dd72a8-70a2-411b-af52-7fcb8301b64e

Expected Behavior

Syntax highlighting should work in *.graphql schema files

Steps To Reproduce

  1. For VS code install https://marketplace.visualstudio.com/items?itemName=GraphQL.vscode-graphql and https://marketplace.visualstudio.com/items?itemName=GraphQL.vscode-graphql-syntax
  2. In a temp project create .graphqlrc.yml file
  3. add schema: 'schema.graphql' section
  4. create schema.graphql file
  5. No type completion for any graphql data type

Environment

Anything else?

No response

acao commented 8 months ago

I have a fix for this I am just about to release in #3521! there is a pre-release in a zip file if you want to give it a try!

wongjiahau commented 5 months ago

The stream method appears to be completely dysfunctional due to the initializedHandlers not being called in the branch where method is stream: https://github.com/graphql/graphiql/blob/aa6dbbb45bf51c1966537640fbe5c4f375735c8d/packages/graphql-language-service-server/src/startServer.ts#L118-L128

wongjiahau commented 5 months ago

I verified my hypothesis above by building graphql-lsp from source, indeed aa6dbbb45bf51c1966537640fbe5c4f375735c8d is the first bad commit that causes graphql-lsp server --method stream to malfunction.

To install the latest functioning graphl-lsp that works for --method stream (make sure yarn is installed first):

git clone https://github.com/graphql/graphiql.git 
cd graphiql
git checkout 03ab3a6b # The commit before the first bad commit
yarn install
yarn build
cd packages/graphql-language-service-cli/
npm i -g .

P/S: For some reason, the binaries published on npm, although their version precedes the first bad commit, are also dysfunctional.

heavenshell commented 4 months ago

Any update about this? main branch's stream server is still broken. As @wongjiahau mentioned, git checkout 03ab3a6b works fine.

Here is log of main branch using vim-lsp

Sat Jun 22 11:17:51 2024:["<---(stderr)",1,"graphql-language-server","Content-Length: 73\r\n\r\n"]
Sat Jun 22 11:17:51 2024:["<---(stderr)",1,"graphql-language-server","{\"jsonrpc\":\"2.0\",\"id\":1,\"result\":{\"capabilities\":{\"textDocumentSync\":0}}}"]
heavenshell commented 4 months ago

Confirm 3.4.1 fixed this problem. Thank you!