HTTP is a format for sending messages over the internet. It is used on top of two other message formats—IP (which has an IP address and routes the message to the right machine) and TCP (which has a port number and resends any messages that are lost in transit). An HTTP message adds a method (like GET or POST), a path (like /graphql), headers (like the Bearer header we use for authentication), and a body (where GraphQL queries and responses go).
When we enter a URL, like http://graphql.guide/, into our browser, it goes through these steps:
We can see for ourselves what the DNS server says using the nslookup command:
$ nslookup graphql.guide
IP to 188.8.131.52
TCP to port 80
HTTP GET /
Internet routers look at the IP part, see it is addressed to 184.108.40.206, and pass it off to a router that is closer to 220.127.116.11.
The message arrives at 18.104.22.168 (the IP address of the Guide server), which opens the message, sees that it’s trying to connect to port 80, and passes the message to whatever server program (in this case, a Node.js process) is listening at the port.
An IP address is the number ID of a computer on the internet, and we can think of a port as the number of a program running on that computer.
This sequence is a little simplified—it actually takes a separate round-trip message to set up the TCP connection, and for graphql.guide, the client is actually redirected to HTTPS at the beginning, which uses port 443 and sets up an SSL connection before sending HTTP GET /.