# More expressive schemas with @oneOf

DevFeed: [More expressive schemas with @oneOf](<https://devfeed.tech/articles/more-expressive-schemas-with-oneof-23459.md>)

Original publisher: [Read original article](<https://www.apollographql.com/blog/more-expressive-schemas-with-oneof>)

Author: Benoit Lubek

Published: 2024-09-25T07:10:00Z

Content type: article

Language: en

Sources: [Apollo Blog](<https://devfeed.tech/sources/apollo-blog.md>)

Topics: [GraphQL](<https://devfeed.tech/topics/graphql.md>), [API](<https://devfeed.tech/topics/api.md>), [interfaces](<https://devfeed.tech/topics/interfaces.md>), [Kotlin](<https://devfeed.tech/topics/kotlin.md>)

Tags: [api](<https://devfeed.tech/tags/api.md>), [compatibility](<https://devfeed.tech/tags/compatibility.md>), [experimental](<https://devfeed.tech/tags/experimental.md>), [graphql](<https://devfeed.tech/tags/graphql.md>), [interfaces](<https://devfeed.tech/tags/interfaces.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [mobile](<https://devfeed.tech/tags/mobile.md>), [schema](<https://devfeed.tech/tags/schema.md>), [validation](<https://devfeed.tech/tags/validation.md>)

## AI overview

The article explains GraphQL's OneOf RFC, which proposes a built-in directive for input types requiring exactly one field. It also describes backward compatibility and experimental support for @oneOf in Apollo Kotlin 4.

## Source excerpt

GraphQL, the lingua franca of APIs, offers a palette of expressive tools: interfaces, nullability, deprecation, unions, etc. Occasionally though, a backend's contract would be reflected more precisely, if only it could be represented in the schema. Take unions for example: they can be used for output types, but not input types, so a search API accepting different kinds of criteria can be implemented like this: This works, but is a bit tedious, and what we really mean is something like .