Skip to content

Conversation

tyranron
Copy link
Member

@tyranron tyranron commented Oct 9, 2025

Resolves #1062, #1055
Part of #1347

Synopsis

GraphQL spec September 2025 supports @oneOf directive on input objects:

OneOf Input Objects are a special variant of Input Objects where the type system asserts that exactly one of the fields must be set and non-null, all others being omitted. This is represented in introspection with the __Type.isOneOf: Boolean field, and in SDL via the @oneOf directive on the input object.

input UserBy @oneOf {
  id: ID
  email: String
  username: String
  registrationNumber: Int
}
type Query {
  user(by: UserBy!): User
}

Solution

  • Add @oneOf directive to introspection schema
  • Add __Type.isOneOf field to introspection schema
  • Support placing @oneOf directive to the correct place
  • Support enums in derive(GraphQLInputObject) macro
  • Add validation rules for @oneOf input objects

Checklist

  • Docs are added
  • Tests are added
  • CHANGELOG entry is added

@tyranron tyranron added this to the 0.18.0 milestone Oct 9, 2025
@tyranron tyranron self-assigned this Oct 9, 2025
@tyranron tyranron mentioned this pull request Oct 9, 2025
23 tasks
@tyranron tyranron added enhancement Improvement of existing features or bugfix k::api Related to API (application interface) feature New feature or request labels Oct 9, 2025
@tyranron tyranron added the k::design Related to overall design and/or architecture label Oct 9, 2025
@tyranron tyranron linked an issue Oct 13, 2025 that may be closed by this pull request
@tyranron tyranron changed the title @oneOf input objects (#1062, #1347) @oneOf input objects (#1062, #1055, #1347) Oct 13, 2025
@tyranron tyranron marked this pull request as ready for review October 17, 2025 15:18
@tyranron tyranron enabled auto-merge (squash) October 17, 2025 15:21
@tyranron tyranron merged commit fe3dfaa into master Oct 17, 2025
180 checks passed
@tyranron tyranron deleted the 1062-oneof-input-objects branch October 17, 2025 15:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Improvement of existing features or bugfix feature New feature or request k::api Related to API (application interface) k::design Related to overall design and/or architecture

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GraphQL spec September 2025 Support of the @OneOf Input Object feature Feature Request: Derivable custom input objects

1 participant