Projective objects in a presheaf topos is a retract of representables

An object $P$ in a category is projective if the Hom-set $Hom(P,-)$ preserves epi. Considering the presheaf topos $\hat{C}=\mathbf{Sets}^{C^{op}}$, how can I show that an object in this category is projective then the object is a retract of a coproduct of representables?

I know that a representable is projective and the coproduct of representables is projective. I also think of that a presheaf is a colimit of representables. But I'm not sure how to relate these two to solve the question.

• This isn't true for this sense of "projective"-the coproduct of representables has no reason to be a retract of a representable in general. The sense of "projective" which is relevant here is "small-projective": an object $x$ such that maps out of $x$ commute with arbitrary small colimits. – Kevin Carlson Apr 23 '18 at 20:16
• @KevinCarlson Sorry that should be a retract of a coproduct of representables. And this is exercise IV.15(d) from MacLane and Moerdijk. Sheaves in geometry and logic: A first introduction to topos theory. – user301513 Apr 23 '18 at 20:37

In a category with the relevant coproducts, every colimit can be written as the coequalizer of a coproduct. In particular, every presheaf $P$ has the form of a coequalizer
$$\coprod_i U_i \rightrightarrows \coprod_j V_j \xrightarrow{\rho} P$$
where the $U_i$ and $V_j$ are represenetables.
Coequalizers are epic, so we can apply the given property of $P$:
$$\hom\left(P, \coprod_j V_j \right) \xrightarrow{\rho_*} \hom(P, P)$$
is surjective. In particular, there is a map $\lambda : P \to \coprod_j V_j$ such that $\rho \circ \lambda = 1_P$.