Roger Federer was beaten by Nikoloz Basilashvili in three sets at the Qatar Open in his second match back since returning from injury.