Skip to content

[graphql-language-service] hover broken #4157

@lesleydreyer

Description

@lesleydreyer

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

If you hover at the beginning of the query editor, it shows an error
Error: Expected Parser stream to be available

When I first filed the issue I thought this could be fixed in the GraphQLWorker file -> doHover function by changing to return early

const hover = this._languageService.getHover(uri, document, graphQLPosition);
if (!hover) return;

but a couple days after I filed this issue I realized it also occurs if I hover later in the first line and think it may be the same issue as #3168 from a few years ago.

I think it can be fixed by changing graphql-language-service -> interface -> getDiagnostics -> getRange

(let i = 0; i < location.line; i++) {
to
for (let i = 0; i <= location.line; i++) {

Expected Behavior

Should not throw Error: Expected Parser stream to be available in the UI console.

Steps To Reproduce

To reproduce go to the swapi or netlify demos from the graphiql docs, open the UI console, and hover at position 0.

Image Image

Environment

  • GraphiQL Version: 5.2.2
  • OS: Mac Sequoia 15.7.3 (24G419)
  • Browser: Chrome
  • Bundler: tried with vite and esbuild and the demos
  • react Version: 16.12
  • graphql Version: 18.2

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions