question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Autocomplete not working on Schema definition

See original GitHub issue

Actual 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: image

However, whenever I type a new field, autocomplete doesn’t work: image

In the example above, if I write Int and save my file, then it gets suggested the next time I type something: image

But as soon as I’m writing the next field it stops working again: image

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:open
  • Created 3 years ago
  • Reactions:22
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
acaocommented, Feb 17, 2022

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!

1reaction
acaocommented, Feb 17, 2022

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 😢

Read more comments on GitHub >

github_iconTop Results From Across the Web

Autocomplete not working on Schema definition #2172 - GitHub
Autocomplete works fine on gql tags and query files in the project but it does not work on the schema definition file.
Read more >
Single instance Prisma client autocomplete not working
Worked for me to generate the schemas for the prisma-client. You should have defined in your schema.prisma the generator:
Read more >
Auto Completion is not working in non-dbo schemas
Re: Auto Completion is not working in non-dbo schemas. Hi Alex, You can set the Schema list to empty to let auto-complete list...
Read more >
Autocomplete not working when editing JSON with schema ...
Schema is valid, but Intellisense not reacting. For example it's annoying when try to edit settings.json of Windows Terminal with VS2019 but there's...
Read more >
Autocomplete not working correctly after 2017.1 update
6.1 Postgres database, have the schema the table lives on selected in the Data Sources and Drivers->Schemas tab, and have "Synchronized" the ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found