ardatan / ardatan/graphql-tools
Bug: HoistField does not support List in path
- Dominant language
- TypeScript
- Stars
- 5.4k
- Forks
- 830
- Avg merge
- 10h 59m
- Merged PRs (30d)
- 45
Description
When hoisting a field and the path to the field contains a list the resulting schema ignores that there was a list in the path.
**To Reproduce**
Given the following schema:
```graphql
type Query {
data: [Wrapper!]!
}
type Wrapper {
value: String!
}
```
Using the following configuration for hoist field:
```ts
new HoistField('Query', ['data', 'value'], 'data');
```
The result is:
```graphql
type Query {
data: String!
}
```
**Expected behavior**
The hoist field transform should instead generate the followings schema
```graphql
type Query {
data: [String!]!
}
```
Note:
- This should also work when there are multiple levels of lists (while supporting a single level of list would be the most crucial to support)
**Additional context**
Use case:
- We often find legacy APIs that wrap list result data in above described structures
- We use the HoistField transform (and others) to remove unnecessary nesting to provide a clean GraphQL API to consume
Contributor guide
Research direction
Start by locating the HoistField transform and reproduce the schema shown in the issue with a list in the path. Trace how the transform builds the resulting field type, then verify that one or multiple list levels preserve their wrappers and produce the expected schema.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- api, backend-api-design
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 48/100