-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature: LSP Fragment completions (#4134)
Summary: # LSP Fragment Completions Adds support for `__typename`, fragment, and inline fragment completions for `interface`/`union`/`type`. Completions are ordered using [`sortText`](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_completion), with the following `precedence`: 1. Fields on the type, e.g., fields from `type`/`interface` 2. `__typename` 3. `...on T` inline fragments 4. `...F` fragments The modified tests show the behaviour, but a summary here is: ## `interface` - `__typename: String!` completion - `...on T` completions for the `interface` type itself and all types which implement it - `...F` completions for all fragments `F` on the `interface` or any `implements`' of it ### Example <img width="468" alt="Screenshot 2022-11-21 at 13 59 39" src="https://user-images.githubusercontent.com/17055343/203078448-465eb2ab-6165-49ee-9f9d-403bcbe6f739.png"> ## `union` - `__typename: String!` completion - `...on T` completions for the `union` type itself and for each variant - `...F` completions for all fragments `F` on the `union` or any variants of it ### Example <img width="471" alt="Screenshot 2022-11-21 at 13 59 56" src="https://user-images.githubusercontent.com/17055343/203078444-9f98c439-facb-4c5d-ab0b-ccf552fca0e2.png"> ## `type` - `__typename: String!` completion - `...F` completions for all fragments `F` on the `type` or on any `interface`s or `union`s it implements ### Example <img width="469" alt="Screenshot 2022-11-21 at 14 00 10" src="https://user-images.githubusercontent.com/17055343/203078437-10b43e4d-152c-4592-a7e9-2bfad020cde4.png"> ## Questions: - [x] Does Relay have a preferred style for spacing of fragments? Which should be used on these completions? Should this be a user configurable option? - `...on T` vs `... on T` - `...F` vs `... F` - [x] Should inline fragment completions exist for the type itself? E.g., when fragmenting on a `type User`, should `...on User` be suggested? - At the moment this MR adds this for `interface` & `union` but not `type` - should this be consistent? - [x] Will this feature be annoying for users of the LSP in orgs with a large codebase & lots of fragments? Should either of these be user configurable? - [x] Is the `sortText` robust enough? This has been implemented by prefixing a number to the start of the `label`; it seems to work for me locally ([code](https://github.com/facebook/relay/pull/4134/files#diff-04b7155ac238238b6434c2f32c30439229c0127075572f2d2f7519b574ff90c6R1018)) Pull Request resolved: #4134 Reviewed By: tyao1 Differential Revision: D41470372 Pulled By: alunyov fbshipit-source-id: ef04a34fb7e145cb9884c8b79345fd8e0a26cf83
- Loading branch information
1 parent
8eea4aa
commit 96c7193
Showing
3 changed files
with
382 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.