Jan Wilmake's Blog

Chat with This Blog

Setting up a GraphQL Backend without GraphCool

This article is part of a series on building an MVP of a Data-driven cross-platform app with the following stack: React Native, Apollo GraphQL, and on the backend Node JS with Express and a MySQL Database.

GraphCool is great but it kinda traps you. With this simple guide, I want to argue that it's actually not THAT hard to set up your own backend! And after you scale it, it's muuuuuuuch cheaper!

Please note! This is still a work in progress. It were actually just my own notes, so if something is unclear, just contact me.

In this post, you will read how to do the following:

  1. Start with a basic server setup, GraphQL, Express, Sequelize, SQLite, Dev mode, Git
  2. Explain how I spin it up a 5$ Linode
  3. Explain all domain stuff too? But https is necessary for sure! iOS needs it.
  1. GraphQL Server locally First of all, we are going to make sure we have a GraphQL Server working on localhost
  1. Remote server The second step will be to run it on a remote server somewhere on this planet using Linode (or any other cloud hosting platform).
  1. add name servers of preferred domain pointing to cloudflare (dana&paul.ns.cloudflare.com)
  2. setup CloudFlare DNS
  1. use any static website project but probably the React Bootstrap App theme that I modified, build it, and upload it using “surge ./build/ example.com”

  2. setup a server with Ubuntu 16.04 and Nginx that has this in /etc/nginx/sites-enabled/default

server { listen 80; access_log /var/log/nginx/nginx.vhost.access.log; error_log /var/log/nginx/nginx.vhost.error.log;

location / { proxy_pass http://localhost:3001/graphql; }

}

  1. check for correctness using sudo nginx -t and if it's correct, restart nginx: sudo systemctl restart nginx

  2. Make sure the process indeed runs on this location and port using pm2.

  3. You can now approach your server remotely from anywhere in the world via https://server.yourdomain.com/ . congratz!

3/6/2018
graphqlnodejsdevopsprogrammingsequelizeapollo