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

regression in schema type support #218

Closed kdong007 closed 4 years ago

kdong007 commented 4 years ago

Actual Behavior

No hover No auto suggestion

I added config file graphqlrc.yml using your sample config, restarted VSCode, but it doesn't work.

schema: "./src/schema.ggl"
documents: "src/**/*.{graphql,js,ts,jsx,tsx}"

Expected Behavior

Plugin work as stated

Steps to Reproduce the Problem Or Description

https://github.com/kdong007/sample-graphql

Specifications

Logs Of TS Server || GraphQL Language Service


(node:37574) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 105)
(node:37574) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 108)
(node:37574) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 110)
[Error - 4:02:40 PM] Request textDocument/definition failed.
  Message: Request textDocument/definition failed with message: File '/Users/kdong007/Desktop/projects/sample-graphql/src/schema.gql' doesn't match any project
  Code: -32603 
(node:37574) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 113)
(node:37574) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 115)
(node:37574) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 117)
(node:37574) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 119)
(node:37574) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 122)
[Error - 4:03:02 PM] Request textDocument/definition failed.
  Message: Request textDocument/definition failed with message: File '/Users/kdong007/Desktop/projects/sample-graphql/src/schema.gql' doesn't match any project
  Code: -32603 
[Error - 4:03:02 PM] Request textDocument/definition failed.
  Message: Request textDocument/definition failed with message: File '/Users/kdong007/Desktop/projects/sample-graphql/src/schema.gql' doesn't match any project
  Code: -32603 
[Error - 4:04:26 PM] Request textDocument/definition failed.
  Message: Request textDocument/definition failed with message: File '/Users/kdong007/Desktop/projects/sample-graphql/src/schema.gql' doesn't match any project
  Code: -32603 
