graphql / graphql/graphiql

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

Open
#3,546 1 comment 0 reactions 0 assignees View on GitHub
bug graphiql
Dominant language
TypeScript
Stars
16.9k
Forks
1.9k
Avg merge
22h 45m
Merged PRs (30d)
70

Description

### Is there an existing issue for this?

- [X] I have searched the existing issues

### 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.

```graphql
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.
```graphql
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

* GraphiQL Version: latest. I have tried the v0.10.0, with the vsix file.
* OS: Sonoma 14.0
* Browser: chrome
* Bundler: webpack
* `react` Version: 17
* `graphql` Version:

### Anything else?

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.