feat: @oneOf input directive support#2183
Open
samuelAndalon wants to merge 2 commits into
Open
Conversation
added 2 commits
June 16, 2026 16:19
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📝 Description
Add support for GraphQL
@oneOfdirective for input objects .See:
https://graphql.org/blog/2025-09-04-multioption-inputs-with-oneof/
https://spec.graphql.org/September2025/#sec-OneOf-Input-Objects
What graphql-java provides
graphql-java owns the directive definition and all input validation— runs before our convertArgumentValue:
Directive def — @OneOf SDL definition baked into graphql-java.
Input validation/coercion — ValuesResolverOneOfValidation (source) enforces oneOf rules at execution time, per spec:
exactly one field supplied,
that field's value non-null,
rejects map with 0 or 2+ keys -> error before resolver runs.
So by the time graphql-kotlin runtime code sees the argument map, it is already validated: guaranteed single non-null entry. That's why mapToOneOfKotlinObject can safely
do input.entries.single() — no defensive count check needed.
What graphql-java does NOT cover
graphql-java works in graphql land. It knows nothing about Kotlin sealed types. It does not:
What graphql-kotlin adds
🔗 Related Issues
#1891
Examples