graphql / graphiql

GraphiQL & the GraphQL LSP Reference Ecosystem for building browser & IDE tools.
MIT License
15.94k stars 1.71k forks source link

[vscode-graphql] go to definition jumps to wrong line on certain condition #3546

Open panda0603 opened 6 months ago

panda0603 commented 6 months ago

Is there an existing issue for this?

Current Behavior

Hello,

there seems to be existing issues with wrong line jumps, but I'm not sure if this is the same condition so I am posting another issue.

When using inline string fragments in .ts files like below,

jump to definition(cmd+click) on RelatedLinks type jumps to wrong line(usually at the end of the file) at the correct file(where the type RealtedLinks is defined). The point here is that this happens only when the fragment name exactly matches the type name(both are RelatedLinks). If the names are different, go to definition works well, jumping to the correct line.

export const LINKS = `#graphql
  fragment RelatedLinks on RelatedLinks {
     ...
  }
`

I tried moving the fragment to a .gql file, and here even with the same names, it jumps well to the correct line. I am not sure why this is different behavior to .ts file.

may this be a bug or am I setting something wrong?

EDIT: found another bug.

Go to definition doesn't work well when clicking the fragment(CommonItemsFragment) which is defined in .ts file.

items {
   ...CommonItemsFragment
}

I have many fragments(embedded string fragment) defined in one .ts file. Upon clicking the fragment, go to definiton leads to the correct file, but just to the start of the file and not where the string fragment is defined.

thanks

Expected Behavior

jump to correct line, where the type is defined.

Steps To Reproduce

No response

Environment

Anything else?

No response

acao commented 6 months ago

can you tell me if this release works for you? https://github.com/graphql/graphiql/pull/3521#issuecomment-1975500452