对象类型验证
Object types have the potential to be invalid if incorrectly defined. This set of rules must be adhered to by every Object type in a GraphQL schema.
- An Object type must define one or more fields.
- The fields of an Object type must have unique names within that Object type; no two fields may share the same name.
- Each field of an Object type must not have a name which begins with the characters "__" (two underscores).
- An object type must be a super‐set of all interfaces it implements:
- The object type must include a field of the same name for every field defined in an interface.
- The object field must be of a type which is equal to or a sub‐type of the interface field (covariant).
- An object field type is a valid sub‐type if it is equal to (the same type as) the interface field type.
- An object field type is a valid sub‐type if it is an Object type and the interface field type is either an Interface type or a Union type and the object field type is a possible type of the interface field type.
- An object field type is a valid sub‐type if it is a List type and the interface field type is also a List type and the list‐item type of the object field type is a valid sub‐type of the list‐item type of the interface field type.
- An object field type is a valid sub‐type if it is a Non‐Null variant of a valid sub‐type of the interface field type.
- The object field must include an argument of the same name for every argument defined in the interface field.
- The object field argument must accept the same type (invariant) as the interface field argument.
- The object field may include additional arguments not defined in the interface field, but any additional argument must not be required.
- The object field must be of a type which is equal to or a sub‐type of the interface field (covariant).
- The object type must include a field of the same name for every field defined in an interface.