Getting Started with GraphQL

Part 5: Deployment

Junhong Wang
2 min readJan 14, 2020

This is part 5 of Getting Started with GraphQL series. We will be building a Netflix clone with GraphQL. You can check out the demo app here. The source code is available here. You can also play around with demo app’s graphiql here.

Index

Deploying your app on Heroku

We will use Heroku to deploy our app. Heroku is a cloud platform where developers can deploy their applications. A nice thing about Heroku is that it’s free! There are some limitations for free version though. In particular, they put your server into sleep mode if there’s no access within 30 minutes, and it takes some time to load the website. If you are a student (like me!), there’s a good news. Heroku offers students free hobby dynos for up to 2 years. This means your app will remain active and respond to request 24/7.

Go to Heroku and create an account if you haven’t already. Create a new app and you should see a dashboard like this.

If you click Settings , you can set the environment variables at Config Vars section.

We will put DATABASE_URI as key and value from mLab website. Next, we need to change our server code a bit to make it work with Heroku. By default, Heroku only lets you use port 80, so make sure the server is listening at that port.

Finally, you can login to Heroku from terminal, and push your code to Heroku server as follows.

# login to Heroku
heroku login
# push your code to Heroku server
git push heroku master

That’s it! You should be able to see your app running on Heroku server. You can click Open app to visit the website.

--

--

Junhong Wang

I'm Junhong. I'm a Software Engineer based in LA. I specialize in full stack web development and writing readable code. junhong.wang