DEV Community

Noah Vaillancourt
Noah Vaillancourt

Posted on

Notes About Prisma and Apollo Server Heroku Deployments

Deploying an Apollo server to Heroku is really tempting. The free tier is pretty good and if you're just deploying a small hobby project it works great. That's what I thought until I ran into problem after problem with my deployment. It took a few days of digging into Stack Overflow threads to really figure it out. The Problem is the deployment docs aren't all that complete. It's either that or I set my project up in such a way it wasn't working for me. Today I'm going to walk through the problems I had while deploying and what I did to fix them. Hopefully this helps someone else out down the line.

H10 - App Crash Error

This was one I kept running into when I first started deployment. The fix to this was actually really simple and it should have been obvious. Make sure that you have the start script set to 'node index.js' the problem was I had mine set to use nodemon which is a dev dependency that doesn't work in production.

Prisma Client Issues

Now I'm not sure what exactly was happening and why the generated client wasn't deploying but this was a problem I had to work through. After digging around a handful of forum posts and reading some docs I came up with this solution. You need to setup a post deploy hook in the scripts under package.json

"heroku-postbuild": "npx prisma generate"
Enter fullscreen mode Exit fullscreen mode

This will generate the Prisma client after everything finishes building. This should solve the fact that the server can't make Prisma calls.

Now this isn't the most "here's how to build a thing" kind of post. That's not the intention. The idea is if someone else out there runs into the same problems hopefully this post will help in some kind of way. If it doesn't and you're still running into issues feel free to DM me on twitter and I'll do my best to give you a hand.

Top comments (0)