@@ -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 :
@@ -1879,7 +1911,8 @@ provide:
18791911- the ` @deprecated ` directive if representing deprecated portions of the
18801912 schema;
18811913- the ` @oneOf ` directive if representing types that require exactly one field
1882- (i.e. Oneof Input Objects).
1914+ (i.e. Oneof Input Objects) or fields that require exactly one argument (i.e.
1915+ Oneof Fields).
18831916
18841917** Custom Directives**
18851918
@@ -2047,11 +2080,14 @@ type ExampleType {
20472080### @oneOf
20482081
20492082``` graphql
2050- directive @oneOf on INPUT_OBJECT
2083+ directive @oneOf on INPUT_OBJECT | FIELD_DEFINITION
20512084```
20522085
20532086The `@oneOf ` directive is used within the type system definition language
2054- to indicate an Input Object is a Oneof Input Object .
2087+ to indicate :
2088+
2089+ - an Input Object is a Oneof Input Object , or
2090+ - an Object Type 's Field is a Oneof Field .
20552091
20562092```graphql example
20572093input UserUniqueCondition @oneOf {
@@ -2060,3 +2096,14 @@ input UserUniqueCondition @oneOf {
20602096 organizationAndEmail : OrganizationAndEmailInput
20612097}
20622098```
2099+
2100+ ```graphql example
2101+ type Query {
2102+ findUser (
2103+ byID : ID
2104+ byUsername : String
2105+ byEmail : String
2106+ byRegistrationNumber : Int
2107+ ): User @oneOf
2108+ }
2109+ ```
0 commit comments