Putting $x = y = 0$, we get $f(f(0)) = 0.$
Now, putting $x=0$, we get $f(f(0)) = yf(0)$ $\forall y$.
Hence, $f(0) = 0$ as well.
Substituting $y = 0$, we get that $f(f(x)) = x.$
Also, putting $y = f(y)$ in original equation, we get :
$f(xy+f(x)) = f(x)f(y)+x$.
Putting $x=y=1$ in this equation, we get $f(1+f(1)) = f^{2}(1)+1$
Now, putting $x=y=1$ in original equation, we get $f(2f(1)) = f(1)+1$
$\implies 2f(1) = f(f(1) + 1). $
But, $f(f(1)+1) = f^{2}(1)+1 = 2f(1).$
Thus, we get $f(1) = 1.$
Now, assuming $f(n)=n$ and putting $x=1$ and $y=n$ respectively in original equation gives us :
$f(n+1) = n+1$. Hence, $f(x) = x$ $\forall x \in \mathbb{N}$ by induction.
Now, putting $x=1,y=-1$ in $f(xy+f(x)) = f(x)f(y) + x$, we get :
$f(f(1)-1) = f(-1) + 1 = 0.$
Hence, $f(-1) = -1.$
Now, putting $x=-1$ and $y=n$ in original equation, we get:
$f(-(n+1)) = -(n+1).$
Hence, $f(x) = x$ $\forall x \in \mathbb{Z}.$
Now, putting $y = \frac{p}{q}$ and $x=q$, we get :
$f(q.f(\frac{p}{q})+q) = p+q$.
Applying f on both sides, we get :
$q.f(\frac{p}{q})+q = p+q.$
$\implies f(\frac{p}{q}) = \frac{p}{q}.$
Hence, $f(x) = x$ $\forall x \in \mathbb{Q}$.