In a large bowl, combine the ricotta, 1 cup of the flour, the egg, and 1 teaspoon salt until just blended.
Add additional flour up to 1 cup more, 1/4 cup at a time, stirring with a wooden spoon until a smooth, slightly sticky dough forms.
Turn the dough onto a well-floured surface and knead briefly until it comes together, is smooth, and slightly elastic; use about 3/4 cup more flour as needed.
Form the dough into a ball, wrap in plastic, and refrigerate for 30 minutes.
Divide the chilled dough into 8 pieces. Roll the first piece on a lightly floured surface into a long rope about the diameter of your finger.
Cut the rope into 1/2-inch pieces. If desired, roll each piece over the back of a fork to create ridges, then place on a parchment-lined baking sheet. Repeat with remaining dough.
Bring a large pot of well-salted water to a boil. Add gnocchi and cook 3–5 minutes; they will rise to the surface—once floating, cook at least 1–2 more minutes to ensure done.
Meanwhile, make the marinara: heat olive oil in a skillet, cook garlic cloves until slightly golden, then add diced onion and cook until soft.
Add tomato paste to the skillet, stir briefly, then carefully add canned tomatoes (watch for splattering). Season with a pinch of sugar, basil, oregano, salt, and pepper.
Simmer the sauce about 30 minutes, remove the garlic cloves, then toss the drained gnocchi with the marinara and serve.