[Error - 4:04:27 PM] Request textDocument/definition failed.
  Message: Request textDocument/definition failed with message: File '/Users/kdong007/Desktop/projects/sample-graphql/src/schema.gql' doesn't match any project
  Code: -32603 ```
acao commented 4 years ago

@kdong007 does the file name match this list?

https://graphql-config.com/usage

the same list is in the readme.

it looks like you are referring to a graphqlrc.yml file instead of .graphqlrc.yml, but I can't tell because there is no graphql config file in the repo?

acao commented 4 years ago

ah! i forgot to include the . in the readme update.

acao commented 4 years ago

readme is updated. let me know if it works when you name the config file as expected

kdong007 commented 4 years ago

@acao Thanks for your attention.

I have update the config but the plugin is still not working. No hover and No definition found for xxxx, on both Windows and Mac

The config is checked into repo.

Here are some logs from "GraphQL Language Server"

2020-09-20, 8:39:21 a.m. [4] (pid: 2788) graphql-language-service-usage-logs: {"type":"usage","messageType":"initialize"}

undefined
2020-09-20, 8:39:21 a.m. [4] (pid: 2788) graphql-language-service-usage-logs: {"type":"usage","messageType":"textDocument/didOpen","projectName":"default","fileName":"file:///c%3A/Users/Mars/Desktop/projects/sample-graphql/src/schema.gql"}

undefined
2020-09-20, 8:40:26 a.m. [4] (pid: 2788) graphql-language-service-usage-logs: {"type":"usage","messageType":"textDocument/didOpen","projectName":"default","fileName":"file:///c%3A/Users/Mars/Desktop/projects/sample-graphql/src/server.ts"}

undefined
[Error - 8:40:26 a.m.] Request textDocument/documentSymbol failed.
  Message: Request textDocument/documentSymbol failed with message: A cached document cannot be found.
  Code: -32603 
[Error - 8:40:26 a.m.] Request textDocument/documentSymbol failed.
  Message: Request textDocument/documentSymbol failed with message: A cached document cannot be found.
  Code: -32603 
[Error - 8:40:26 a.m.] Request textDocument/documentSymbol failed.
  Message: Request textDocument/documentSymbol failed with message: A cached document cannot be found.
  Code: -32603 
2020-09-20, 8:42:46 a.m. [4] (pid: 2788) graphql-language-service-usage-logs: {"type":"usage","messageType":"textDocument/didChange","projectName":"default","fileName":"file:///c%3A/Users/Mars/Desktop/projects/sample-graphql/src/schema.gql"}

undefined
2020-09-20, 8:42:47 a.m. [4] (pid: 2788) graphql-language-service-usage-logs: {"type":"usage","messageType":"textDocument/didChange","projectName":"default","fileName":"file:///c%3A/Users/Mars/Desktop/projects/sample-graphql/src/schema.gql"}

undefined
2020-09-20, 8:42:47 a.m. [4] (pid: 2788) graphql-language-service-usage-logs: {"type":"usage","messageType":"textDocument/didChange","projectName":"default","fileName":"file:///c%3A/Users/Mars/Desktop/projects/sample-graphql/src/schema.gql"}

undefined
2020-09-20, 8:42:48 a.m. [4] (pid: 2788) graphql-language-service-usage-logs: {"type":"usage","messageType":"textDocument/didChange","projectName":"default","fileName":"file:///c%3A/Users/Mars/Desktop/projects/sample-graphql/src/schema.gql"}

And here is on interesting log, only happened once on Windows, not Mac

(node:2788) UnhandledPromiseRejectionWarning: Error: ENOENT: no such file or directory, open '/c%3A/Users/Mars/Desktop/projects/sample-graphql/src/schema.gql'
    at Object.openSync (fs.js:440:3)
    at Object.func [as openSync] (electron/js2c/asar.js:140:31)
    at Object.readFileSync (fs.js:342:35)
    at Object.fs.readFileSync (electron/js2c/asar.js:542:40)
    at c:\Users\Mars\.vscode\extensions\prisma.vscode-graphql-0.3.6\node_modules\graphql-language-service-server\dist\MessageProcessor.js:320:35
    at Array.map (<anonymous>)
    at MessageProcessor.handleWatchedFilesChangedNotification (c:\Users\Mars\.vscode\extensions\prisma.vscode-graphql-0.3.6\node_modules\graphql-language-service-server\dist\MessageProcessor.js:313:43)
    at c:\Users\Mars\.vscode\extensions\prisma.vscode-graphql-0.3.6\node_modules\graphql-language-service-server\dist\startServer.js:164:122
    at handleNotification (c:\Users\Mars\.vscode\extensions\prisma.vscode-graphql-0.3.6\node_modules\vscode-jsonrpc\lib\main.js:502:43)
    at processMessageQueue (c:\Users\Mars\.vscode\extensions\prisma.vscode-graphql-0.3.6\node_modules\vscode-jsonrpc\lib\main.js:273:17)
(node:2788) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 6)
(node:2788) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
acao commented 4 years ago

i re-created your case using graphqlrc.yml, but found renaming the file to .graphqlrc.yml fixed it and restored language features for me on linux. you'll have to re-start the extension.

this should improve error handling when config isn't present https://github.com/graphql/graphiql/pull/1667

see the readme for known issues regarding "cached document cannot be found"

kdong007 commented 4 years ago

Sorry I forgot to mention, I did use the file with dot .graphqlrc.yml

https://github.com/kdong007/sample-graphql/blob/master/.graphqlrc.yml

maybe its something related to global binary/package not installed on my side?

acao commented 4 years ago

hmm, there aren't any binaries for you to install AFAIK, unless you're referring to nodejs?

your log output in macosx looks fine

kdong007 commented 4 years ago

well. of course I have node installed LOL. v12.18.0

kdong007 commented 4 years ago

Tried on Linux too. Not working.

Tried VSCdoe setting "vscode-graphql.useSchemaFileDefinition": true, not working.

Here is the famous "not happening on my side" problem LOL

acao commented 4 years ago

exmaple-apollo

here it is with your repo!

i created an example.tsx file and it looks like completion and validation is working

acao commented 4 years ago

apollo-example-2

acao commented 4 years ago

you're correct that useSchemaFileDefinition isn't working now, so I need to look into what's regressed

acao commented 4 years ago

and I see now that the schema completion has regressed somehow? good catch!

kdong007 commented 4 years ago

oops. We were talking about two different things

You are talking about editor support in writing query. But I am talking about editor support in writing schema. like Hover/"Go to definition"/autocomplete

acao commented 4 years ago

yeah, this was all working great before i introduced all the logic for generated schemas, so i'm sure its just a small bug. thank you!

acao commented 4 years ago

image

outline support works fine, which means the definitions are being cached properly

acao commented 4 years ago

@kdong007 found the regression! try renaming your schema to .graphql for now. not sure how .gql got removed from the allowed extensions array

kdong007 commented 4 years ago

Awesome! it's all working now.

acao commented 4 years ago

awesome! just released support for .gql anyways! cheers!