Skip to content

fix(schema-generator): custom union lookup on deprecated properties#2178

Merged
samuelAndalon merged 2 commits into
ExpediaGroup:masterfrom
Samjin:fix/deprecated-meta-union-list
Jun 16, 2026
Merged

fix(schema-generator): custom union lookup on deprecated properties#2178
samuelAndalon merged 2 commits into
ExpediaGroup:masterfrom
Samjin:fix/deprecated-meta-union-list

Conversation

@Samjin

@Samjin Samjin commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Problem

Custom union annotations can be missed when they are used on a property that also has another annotation, such as @deprecated. This leads to a failing build job and user can't deprecate the union below.

  @GraphQLUnion(
      name = "ToolbarAction",
      possibleTypes = [IconButton::class, TextButton::class]
  )
  annotation class ToolbarAction

  data class Sheet(
      @Deprecated("Use toolbar instead")
      @ToolbarAction
      val actions: List<Any>
  )

The current

annotations
  .map { it.getMetaUnionAnnotation() }
  .firstOrNull()

returns null as result and missing the ToolbarAction and fail build job.

Approach

Skip annotations that do not contain a meta-union and use the first actual match.

This keeps the existing behavior for direct @GraphQLUnion annotations and for fields without custom unions, while allowing deprecated custom-union properties to generate the expected union field and preserve the deprecation reason.

@Samjin Samjin marked this pull request as ready for review June 9, 2026 17:52
@Samjin Samjin changed the title fix custom union lookup on deprecated properties fix(schema-generator): custom union lookup on deprecated properties Jun 9, 2026
@samuelAndalon samuelAndalon merged commit c202817 into ExpediaGroup:master Jun 16, 2026
8 checks passed
samuelAndalon pushed a commit that referenced this pull request Jun 17, 2026
Back port #2178 to v6 
Coverage always run before integration and cause constant failing in PR
check. 7+ version doesn't have such issue.

---------

Co-authored-by: sjin <sjin@expediagroup.com>
Samjin pushed a commit to Samjin/graphql-kotlin that referenced this pull request Jun 18, 2026
Samjin pushed a commit to Samjin/graphql-kotlin that referenced this pull request Jun 18, 2026
Samjin pushed a commit to Samjin/graphql-kotlin that referenced this pull request Jun 18, 2026
Samjin pushed a commit to Samjin/graphql-kotlin that referenced this pull request Jun 18, 2026
Samjin pushed a commit to Samjin/graphql-kotlin that referenced this pull request Jun 18, 2026
Samjin added a commit to Samjin/graphql-kotlin that referenced this pull request Jun 18, 2026
…xpediaGroup#2178)

## Problem

Custom union annotations can be missed when they are used on a property
that also has another annotation, such as @deprecated. This leads to a
failing build job and user can't deprecate the union below.

```kotlin
  @GraphQLUnion(
      name = "ToolbarAction",
      possibleTypes = [IconButton::class, TextButton::class]
  )
  annotation class ToolbarAction

  data class Sheet(
      @deprecated("Use toolbar instead")
      @ToolbarAction
      val actions: List<Any>
  )
```

The current 
```kotlin
annotations
  .map { it.getMetaUnionAnnotation() }
  .firstOrNull()
```
returns `null` as result and missing the ToolbarAction and fail build
job.

## Approach

Skip annotations that do not contain a meta-union and use the first
actual match.

This keeps the existing behavior for direct @GraphQLUnion annotations
and for fields without custom unions, while allowing deprecated
custom-union properties to generate the expected union field and
preserve the deprecation reason.

---------

Co-authored-by: sjin <sjin@expediagroup.com>
Samjin added a commit that referenced this pull request Jun 18, 2026
Back port #2178 to v7

Co-authored-by: sjin <sjin@expediagroup.com>
Samjin added a commit that referenced this pull request Jun 18, 2026
Back port #2178 to v8

Co-authored-by: sjin <sjin@expediagroup.com>
Samjin added a commit that referenced this pull request Jun 18, 2026
Back port #2178 to v9

Co-authored-by: sjin <sjin@expediagroup.com>
samuelAndalon pushed a commit that referenced this pull request Jun 18, 2026
)

Cherry pick #2178 to `v10.x.x` branch.

Co-authored-by: sjin <sjin@expediagroup.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants