Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: HoistField does not support List in path #3906

Open
Tracked by #5201 ...
ntziolis opened this issue Nov 21, 2021 · 2 comments
Open
Tracked by #5201 ...

Bug: HoistField does not support List in path #3906

ntziolis opened this issue Nov 21, 2021 · 2 comments
Labels
stage/1-reproduction A reproduction exists

Comments

@ntziolis
Copy link
Contributor

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:

type Query {
   data: [Wrapper!]!
}

type Wrapper {
   value: String!
}

Using the following configuration for hoist field:

new HoistField('Query', ['data', 'value'], 'data');

The result is:

type Query {
   data: String!
}

Expected behavior
The hoist field transform should instead generate the followings schema

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
@ntziolis
Copy link
Contributor Author

Added simple unit test that covers this case:
ntziolis@3107071

@ardatan
Copy link
Owner

ardatan commented Jan 13, 2022

Would you create a PR with this failing test?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stage/1-reproduction A reproduction exists
Projects
None yet
Development

No branches or pull requests

2 participants