Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add getDefinitionAtPosition #1248

Merged
merged 4 commits into from Mar 27, 2024
Merged

feat: Add getDefinitionAtPosition #1248

merged 4 commits into from Mar 27, 2024

Conversation

Quramy
Copy link
Owner

@Quramy Quramy commented Mar 19, 2024

What

Add "Go to Definition" feature for fragment spread.

For example, in VSCode, user trigger "Go to definition" (F12 key by default) when the cursor is at the following (A) position, this feature navigates the cursor to (B).

const query = graphql`
  query AppQuery {
     ...AppFragment
##      ^
##      (A) Cursor
  }
`;

const fragment = graphql`
  fragment AppFragment on Query {
##         ^
##         (B) Definition location
    __typename
  }
`

Limitations

This feature depends on global fragment registry.

If users do not turn on enabledGlobalFragments, they can't use this feature.
But I don't think it's a problem. Disabling global fragments means that reference to fragment between multiple template expression requires interpolation. And the explicit interpolation indicates where the fragment definition is located.

Copy link

codecov bot commented Mar 19, 2024

Codecov Report

Attention: Patch coverage is 95.28302% with 5 lines in your changes are missing coverage. Please review.

Project coverage is 96.59%. Comparing base (b2721bd) to head (6ed82f8).
Report is 29 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1248      +/-   ##
==========================================
- Coverage   96.62%   96.59%   -0.03%     
==========================================
  Files          73       75       +2     
  Lines        5740     5845     +105     
  Branches      856     1143     +287     
==========================================
+ Hits         5546     5646     +100     
- Misses        192      193       +1     
- Partials        2        6       +4     
Files Coverage Δ
src/gql-ast-util/fragment-registry.ts 96.64% <100.00%> (+0.03%) ⬆️
...e-service-adapter/get-definition-and-bound-span.ts 100.00% <100.00%> (ø)
...uage-service-adapter/get-definition-at-position.ts 100.00% <100.00%> (ø)
...ervice-adapter/graphql-language-service-adapter.ts 96.77% <100.00%> (+0.64%) ⬆️
...c/language-service-plugin/plugin-module-factory.ts 97.75% <100.00%> (+0.05%) ⬆️
src/graphql-language-service-adapter/types.ts 0.00% <0.00%> (ø)

... and 4 files with indirect coverage changes

@Quramy Quramy changed the title wip: feat: Add getDefinitionAtPosition feat: Add getDefinitionAtPosition Mar 19, 2024
@Quramy Quramy marked this pull request as ready for review March 27, 2024 03:25
@Quramy Quramy merged commit da16ec7 into main Mar 27, 2024
1 of 3 checks passed
@Quramy Quramy deleted the goto_def branch March 27, 2024 03:43
ckomop0x pushed a commit to ckomop0x/ckomop0x.me.site.v2 that referenced this pull request Mar 30, 2024
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [ts-graphql-plugin](https://togithub.com/Quramy/ts-graphql-plugin) |
[`3.1.2` ->
`3.2.0`](https://renovatebot.com/diffs/npm/ts-graphql-plugin/3.1.2/3.2.0)
|
[![age](https://developer.mend.io/api/mc/badges/age/npm/ts-graphql-plugin/3.2.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/ts-graphql-plugin/3.2.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/ts-graphql-plugin/3.1.2/3.2.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/ts-graphql-plugin/3.1.2/3.2.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

<details>
<summary>Quramy/ts-graphql-plugin (ts-graphql-plugin)</summary>

###
[`v3.2.0`](https://togithub.com/Quramy/ts-graphql-plugin/releases/tag/v3.2.0)

[Compare
Source](https://togithub.com/Quramy/ts-graphql-plugin/compare/v3.1.2...v3.2.0)

#### New Features

- feat: Add getDefinitionAtPosition by
[@&#8203;Quramy](https://togithub.com/Quramy) in
[Quramy/ts-graphql-plugin#1248

#### Misc Changes

- test: fix spec name typo by
[@&#8203;Quramy](https://togithub.com/Quramy) in
[Quramy/ts-graphql-plugin#1243
- chore: Modify type imports by
[@&#8203;Quramy](https://togithub.com/Quramy) in
[Quramy/ts-graphql-plugin#1244
- test: Refactor lang service adapter fixture by
[@&#8203;Quramy](https://togithub.com/Quramy) in
[Quramy/ts-graphql-plugin#1250
- chore: Uninstall unused dev deps by
[@&#8203;Quramy](https://togithub.com/Quramy) in
[Quramy/ts-graphql-plugin#1265

**Full Changelog**:
Quramy/ts-graphql-plugin@v3.1.2...v3.2.0

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://developer.mend.io/github/ckomop0x/ckomop0x.me.site.v2).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4yNjkuMiIsInVwZGF0ZWRJblZlciI6IjM3LjI2OS4yIiwidGFyZ2V0QnJhbmNoIjoibWFzdGVyIn0=-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant