官术网_书友最值得收藏!

The basic setup

The basic setup to make an application work is the logical request flow, which looks as follows:

Here's how the logical request flow works:

  1. The client requests our site.
  2. The Express.js server handles these requests and serves a static HTML file.
  3. The client downloads all necessary files, according to this HTML file. The files also include a bundled JavaScript file.
  1. This bundled JavaScript file is our React application. After executing all JavaScript code from this file, all required Ajax alias GraphQL requests are made to our Apollo Server.
  2. Express.js receives the requests and passes them to our Apollo endpoint.
  3. Apollo queries all requested data from all available systems, such as our SQL server or third-party services, merges the data, and sends it back as JSON.
  4. React can render the JSON data to HTML.

This workflow is the basic setup to make an application work. In some cases, it makes sense to offer server-side rendering for our client. The server would need to render and send all XMLHttpRequests itself before returning the HTML to the client. The user will save one or more round trips if the server sends the requests on the initial loadWe will focus on this topic in a later chapter, but that's the application architecture in a nutshell. With that in mind, let's get hands-on and set up our development environment.

主站蜘蛛池模板: 霸州市| 东港市| 仲巴县| 顺平县| 原平市| 富宁县| 进贤县| 榆林市| 山丹县| 德阳市| 潜山县| 新平| 普定县| 大庆市| 清镇市| 武邑县| 全州县| 上虞市| 孝感市| 广丰县| 正安县| 宣威市| 墨玉县| 黑龙江省| 团风县| 望江县| 十堰市| 法库县| 青岛市| 新余市| 漯河市| 景德镇市| 新密市| 封开县| 阿克陶县| 曲阳县| 增城市| 右玉县| 环江| 临夏县| 湘阴县|