I have a cocomplete abelian category $\mathcal C$ and two objects $X$, $Y$ in $\mathcal C$. Further, $\mathcal C$ has a projective generator $P$. I have an isomorphism

$$ \mathcal C(P,X) \cong \mathcal C(P,Y)$$

It feels like this should be enough to show that $X\cong Y$ in $\mathcal C$. Because any object $Z$ in $\mathcal C$ can be written as a cokernel $P^J\longrightarrow P^I\longrightarrow Z\longrightarrow 0$ and so we have $\mathcal C(Z,X)\cong \mathcal C(Z,Y)$. It feels like the isomorphisms $\mathcal C(Z,X)\cong \mathcal C(Z,Y)$ are natural in $Z$ and do not depend on the choice of projective resolutions.

But I cannot be sure. Is this true? Any reference or pointers would be appreciated.