MutationInput type
Transforms an entity type for mutation input.
@onerelationship fields becomeRelationshipInput<T>(accepts full object or id-only)@manyrelationship fields (arrays) are allowed but ignored at runtime (they're managed via the FK on the "many" side, not on the parent)- Primitive fields remain unchanged
type MutationInput<T> = {
[K in keyof T]: NonNullable<T[K]> extends any[]
? T[K]
: IsRelationship<NonNullable<T[K]>> extends true
?
| RelationshipInput<NonNullable<T[K]>>
| (undefined extends T[K] ? undefined : never)
: T[K]
}
Remarks
This type preserves optionality: if a field is optional in the entity (e.g., category?: Category),
it remains optional in the mutation input.
@many arrays can be passed for convenience but will be ignored by the GraphQL mutation.
To manage @many relationships, update the child entities' @one references instead.