Functional equation $f(x+y)=f(x)f(y)-f(xy)+1$

$f(0)=f(0+0)=f(0)^2-f(0)+1$ so $(f(0)-1)^2=0$, $\therefore f(0)=1$.
Let $f(1)=a+1$, then noting that $f(n+1)=af(n)+1$ \begin{align}f(2)&=f(1+1)=a^2+a+1\\ f(4)&=f(3+1)=\cdots=a^4+a^3+a^2+a+1\\ &=f(2+2)=f(2)^2-f(4)+1\end{align} $$\therefore 2f(4)=f(2)^2+1$$ Solving for $a$ gives $a=-1,0,1$.

If $a=-1$, $f(1)=0$, then $f(n)=\begin{cases}1&n \textrm{ odd}\\0&n \textrm{ even}\end{cases}$. This gives the formula $f(x+1)=1-f(x)$. This function does not extend to $\mathbb{Q}$ otherwise $f(1)=f(2\times\tfrac{1}{2})=f(2)f(\tfrac{1}{2})-f(2+\tfrac{1}{2})+1$, which is the same as $0=f(\tfrac{1}{2})-f(\tfrac{1}{2})+1$.

If $a=0$, then $f(n)=1$ for all $n$. This extends to all of $\mathbb{Q}$ by noting that $f(x+1)=f(x)f(1)-f(x)+1=1$.

If $a=1$, then $f(n)=n+1$ for all $n$. This extends as in this answer to $\mathbb{Q}$.

The last two functions $f(x)=x+1$ and $f(x)=1$ satisfy the general formula for all $x\in \mathbb{Q}$.