question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Mapped types are dropped when combined with unions at non-trivial depth.

See original GitHub issue

Issue workflow progress

Progress of the issue based on the Contributor Workflow

Make sure to fork this template and run yarn generate in the terminal.

Please make sure the Codegen and plugins version under package.json matches yours.

  • 2. A failing test has been provided

  • 3. A local solution has been provided

  • 4. A pull request is pending review


Describe the bug The resolver type for a type that contains a type that contains a union of types that are mapped, drops knowledge of the mapped type.

That a mouthful, but here is a minimal reproduction:

To Reproduce LIve Code Sandbox: https://codesandbox.io/s/inspiring-shape-ts0t5

  1. My GraphQL schema:
type Query {
    feed: FeedConnection!
}

type FeedConnection {
    edge:FeedEdge
}

type FeedEdge {
    node: FeedNode
}

union FeedNode = PostFeedNode | PhotoFeedNode

type PostFeedNode {
    text:String
}

type PhotoFeedNode {
    url:String
}
  1. My GraphQL operations: N/A

  2. My codegen.yml config file:

schema: schema.graphql
generates:
  types.ts:
    plugins:
      - typescript
      - typescript-resolvers
    config:
      mappers:
        PostFeedNode: ./model#PostFeedNodeModel
        PhotoFeedNode: ./model#PhotoFeedNodeModel

Expected behavior The resolver type should be: FeedConnection:ResolverTypeWrapper<Omit<FeedConnection, 'edge'> & { node?: Maybe<ResolversTypes['FeedEdge']> }>;

But the generated type is: FeedConnection: ResolverTypeWrapper<FeedConnection>;

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
mengyazhu96commented, Aug 4, 2021

Also bumped into this today!

1reaction
darkbasiccommented, May 18, 2021

Is this a regression of #3979?

Checking should be as easy as upgrading my repro to the latest version of the codegen.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Mappers are not used for union types · Issue #3979 - GitHub
The union AOrB type should be automatically mapped to MyA | MyB , but it doesn't. A quick workaround is to manually map...
Read more >
Mapped type that unions variations of the given type?
Mapped - iterates through each property and creates new part of expected union type where current key is set and other keys Exclude<keyof...
Read more >
CUDA C++ Programming Guide - NVIDIA Documentation Center
The texture width, height, and depth refer to the size of the array in each dimension. Table 15 lists the maximum texture width,...
Read more >
Mapping dominant leaf type based on combined Sentinel-1/-2 ...
Two machine learning approaches based on Random Forest (RF) and deep learning (UNET) for the whole country with three sets of predictor variables...
Read more >
WeedMap: A Large-Scale Semantic Weed Mapping ... - MDPI
The main goal of this paper is developing a novel crop/weed segmentation and mapping framework that processes multispectral images obtained from an unmanned ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found