4IT580: Docs
4IT580 WebGithub

4th Practical Class:
GraphQL and BackEnd!

Few links

Terms explanation

Note that alternatives listed here are far from being complete list. And some of the technologies 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 ;)

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.

Client ↔️ Server communication

Data flow Client -> server and back

Data flow inside GraphQL server

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

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