Autocomplete not working on Schema definition
See original GitHub issueActual Behavior
Autocomplete works fine on gql tags and query files in the project but it does not work on the schema definition file.
The outline is being detected as expected:
However, whenever I type a new field, autocomplete doesn’t work:
In the example above, if I write Int and save my file, then it gets suggested the next time I type something:
But as soon as I’m writing the next field it stops working again:
Expected Behavior
Autocomplete should work with default and user defined types on schema definition.
Steps to Reproduce the Problem Or Description
1 - Create a new project with the following configuration file:
.graphqlrc.yml
schema: "schema.graphql"
documents: "src/**/*.{graphql,gql,js,ts,jsx,tsx}"
2 - Create a schema.graphql file in the root folder: schema.graphql
type User {
id: ID
firstName: String
lastName: String
address: Int
cash: Int
}
type Query {
users: [User]
user: User
}
3 - Try to write a new field, autocomplete doesn’t work
Specifications
- GraphQL for VSCode Extension Version: 0.3.13
- VSCode Version:
Version: 1.52.1 Commit: ea3859d4ba2f3e577a159bc91e3074c5d85c0523 Date: 2020-12-16T16:30:02.420Z Electron: 9.3.5 Chrome: 83.0.4103.122 Node.js: 12.14.1 V8: 8.3.110.13-electron.0 OS: Darwin x64 20.2.0
Logs Of TS Server || GraphQL Language Service
12/31/2020, 12:15:43 PM [1] (pid: 5543) graphql-language-service-usage-logs: Error: Unknown type "I". Did you mean "ID"?
[Error - 12:16:05 PM] Request textDocument/hover failed.
Message: Request textDocument/hover failed with message: Unknown type "I". Did you mean "ID"?
Code: -32603
[Error - 12:16:06 PM] Request textDocument/completion failed.
Message: Request textDocument/completion failed with message: Unknown type "I". Did you mean "ID"?
Code: -32603
(node:5543) UnhandledPromiseRejectionWarning: Error: Unknown type "I". Did you mean "ID"?
at assertValidSDL (/Users/theoribeiro/.vscode/extensions/graphql.vscode-graphql-0.3.13/node_modules/graphql/validation/validate.js:107:11)
at Object.buildASTSchema (/Users/theoribeiro/.vscode/extensions/graphql.vscode-graphql-0.3.13/node_modules/graphql/utilities/buildASTSchema.js:45:34)
at makeSchema (/Users/theoribeiro/.vscode/extensions/graphql.vscode-graphql-0.3.13/node_modules/@graphql-tools/merge/index.cjs.js:976:99)
at Object.mergeSchemasAsync (/Users/theoribeiro/.vscode/extensions/graphql.vscode-graphql-0.3.13/node_modules/@graphql-tools/merge/index.cjs.js:967:12)
at async Object.loadSchema (/Users/theoribeiro/.vscode/extensions/graphql.vscode-graphql-0.3.13/node_modules/@graphql-tools/load/index.cjs.js:650:20)
at async GraphQLCache.getSchema (/Users/theoribeiro/.vscode/extensions/graphql.vscode-graphql-0.3.13/node_modules/graphql-language-service-server/dist/GraphQLCache.js:259:26)
(node:5543) 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: 44)
[Error - 12:16:24 PM] Request textDocument/completion failed.
Message: Request textDocument/completion failed with message: Syntax Error: Expected ":", found "}".
Code: -32603
(node:5543) UnhandledPromiseRejectionWarning: GraphQLError: Syntax Error: Expected ":", found "}".
at syntaxError (/Users/theoribeiro/.vscode/extensions/graphql.vscode-graphql-0.3.13/node_modules/graphql/error/syntaxError.js:15:10)
at Parser.expectToken (/Users/theoribeiro/.vscode/extensions/graphql.vscode-graphql-0.3.13/node_modules/graphql/language/parser.js:1413:40)
at Parser.parseFieldDefinition (/Users/theoribeiro/.vscode/extensions/graphql.vscode-graphql-0.3.13/node_modules/graphql/language/parser.js:881:10)
at Parser.optionalMany (/Users/theoribeiro/.vscode/extensions/graphql.vscode-graphql-0.3.13/node_modules/graphql/language/parser.js:1503:28)
at Parser.parseFieldsDefinition (/Users/theoribeiro/.vscode/extensions/graphql.vscode-graphql-0.3.13/node_modules/graphql/language/parser.js:868:17)
at Parser.parseObjectTypeDefinition (/Users/theoribeiro/.vscode/extensions/graphql.vscode-graphql-0.3.13/node_modules/graphql/language/parser.js:812:23)
at Parser.parseTypeSystemDefinition (/Users/theoribeiro/.vscode/extensions/graphql.vscode-graphql-0.3.13/node_modules/graphql/language/parser.js:708:23)
at Parser.parseDefinition (/Users/theoribeiro/.vscode/extensions/graphql.vscode-graphql-0.3.13/node_modules/graphql/language/parser.js:150:23)
at Parser.many (/Users/theoribeiro/.vscode/extensions/graphql.vscode-graphql-0.3.13/node_modules/graphql/language/parser.js:1523:26)
at Parser.parseDocument (/Users/theoribeiro/.vscode/extensions/graphql.vscode-graphql-0.3.13/node_modules/graphql/language/parser.js:115:25)
(node:5543) UnhandledPromiseRejectionWarning: Error: Unknown type "F".
at assertValidSDL (/Users/theoribeiro/.vscode/extensions/graphql.vscode-graphql-0.3.13/node_modules/graphql/validation/validate.js:107:11)
at Object.buildASTSchema (/Users/theoribeiro/.vscode/extensions/graphql.vscode-graphql-0.3.13/node_modules/graphql/utilities/buildASTSchema.js:45:34)
at makeSchema (/Users/theoribeiro/.vscode/extensions/graphql.vscode-graphql-0.3.13/node_modules/@graphql-tools/merge/index.cjs.js:976:99)
at Object.mergeSchemasAsync (/Users/theoribeiro/.vscode/extensions/graphql.vscode-graphql-0.3.13/node_modules/@graphql-tools/merge/index.cjs.js:967:12)
at async Object.loadSchema (/Users/theoribeiro/.vscode/extensions/graphql.vscode-graphql-0.3.13/node_modules/@graphql-tools/load/index.cjs.js:650:20)
at async GraphQLCache.getSchema (/Users/theoribeiro/.vscode/extensions/graphql.vscode-graphql-0.3.13/node_modules/graphql-language-service-server/dist/GraphQLCache.js:259:26)
(node:5543) UnhandledPromiseRejectionWarning: TypeError [ERR_INVALID_URL_SCHEME]: The URL must be of scheme file
at Object.fileURLToPath (internal/url.js:1340:11)
at /Users/theoribeiro/.vscode/extensions/graphql.vscode-graphql-0.3.13/node_modules/graphql-language-service-server/dist/MessageProcessor.js:353:54
at Array.map (<anonymous>)
at MessageProcessor.handleWatchedFilesChangedNotification (/Users/theoribeiro/.vscode/extensions/graphql.vscode-graphql-0.3.13/node_modules/graphql-language-service-server/dist/MessageProcessor.js:342:43)
at /Users/theoribeiro/.vscode/extensions/graphql.vscode-graphql-0.3.13/node_modules/graphql-language-service-server/dist/startServer.js:165:122
at handleNotification (/Users/theoribeiro/.vscode/extensions/graphql.vscode-graphql-0.3.13/node_modules/vscode-jsonrpc/lib/main.js:502:43)
at processMessageQueue (/Users/theoribeiro/.vscode/extensions/graphql.vscode-graphql-0.3.13/node_modules/vscode-jsonrpc/lib/main.js:273:17)
at Immediate._onImmediate (/Users/theoribeiro/.vscode/extensions/graphql.vscode-graphql-0.3.13/node_modules/vscode-jsonrpc/lib/main.js:260:13)
at processImmediate (internal/timers.js:439:21)
Issue Analytics
- State:
- Created 3 years ago
- Reactions:22
- Comments:5 (2 by maintainers)
Top GitHub Comments
It appears from the screenshots that the autocomplete is briefly working properly for you after save. The blue icons are appearing, which are used to denote operation or type fields, as opposed to the emmet style completions that always show and have to be disabled in user settings.
Of course it should also work before save, and after you begin typing a selection, so we will have to fix that!
Terribly sorry this one slipped through the cracks last year. I still have ~900 notifications to go through
I have moved this ticket to the repository for the language server. I haven’t seen this issue with similar configurations yet, but I’m sure I or another maintainer will be able to reproduce it. It’s been added as a high priority bug to the roadmap, given the response 😢