Unlike Next.js, Gatsby doesn't come with any way to include serverless functions (AKA "API Routes"). Fortunately, Netlify Functions offers the same functionality, with just a bit of setup.
This video shows how to configure an existing Gatsby site deployed through Netlify to enable functions, and how to test them locally. After following the steps in this video, you'll be all set up to add your own functions for a drop-in backend based on AWS Lambda.