Combine basil, 4 tablespoons Parmesan cheese, pine nuts, olive oil, whole garlic cloves, salt, and pepper in a blender; puree until pesto is smooth.
Melt butter in a frying pan over medium heat. Add minced garlic; cook until fragrant, 30 seconds to 1 minute. Add shrimp; cook and stir until opaque, 2 to 3 minutes. Remove from heat and keep warm.
Bring a large pot of lightly salted water to a boil. Cook gnocchi in the boiling water until they float to the top, 2 to 4 minutes. Drain. Mix pesto into gnocchi and serve with shrimp. Garnish with remaining Parmesan cheese.