Repository navigation
fix(graphql-language-service): suggest fields after a fragment spread - #4760
Open
unrevised6419 wants to merge 1 commit into
Open
unrevised6419 wants to merge 1 commit into
unrevised6419 wants to merge 1 commit into
Conversation
After a complete fragment spread name the parser stays in the FragmentSpread state (waiting for optional directives), which no completion branch handled, so an empty position after `...Foo` returned no suggestions. Treat it like a field state and suggest the parent type's fields. Fixes graphql#3437 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: b7948e3 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
This branch has not been deployed
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Field autocomplete returned nothing on an empty position right after a fragment spread:
After a complete spread name, the online parser stays in the
FragmentSpreadstate at step 2 (waiting for optional directives, or step 3 with experimental fragment arguments).getAutocompleteSuggestionsonly handledFragmentSpreadat step 1 (the fragment name), so this position fell through every branch.typeInfo.parentTypeis already set there, so this change routesFragmentSpreadwithstep > 1to the existing field-name suggestions, the same way aFieldstate after its name already works.Fixes #3437
Changes
getAutocompleteSuggestions.ts: includeFRAGMENT_SPREAD && step > 1in the field-name branch.experimentalFragmentArguments.codemirror-graphqlhint.test.ts: drop the case that asserted no suggestions afterquery { ...Foo(it encoded this bug).graphql-language-service.How to verify
npx vitest run packages/graphql-language-service/src/interface/__tests__/getAutocompleteSuggestions.test.ts -t "after a fragment spread"....Fragmentspread and trigger completion: the parent type's fields are suggested.graphql-language-service(304) andcodemirror-graphql(69) tests pass. Also checked manually in the VS Code extension:Note: fields are now also suggested on the same line after the spread (
...Foo |), where a directive could also follow, which matches how completion already behaves after a field name ({ id |).🤖 Generated with Claude Code
AI assisted