TITLE: Is there an example of a non measurable function with a measurable graph?
QUESTION [8 upvotes]: Let $(S, \Sigma)$ be a measurable space. Let $f: S \rightarrow \mathbb{R}$ be function and let $\mathcal{B}(\mathbb{R})$ be Borel $\sigma$-algebra on $\mathbb{R}$. Let $G(f)$ be the graph of $f$, that means
$ G(f)=\{(x,f(x)) \in S\times \mathbb{R} : x \in S\} $. We write $ \Sigma \otimes \mathcal{B}(\mathbb{R})$ to indicate the product $\sigma$-algebra of $\Sigma$ and $\mathcal{B}(\mathbb{R})$.
We can prove that:

If $f$ is $\Sigma$-$\mathcal{B}(\mathbb{R})$ measurable then $G(f) \in \Sigma \otimes \mathcal{B}(\mathbb{R})$.
Assuming that $S$ is a Polish space and $\Sigma$ is its Borel $\sigma$-algebra, if $G(f) \in \Sigma \otimes \mathcal{B}(\mathbb{R})$ then $f$ is $\Sigma$-$\mathcal{B}(\mathbb{R})$ measurable.

The proof of item 1 is rather easy. The proof of item 2 is more advanced and uses analytic sets. One such proof can found in here (section 3 proposition 6).
Question: Can we prove that if $G(f) \in \Sigma \otimes \mathcal{B}(\mathbb{R})$ then $f$ is $\Sigma$-$\mathcal{B}(\mathbb{R})$ measurable in the general case (that is, just having $(S, \Sigma)$ a measurable space)? If not, is there a counterexample (that is, an example where  $G(f) \in \Sigma \otimes \mathcal{B}(\mathbb{R})$, but $f$ is not $\Sigma$-$\mathcal{B}(\mathbb{R})$ measurable)?
(Of course changing the $\sigma$-algebra in the counter-domain makes it trivial to have counter-examples).
Remark: Examples where  $G(f) \notin \Sigma \otimes \mathcal{B}(\mathbb{R})$ and $f$ is not $\Sigma$-$\mathcal{B}(\mathbb{R})$ measurable are rather trivial to produce. They are not what I am asking for.

Let $X=[0,1]$, $\Sigma$ be the Borel $\sigma$-algebra in $[0,1]$, let $A\subseteq [0,1]$ be a set not in $\Sigma$. Let $f$ be $\chi_A$ (the indicator function) of $A$. Its is easy to see that $G(f) \notin \Sigma \otimes \mathcal{B}(\mathbb{R})$, and $f$ is not $\Sigma$-$\mathcal{B}(\mathbb{R})$ measurable.

REPLY [8 votes]: See Srivastava, A Course on Borel Sets, in the section "Solovay's Coding of Borel Sets", beginning at "We now proceed to give an example of a function with domain coanalytic whose graph is Borel and that is not Borel measurable." Google books preview (There is a typo: it should say $E\subseteq C\times \mathbb R\times 2^{\mathbb N}$ instead of $E\subseteq \mathbb R\times 2^{\mathbb N}.$)
The example is a function $f:C\times \mathbb R\to2^{\mathbb N}$ where $C$ is a set of codes for Borel sets. Of course $\mathbb R$ is Borel isomorphic to $2^{\mathbb N}.$