apollographql / apollographql/apollo-tooling

VS Code extension: triggering intellisense in a union field throws an error

Open
#1,922 1 comment 1 reaction 0 assignees View on GitHub
:spiral_notepad: component - vscode
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.

![image](https://user-images.githubusercontent.com/2101409/80832446-85435780-8ba1-11ea-80de-1dfcdbf6a8d8.png)

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

Open the contributing 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.