4IT580: Docs
4IT580 WebGithub

5th Practical Class:
GraphQL and BackEnd!

Client ↔️ Server communication

Few links

Data flow Client -> server and back

Terms explanation

Note that alternatives listed here are far from being complete list. And some of the technolgoies have different purposes - aka can be used to do same stuff, but are mainly build to do some other stuff.

API

Aplication Programming Interface - application designed to provide data to it's consumers. The data are usually provided wia some data-transfer protocol, HTTP and WebSocket being really common. API application is commonly called server or back-end, it's consumers are commonly called clients or front-end. There are many ways how to build API's, each fitting different purpose. Quite commonly used are REST and GraphQL API patterns.

Node.js

Node.js is out of browser implementation of EcmaScript specification, using Chrome V8 runtime. It can be used for scripting, server implementation, desktop app creation. Visual Studio Code and Atom are both running using Node.js ;) Alternatives would be for example Python, Java, C++.

Express

Express is simple HTTP server running on node.js. It simplifies work with HTTP requests, using middleware approach. In node.js ecosystem alternatives would be Koa, Feathers, Sails. Alternatives ouside of JS ecosystem would be Nginx, Apache, IIS. And bunch of cloud based HTTP services :) Like AWS Elastic Load Balancer, Azure Load Balancer.

GraphQL

GraphQL is query language specification, used to build API on top of your data. Focus of today's lesson :)

Apollo server

One of many JS implementation of GraphQL. Alternatives would be graphql-express or Prisma.

Basics of GraphQL theory

GraphQL properties

Examples:

Entry point to API, Query type specification

Resolver for Query

Specification of type User

Resolver for type User

Note that all resolvers are passed to Apollo server as a single object, see /backend/src/__mocks__/mockResolver.js for full example.

Query example

Data flow inside GraphQL server

How to work with GraphQL server

From Clients perspective

From Servers perspective

Initial set-up (provided by us)

Creating root of GraphQL server

Adding new stuff to schema