@@ -818,6 +818,9 @@ of rules must be adhered to by every Object type in a GraphQL schema.
818818 characters {"__ "} (two underscores).
819819 2 . The argument must accept a type where {IsInputType(argumentType)}
820820 returns {true}.
821+ 3 . If the field is a Oneof Field:
822+ 1 . The field must be nullable.
823+ 2 . The field must not have a default value.
8218243 . An object type may declare that it implements one or more unique interfaces.
8228254 . An object type must be a super-set of all interfaces it implements:
823826 1 . Let this object type be {objectType}.
@@ -845,6 +848,8 @@ IsValidImplementation(type, implementedType):
845848 2 . Let {implementedFieldType} be the return type of {implementedField}.
846849 3 . {IsValidImplementationFieldType(fieldType, implementedFieldType)}
847850 must be {true}.
851+ 6 . {field} must be a Oneof Field if and only if {implementedField} is a
852+ Oneof Field.
848853
849854IsValidImplementationFieldType(fieldType, implementedFieldType):
850855 1 . If {fieldType} is a Non-Null type:
@@ -917,6 +922,30 @@ May yield the result:
917922The type of an object field argument must be an input type (any type except an
918923Object, Interface, or Union type).
919924
925+ ** Oneof Fields**
926+
927+ Oneof Fields are a special variant of Object Type fields where the type system
928+ asserts that exactly one of the field's arguments must be set and non-null, all
929+ others being omitted. This is useful for representing situations where an input
930+ may be one of many different options.
931+
932+ When using the type system definition language, the ` @oneOf ` directive is used
933+ to indicate that a Field is a Oneof Field (and thus requires exactly one of its
934+ arguments be provided):
935+
936+ ``` graphql
937+ type Query {
938+ findUser (
939+ byID : ID
940+ byUsername : String
941+ byEmail : String
942+ byRegistrationNumber : Int
943+ ): User @oneOf
944+ }
945+ ```
946+
947+ In schema introspection, the `__Field.oneArgument` field will return {true} for
948+ Oneof Fields , and {false } for all other Fields .
920949
921950### Field Deprecation
922951
@@ -1160,6 +1189,9 @@ Interface types have the potential to be invalid if incorrectly defined.
11601189 characters {"__" } (two underscores).
11611190 2. The argument must accept a type where {IsInputType (argumentType)}
11621191 returns {true }.
1192+ 3. If the field is a Oneof Field :
1193+ 1. The field must be nullable .
1194+ 2. The field must not have a default value .
116311953. An interface type may declare that it implements one or more unique
11641196 interfaces , but may not implement itself .
116511974. An interface type must be a super -set of all interfaces it implements :
@@ -1880,7 +1912,8 @@ provide:
18801912- the ` @deprecated ` directive if representing deprecated portions of the
18811913 schema;
18821914- the ` @oneOf ` directive if representing types that require exactly one field
1883- (i.e. Oneof Input Objects).
1915+ (i.e. Oneof Input Objects) or fields that require exactly one argument (i.e.
1916+ Oneof Fields).
18841917
18851918** Custom Directives**
18861919
@@ -2048,11 +2081,14 @@ type ExampleType {
20482081### @oneOf
20492082
20502083``` graphql
2051- directive @oneOf on INPUT_OBJECT
2084+ directive @oneOf on INPUT_OBJECT | FIELD_DEFINITION
20522085```
20532086
20542087The `@oneOf ` directive is used within the type system definition language
2055- to indicate an Input Object is a Oneof Input Object .
2088+ to indicate :
2089+
2090+ - an Input Object is a Oneof Input Object , or
2091+ - an Object Type 's Field is a Oneof Field .
20562092
20572093```graphql example
20582094input UserUniqueCondition @oneOf {
@@ -2061,3 +2097,14 @@ input UserUniqueCondition @oneOf {
20612097 organizationAndEmail : OrganizationAndEmailInput
20622098}
20632099```
2100+
2101+ ```graphql example
2102+ type Query {
2103+ findUser (
2104+ byID : ID
2105+ byUsername : String
2106+ byEmail : String
2107+ byRegistrationNumber : Int
2108+ ): User @oneOf
2109+ }
2110+ ```
0 commit comments