public function mutation($operation, $input, $type, $baseVersion = null)
{
// If the given element is an Entity, it will use that baseVersion.
if ($input instanceof Entity) {
$baseVersion = $input->baseVersion();
$data = $this->entityMapper->objectToRequest($input);
} elseif ($input instanceof Key) {
$data = $input->keyObject();
} else {
throw new InvalidArgumentException(sprintf('Input must be a Key or Entity, %s given', get_class($input)));
}
return array_filter([$operation => $data, 'baseVersion' => $baseVersion]);
}