apollographql / apollographql/apollo-tooling
VS Code extension: triggering intellisense in a union field throws an error
- Dominant language
- TypeScript
- Stars
- 3k
- Forks
- 460
- PR merge metrics
- No merged PRs in 30d
Description
**Intended outcome:**
When trying to autocomplete fields in a union type, the extension offers to define an inline fragment (preferred) or otherwise notify me that there are no interesting fields to autocomplete (dispreferred, but acceptable).
**Actual outcome:**
When I try to autocomplete the fields in a union type, the extension throws and pops up the error pane. The autocomplete includes no context-aware options.

An instance of the error:
```
[Error - 11:45:49 AM] Request textDocument/completion failed.
Message: Request textDocument/completion failed with message: parentType.getFields is not a function
Code: -32603
```
**How to reproduce the issue:**
`BindingTargetSpec` is the type of the field that I was trying to autocomplete:
```graphql
type MeasurementBindingTargetSpec {
nodeLocation: String!
nodeType: String
nodeSubtype: String
measurementType: String!
}
type PropertyBindingTargetSpec {
nodeLocation: String!
nodeType: String
nodeSubtype: String
propertyName: String!
}
union BindingTargetSpec = MeasurementBindingTargetSpec | PropertyBindingTargetSpec
```
**Versions**
Extension version: v1.15.3
Contributor guide
Research direction
Start by reproducing the failure through the VS Code extension's textDocument/completion request using the provided BindingTargetSpec union. Compare the intended inline-fragment or no-options behavior with the reported parentType.getFields error. Done means union-field completion no longer throws and provides the expected context-aware result.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- graphql, typescript
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100