Lightly roast pine nuts in a pan without fat, remove. Put the gnocchi in about 2 litres of boiling salted water and let them simmer for about 2 minutes until they float on top. Wash and halve the tomatoes.
Drain the mozzarella and cut into slices. Peel and finely chop the onion. Heat the oil in a frying pan. Fry the onions for 2 minutes. Add the tomatoes and fry for 2 minutes. Drain gnocchi on a sieve and add to the tomatoes.
Carefully fold in the pesto. Spread mozzarella on top. Cover and let it melt at low heat for about 2 minutes. Arrange gnocchi, sprinkle with pine nuts and garnish with basil.