GraphQL @oneOf Directive Now Standard, Enforcing Exactly One Input Field in Schemas
The GraphQL specification's September 2025 edition officially standardizes the @oneOf directive, which enforces that exactly one field is supplied in an input object. Previously, developers had to choose between multiple root fields or nullable arguments with manual resolver-level validation — both error-prone approaches. By marking an input type with @oneOf, the schema itself rejects invalid combinations before a resolver ever runs, moving constraint logic out of application code. The directive also enables polymorphic inputs, filling a long-standing gap since GraphQL has supported union types only on the output side. Major server libraries including GraphQL.js v16+, GraphQL Ruby, GraphQL Java, and others already ship support for the feature.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)
Log in to join the discussion and vote.
Log in