Closed MichalLytek closed 4 years ago
@19majkel94 : Can you please provide a minimal reproduction of this in for of a Github issue? That would help me expedite a fix. Also, please try with yml
version of the .graphqlconfig
once, maybe format is the issue - this will help us corner out the issue faster. Thanks.
@divyenduz Here is the reproduction repo: https://github.com/19majkel94/vscode-graphql-bug
The hover feature doesn't work, when you open the query, it prints this errors in extensions output:
(node:19476) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): TypeError: Cannot read property 'schemaPath' of undefined
(node:19476) [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.
[Error - 5:01:48 PM] Request textDocument/hover failed.
Message: Request textDocument/hover failed with message: Cannot read property 'projectName' of undefined
Code: -32603
(node:19476) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 5): TypeError: Cannot read property 'schemaPath' of undefined
[Error - 5:02:45 PM] Request textDocument/hover failed.
Message: Request textDocument/hover failed with message: Cannot read property 'projectName' of undefined
Code: -32603
[Error - 5:02:45 PM] Request textDocument/hover failed.
Message: Request textDocument/hover failed with message: Cannot read property 'projectName' of undefined
Code: -32603
@19majkel94 Thanks for the reproduction, I am able to reproduce this issue. Removing includes
from the config file indeed makes hover work again.
@19majkel94 : I have a question, why do you want to include the queries (.gql
) files? I think this would work if you include the schema file. Language features work with "definition" part of the GraphQL SDL i.e. type definitions etc and they should ignore (and not crash) on "executable" part of GraphQL SDL like queries, mutations.
@19majkel94 : For instance, in this reproduction, I made the following changes:
-schemaPath: ./server/src/schema.graphql
-includes: ["./client/src/**/*.graphql"]
+schemaPath: "./server/src/schema.graphql" # Added quotes
+includes: ["**/*.graphql"] # Changed includes
And it works: http://recordit.co/ns3OkAyjXN
I will still keep this issue open because it is a bug (to crash on wrong includes) and we should handle the error handling better but does making these changes make it work for you as well?
Please restart VSCode or reload the project after you change the .graphqlconfig.yaml
file.
@divyenduz Based on the readme, I thought that includes
is for pointing the files that should use selected schema for autocomplete/validation:
{
"projects": {
"projectA": {
"schemaPath": "./resources/schema.graphql",
"includes": ["./projectA/graphql/*.graphql"]
},
"projectB": {
"schemaPath": "../resources/schema.graphql",
"includes": ["./projectB/graphql/*.graphql"]
},
"projectC": {
"schemaPath": "./schema-for-projectC.graphql"
}
}
}
The reason why I want to add the includes
is because of this:
To support language features like "go-to definition" across multiple files, please include includes key in the graphql-config per project.
I use imported fragments a lot and the extension shows me error about this:
But when I save the file, the error is gone (it just don't validate the fragment, I can place there foo or bar and it's ok too 😞
I think this would work if you include the schema file. Language features work with "definition" part of the GraphQL SDL
With includes: ["**/*.graphql"]
I'm still not able do make hover/jump to definition work in the schema.graphql
file.
From comment in related issue #107
@remy You've probably moved on by now, but I found the issue.
includes
should beinclude
(not plural).That's it.
in the latest version, graphql-config@3 uses documents
, though include
should still work for backwards compatibility. thanks @chloerice for the support help!
Actual Behavior
I receive the errors
Cannot read property 'schemaPath' of undefined
andCannot read property 'projectName' of undefined
.Expected Behavior
There should be no error and it should provide all the assistance.
Steps to Reproduce the Problem Or Description
I receive the errors only when I add the
includes
section to the config.With only
schemaPath
it works ok (but only syntax, validation, hover and autocompletion, without jumping to fragment from import):Specifications
Logs Of TS Server || GraphQL Language Service