Skip to content

Support enum fields in conditional hydration - #723

Merged
mcaliskan2 merged 2 commits into
atlassian-labs:masterfrom
mcaliskan2:fix/enum-conditional-hydration
May 4, 2026
Merged

Support enum fields in conditional hydration#723
mcaliskan2 merged 2 commits into
atlassian-labs:masterfrom
mcaliskan2:fix/enum-conditional-hydration

Conversation

@mcaliskan2

@mcaliskan2 mcaliskan2 commented Apr 28, 2026

Copy link
Copy Markdown
Contributor

Summary

Allow GraphQL enum types as the sourceField in @hydrated(when: { result: { ... } }) conditions, alongside the existing String/Int/ID scalars.

What's in scope

  • equals predicate accepts enum-typed condition fields. The supplied value must match a defined enum value (case-sensitive).
  • startsWith / matches continue to require String/ID — enums are rejected with the existing predicate-specific errors.
  • New NadelHydrationConditionInvalidEnumValueError raised when equals references a value not in the enum.
  • NadelHydrationResultConditionUnsupportedFieldTypeError message updated to mention enum

Implementation notes

  • Internal sealed NadelConditionFieldType introduced so per-predicate type checks stay readable as more variants get added.

Tests

  • Validation: nullable / non-null / list / renamed enums, invalid enum value, case-sensitivity, empty string, startsWith + matches rejection.
  • Integration fixtures: single conditional hydration, polymorphic (stacked @hydrated), and batched polymorphic

@atlassian-cla-bot

Copy link
Copy Markdown

Thank you for your submission! Like many open source projects, we ask that you sign our CLA (Contributor License Agreement) before we can accept your contribution.
If your email is listed below, please ensure that you sign the CLA with the same email address.

The following users still need to sign our CLA:
❌mcaliskan2

Already signed the CLA? To re-check, try refreshing the page.

@mcaliskan2
mcaliskan2 force-pushed the fix/enum-conditional-hydration branch from 7bb1aa4 to e369c59 Compare April 28, 2026 08:25
@mcaliskan2 mcaliskan2 changed the title [Testing] Support enum fields in conditional hydration Support enum fields in conditional hydration Apr 28, 2026
@gnawf

gnawf commented May 4, 2026

Copy link
Copy Markdown
Collaborator

Looks good. Need to convert the .yml tests to NadelIntegrationTest but good otherwise. I'll do that and merge it later today.

@gnawf gnawf left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved. I updated the .yml tests to the new NadelIntegrationTest

val condition: NadelHydrationConditionDefinition,
)

private sealed class NadelConditionFieldType {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice

).asInterimSuccess()
} else if (expectedValue is String && conditionFieldType is NadelConditionFieldType.EnumType) {
if (conditionFieldType.enumType.getValue(expectedValue) == null) {
return NadelHydrationConditionInvalidEnumValueError(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice

@mcaliskan2
mcaliskan2 marked this pull request as ready for review May 4, 2026 05:26
@mcaliskan2

mcaliskan2 commented May 4, 2026

Copy link
Copy Markdown
Contributor Author

Thank you @gnawf 🙂

@mcaliskan2
mcaliskan2 merged commit 7853616 into atlassian-labs:master May 4, 2026
2 of 3 checks passed
@mcaliskan2
mcaliskan2 deleted the fix/enum-conditional-hydration branch May 4, 2026 05:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants