Skip to content

[BUG] Mappers not applied to GraphQL union types #233

@lensbart

Description

@lensbart

Describe the bug
For some types, the mapper I define get ignored. I’ve had this happen with two types, both of which are union types, so I guess it’s related to that.

I hope the reduced schema below reproduces it. The schema uses Relay-style connections, but I think that’s unrelated.

The problem is that I don’t want to return someField from the parent resolver. Instead, I want to be forced to return it from its own resolver. In order to do so, it is my understanding that I either have to export UInterfaceMapper, or AMapper, BMapper and CMapper (or all of them) from my mappers file. When doing so, I don’t notice any difference, since the generated types don’t pick up these mappers for the union type U.

I only have 1 mapper file, and the other mapper types get picked up without any issue.

union U = A | B | C

interface UInterface {
	someField(after: String, first: NonNegativeInt!): [String!]!
}

type A implements UInterface {
	someField(after: String, first: NonNegativeInt!): [String!]!
	# ... other fields
}
type B implements UInterface {
	someField(after: String, first: NonNegativeInt!): [String!]!
	# ... other fields
}
type C implements UInterface {
	someField(after: String, first: NonNegativeInt!): [String!]!
	# ... other fields
}

type UConnection {
	edges: [UEdge!]!
	pageInfo: PageInfo!
}

type UEdge {
	cursor: String!
	node: U!
}

type Query {
	u: UConnection!
}

Versions

macOS 14.2.1 (23C71)
@eddeee888/gcg-typescript-resolver-files v0.7.2

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions