Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Full-Stack React, TypeScript, and Node
Full-Stack React, TypeScript, and Node

Full-Stack React, TypeScript, and Node: Build cloud-ready web applications using React 17 with Hooks and GraphQL

Arrow left icon
Profile Icon David Choi
Arrow right icon
Free Trial
Full star icon Full star icon Full star icon Half star icon Empty star icon 3.5 (18 Ratings)
Paperback Dec 2020 648 pages 1st Edition
eBook
S$12.99 S$52.99
Paperback
S$66.99
Subscription
Free Trial
Arrow left icon
Profile Icon David Choi
Arrow right icon
Free Trial
Full star icon Full star icon Full star icon Half star icon Empty star icon 3.5 (18 Ratings)
Paperback Dec 2020 648 pages 1st Edition
eBook
S$12.99 S$52.99
Paperback
S$66.99
Subscription
Free Trial
eBook
S$12.99 S$52.99
Paperback
S$66.99
Subscription
Free Trial

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing
Table of content icon View table of contents Preview book icon Preview Book

Full-Stack React, TypeScript, and Node

Chapter 1: Understanding TypeScript

JavaScript is an enormously popular and powerful language. According to GitHub, it is the most popular language in the world (yes, used even more than Python), and the new features in ES6+ continue to add useful capabilities. However, for large application development, its feature set is considered to be incomplete. This is why TypeScript was created.

In this chapter, we'll learn about the TypeScript language, why it was created, and what value it provides to JavaScript developers. We'll learn about the design philosophy Microsoft used in creating TypeScript and why these design decisions added important support in the language for large application development.

We'll also see how TypeScript enhances and improves upon JavaScript. We'll compare and contrast the JavaScript way of writing code with TypeScript. TypeScript has a wealth of cutting-edge features to benefit developers. Chief among them are static typing and Object-Oriented Programming (OOP) capabilities. These features can make for code that is higher quality and easier to maintain.

By the end of this chapter, you will understand some of the limitations of JavaScript that make it difficult to use in large projects. You will also understand how TypeScript fills in some of those gaps and makes writing large, complex applications easier and less prone to error.

In this chapter, we're going to cover the following main topics:

  • What is TypeScript?
  • Why is TypeScript necessary?

Technical requirements

In order to take full advantage of this chapter, you should have a basic understanding of JavaScript version ES5 or higher and some experience with building web applications with a JavaScript framework. You'll also need to install Node and a JavaScript code editor, such as Visual Studio Code (VSCode).

You can find the GitHub repository for this chapter at https://github.com/PacktPublishing/Full-Stack-React-TypeScript-and-Node. Use the code in the Chap1 folder.

What is TypeScript?

TypeScript is actually two distinct but related technologies – a language and a compiler:

  • The language is a feature-rich, statically typed programming language that adds true object-oriented capabilities to JavaScript.
  • The compiler converts TypeScript code into native JavaScript, but also provides the programmer with assistance in writing code with fewer errors.

TypeScript enables the developer to design software that's of a higher quality. The combination of the language and the compiler enhances the developer's capabilities. By using TypeScript, a developer can write code that is easier to understand and refactor and contains fewer bugs. Additionally, it adds discipline to the development workflow by forcing errors to be fixed while still in development.

TypeScript is a development-time technology. There is no runtime component and no TypeScript code ever runs on any machine. Instead, the TypeScript compiler converts TypeScript into JavaScript and that code is then deployed and run on browsers or servers. It's possible that Microsoft considered developing a runtime for TypeScript. However, unlike the operating system market, Microsoft does not control the ECMAScript standards body (the group that decides what will be in each version of JavaScript). So, getting buy-in from that group would have been difficult and time-consuming. Instead, Microsoft decided to create a tool that enhances a JavaScript developer's productivity and code quality.

So then, if TypeScript has no runtime, how do developers get running code? TypeScript uses a process called transpilation. Transpilation is a method where code from one language is "compiled" or converted into another language. What this means is that all TypeScript code ultimately is converted into JavaScript code before it is finally deployed and run.

In this section, we've learned what TypeScript is and how it works. In the next section, we'll learn about why these features are necessary for building large, complex applications.

Why is TypeScript necessary?

The JavaScript programming language was created by Brendan Eich and was added to the Netscape browser in 1995. Since that time, JavaScript has enjoyed enormous success and is now used to build server and desktop apps as well. However, this popularity and ubiquity have turned out to be a problem as well as a benefit. As larger and larger apps have been created, developers have started to notice the limitations of the language.

Large application development has greater needs than the browser development JavaScript was first created for. At a high level, almost all large application development languages, such as Java, C++, C#, and so on, provide static typing and OOP capabilities. In this section, we'll go over the advantages of static typing over JavaScript's dynamic typing. We'll also learn about OOP and why JavaScript's method of doing OOP is too limited to use for large apps.

But first, we'll need to install a few packages and programs to allow our examples. To do this, follow these instructions:

  1. Let's install Node first. You can download Node from here: https://nodejs.org/. Node gives us npm, which is a JavaScript dependency manager that will allow us to install TypeScript. We'll dive deep into Node in Chapter 8, Learning Server-Side Development with Node.js and Express.
  2. Install VSCode. It is a free code editor and its high-quality and rich features have quickly made it the standard development application for writing JavaScript code on any platform. You can use any code editor you like, but I will use VSCode extensively in this book.
  3. Create a folder in your personal directory called HandsOnTypeScript. We'll save all our project code into this folder.

    Important Note

    If you don't want to type the code yourself, you can download the full source code as mentioned in the Technical requirements section.

  4. Inside HandsOnTypeScript, create another folder called Chap1.
  5. Open VSCode and go to File | Open, and then open the Chap1 folder you just created. Then, select View | Terminal and enable the terminal window within your VSCode window.
  6. Type the following command into the terminal. This command will initialize your project so that it can accept npm package dependencies. You'll need this because TypeScript is downloaded as an npm package:
    npm init

    You should see a screen like this:

    Figure 1.1 – npm init screen

    Figure 1.1 – npm init screen

    You can accept the defaults for all the prompts as we will only install TypeScript for now.

  7. Install TypeScript with the following command:
    npm install typescript

After all the items have been installed, your VSCode screen should look like this:

Figure 1.2 – VSCode after setup is complete

Figure 1.2 – VSCode after setup is complete

We've finished installing and setting up our environment. Now, we can take a look at some examples that will help us better understand the benefits of TypeScript.

Dynamic versus static typing

Every programming language has and makes use of types. A type is simply a set of rules that describe an object and can be reused. JavaScript is a dynamically typed language. In JavaScript, new variables do not need to declare their type and even after they are set, they can be reset to a different type. This feature adds awesome flexibility to the language, but it is also the source of many bugs.

TypeScript uses a better alternative called static typing. Static typing forces the developer to indicate the type of a variable up front, when they create it. This removes ambiguity and eliminates many conversion errors between types. In the following steps, we'll take a look at some examples of the pitfalls of dynamic typing and how TypeScript's static typing can eliminate them:

  1. On the root of the Chap1 folder, let's create a file called string-vs-number.ts. The .ts file extension is a TypeScript specific extension and allows the TypeScript compiler to recognize the file and transpile it into JavaScript. Next, enter the following code into the file and save it:
    let a = 5;
    let b = '6';
    console.log(a + b);
  2. Now, in the terminal, type the following:
    tsc string-vs-number.ts

    tsc is the command to execute the TypeScript compiler, and the filename is telling the compiler to check and transpile the file into JavaScript.

  3. Once you run the tsc command, you should see a new file, string-vs-number.js, in the same folder. Let's run this file:
    node string-vs-number.js

    The node command acts as a runtime environment for the JavaScript file to run. The reason why this works is that Node uses Google's Chrome browser engine, V8, to run JavaScript code. So, once you have run this script, you should see this:

    56

    Obviously, if we add two numbers together normally, we want a sum to happen, not a string concatenation. However, since the JavaScript runtime has no way of knowing this, it guesses the desired intent and converts the a number variable into a string and appends it to variable b. This situation may seem unlikely in real-world code but if left unchecked it could occur, because in web development, most inputs coming in from HTML come in as strings—even if the user types a number.

  4. Now, let's introduce TypeScript's static typing into this code and see what happens. First, let's delete the .js file, as the TypeScript compiler may consider there to be two copies of the a and b variables. Take a look at this code:
    let a: number = 5;
    let b: number = '6';
    console.log(a + b);
  5. If you run the tsc compiler on this code, you will get the error Type "'6'" is not assignable to the type 'number'. This is exactly what we want. The compiler tells us that there is an error in our code and prevents the compilation from successfully compiling. Since we indicated that both variables are supposed to be numbers, the compiler checks for that and complains when it finds it not to be true. So, if we fix this code and set b to be a number, let's see what happens:
    let a: number = 5;
    let b: number = 6;
    console.log(a + b);
  6. Now, if you run the compiler, it will complete successfully, and running the JavaScript will result in the value 11:
Figure 1.3 – Valid numbers addition

Figure 1.3 – Valid numbers addition

Great, when we set b incorrectly, TypeScript caught our error and prevented it from being used at runtime.

Let's look at another more complex example, as it's like what you might see in larger app code:

  1. Let's create a new .ts file called test-age.ts and add the following code to it:
    function canDrive(usr) {    
        console.log("user is", usr.name);     
        
        if(usr.age >= 16) {
            console.log("allow to drive");
        } else {
            console.log("do not allow to drive");
        }
    } 
        
    const tom = { 
        name: "tom"
    } 
    canDrive (tom); 

    As you can see, the code has a function that checks the age of a user and determines, based on that age, whether they are allowed to drive. After the function definition, we see that a user is created, but with no age property. Let's pretend that the developer wanted to fill that in later based on user input. Now, below that user creation, the canDrive function is called and it claims the user is not allowed to drive. If it turned out that user tom was over 16 years old and this function triggered another action to be taken based on the user's age, obviously this could lead to a whole host of issues.

    There are ways in JavaScript to deal with this problem, or at least partially. We could use a for loop to iterate through all of the property key names of the user object and check for an age name. Then, we could throw an exception or have some other error handler to deal with this issue. However, if we had to do this on every function, it would become inefficient and onerous very quickly. Additionally, we would be doing these checks while the code is running. Obviously, for these errors, we would prefer catching them before they make it out to users. TypeScript provides a simple solution to this issue and catches the error before the code even makes it into production. Take a look at the following updated code:

    interface User {
        name: string;
        age: number;
    }
        
    function canDrive(usr: User) {     
        console.log("user is", usr.name);     
        
        if(usr.age >= 16) {
            console.log("allow to drive");
        } else {
            console.log("do not allow to drive");
        }
    } 
            
    const tom = { 
        name: "tom"
    } 
    canDrive (tom); 

    Let's go through this updated code. At the top, we see something called an interface and it is given a name of User. An interface is one possible kind of type in TypeScript. I'll detail interfaces and other types in later chapters, but for now, let's just take a look at this example. The User interface has the two fields that we need: name and age. Now, below that, we see that our canDrive function's usr parameter has a colon and the User type on it. This is called a type annotation and it means that we are telling the compiler only to allow parameters of the User type to be given to canDrive. Therefore, when I try and compile this code with TypeScript, the compiler complains that when canDrive is called, age is missing from the passed-in parameter, because our tom object does not have that property:

    Figure 1.4 – canDrive error

    Figure 1.4 – canDrive error

  2. So, once again, the compiler has caught our error. Let's fix this issue by giving tom a type:
    const tom: User = { 
        name: "tom"
    } 
  3. If we give tom a type of User, but do not add the required age property, we get the following error:
    Property 'age' is missing in type '{ name: string; }' but required in type 'User'.ts(2741)

    However, if we add the missing age property, the error goes away and our canDrive function works as it should. Here's the final working code:

    interface User {
        name: string;
        age: number;
    }
        
    function canDrive(usr: User) {     
        console.log("user is", usr.name);     
        
        if(usr.age >= 16) {
            console.log("allow to drive");
        } else {
            console.log("do not allow to drive");
        }
    } 
        
    // let's pretend sometime later someone else uses the   //function canDrive
    const tom: User = { 
        name: "tom",
        age: 25
    } 
    canDrive (tom); 

    This code provides the required age property in the tom variable so that when canDrive is executed, the check for usr.age is done correctly and the appropriate code is then run.

Here's a screenshot of the output once this fix is made and the code is run again:

Figure 1.5 – canDrive successful result

Figure 1.5 – canDrive successful result

In this section, we learned about some of the pitfalls of dynamic typing and how static typing can help remove and protect against those issues. Static typing removes ambiguity from code, both to the compiler and other developers. This clarity can reduce errors and make for higher-quality code.

Object-oriented programming

JavaScript is known as an OOP language. It does have some of the capabilities of other OOP languages, such as inheritance. However, JavaScript's implementation is limited both in terms of available language features and design. In this section, we'll take a look at how JavaScript does OOP and how TypeScript improves upon JavaScript's capabilities.

First, let's define what OOP is. There are four major principles of OOP:

  • Encapsulation
  • Abstraction
  • Inheritance
  • Polymorphism

Let's review each one.

Encapsulation

A shorter way of saying encapsulation is information hiding. In every program, you will have data and functions that allow you to do something with that data. When we use encapsulation, we are taking that data and putting it into a container of sorts. This container is known as a class in most programming languages and basically, it protects that data so that nothing outside of the container can modify or view it. Instead, if you want to make use of the data, it must be done through functions that are controlled by the container object. This method of working with object data allows strict control of what happens to that data from a single place in code, instead of being dispersed through many locations across a large application—which can be unwieldy and difficult to maintain.

There are some interpretations of encapsulation that focus mainly on the grouping of members inside a common container. However, in the strict sense of encapsulation, information hiding, JavaScript does not have this capability built in. For most OOP languages, encapsulation requires the ability to explicitly hide a member via a language facility. For example, in TypeScript, you can use the private keyword so that a property cannot be seen or modified outside of its class. Now, it is possible in JavaScript to simulate member privacy through various workarounds, but again this is not part of the native code and adds additional complexity. TypeScript supports encapsulation with access modifiers such as private natively.

Important Note

Privacy for class fields will be supported in ECMAScript 2020. However, as this is a newer feature, it is not supported across all browsers at the time of writing.

Abstraction

Abstraction is related to encapsulation. When using abstraction, you hide the internal implementation of how data is managed and provide a more simplified interface to the outside code. Primarily, this is done to cause "loose coupling." This means that it is desirable for code that is responsible for one set of data to be independent and separated from other code. In this way, it is possible to change the code in one part of the application without adversely affecting the code in another part.

Abstraction for most OOP languages requires the use of a mechanism to provide simplified access to an object, without revealing that object's internal workings. For most languages, this is either an interface or an abstract class. We'll review interfaces more deeply in a later chapter, but for now, interfaces are like classes whose members have no actual working code. You can consider them a shell that only reveals the names and types of object members, but hides how they work. This capability is extremely important in producing the "loose coupling" mentioned previously and allowing code to be more easily modified and maintained. JavaScript does not support interfaces or abstract classes, while TypeScript supports both features.

Inheritance

Inheritance is about code reuse. For example, if you needed to create objects for several types of vehicles—car, truck, and boat—it would be inefficient to write distinct code for each vehicle type. It would be better to create a base type that has the core attributes of all vehicles, and then reuse that code in each specific vehicle type. This way, we write some of the needed code only once and share it across each vehicle type.

Both JavaScript and TypeScript support classes and inheritance. If you're not familiar with classes, a class is a kind of type that stores a related set of fields and also may have functions that can act on those fields. JavaScript supports inheritance by using a system called prototypical inheritance. Basically, what this means is that in JavaScript, every object instance of a specific type shares the same instance of a single core object. This core object is the prototype, and whatever fields or functions are created on the prototype, they are accessible across the various object instances. This is a good way of saving resources, such as memory, but it does not have the level of flexibility or sophistication of the inheritance model in TypeScript.

In TypeScript, classes can inherit from other classes but they can also inherit from interfaces and abstract classes. Since JavaScript does not have these features, in comparison, its prototypical inheritance is limited. Additionally, JavaScript has no ability to inherit from multiple classes directly, which is another method of doing code reuse called multiple inheritance. But TypeScript does allow multiple inheritance using mixins. We'll dive deep into all these features later, but basically, the point is that TypeScript has a more capable inheritance model that allows for more kinds of inheritance and therefore more ways to reuse code.

Polymorphism

Polymorphism is related to inheritance. In polymorphism, it is possible to create an object that can be set to one of any number of possible types that inherit from the same base lineage. This capability is useful for scenarios where the type needed is not immediately knowable but can be set at runtime once the appropriate circumstances have arisen.

This feature is used less often in OOP code than some of the other features, but nevertheless can be useful. In the case of JavaScript, there is no direct language support for polymorphism, but due to its dynamic typing, it can be simulated reasonably well (some JavaScript enthusiasts will strongly disagree with this statement, but please hear me out).

Let's look at an example. It is possible to use JavaScript class inheritance to create a base class and have multiple classes that inherit from this one parent base class. Then, by using standard JavaScript variable declaration, which does not indicate the type, we can set the type instance at runtime to whichever inheriting class is appropriate. The issue I find is that there is no way to force the variable to be of a specific base type since there is no way to declare types in JavaScript, therefore there is no way of enforcing only classes that inherit from the one base type during development. So, again, you have to resort to workarounds such as using the instanceof keyword in order to test for certain types at runtime, to try and enforce type safety.

In the case of TypeScript, static typing is on by default and forces type declaration when the variable is first created. Additionally, TypeScript supports interfaces, which can be implemented by classes. Therefore, declaring a variable to be of a specific interface type forces all classes instantiated to that variable to be inheritors of the same interface. Again, this is all done at development time before code is deployed. This system is more explicit, enforceable, and reliable than the one in JavaScript.

In this section, we have learned about OOP and its importance in large application development. We've also understood why TypeScript's OOP capabilities are significantly better and more feature-rich than JavaScript's.

Summary

In this chapter, we introduced TypeScript and learned why it was created. We learned why type safety and OOP capabilities can be so important for building large apps. Then, we saw some examples comparing dynamic typing and static typing and saw why static typing might be a better way of writing code. Finally, we compared the styles of OOP between the two languages and learned why TypeScript has the better and more capable system. The information in this chapter has given us a good high-level conceptual understanding of the benefits of TypeScript.

In the next chapter, we'll do a deeper dive into the TypeScript language. We'll learn more about types and investigate some of the most important features of TypeScript, such as classes, interfaces, and generics. This chapter should give you a strong foundation for using the various frameworks and libraries in the JavaScript ecosystem.

Left arrow icon Right arrow icon
Download code icon Download Code

Key benefits

  • Understand the architecture of React and single-page applications
  • Build a modern Web API for your SPA using Node.js, Express, and GraphQL
  • Gain a clear and practical understanding of how to build a complete full-stack application

Description

React sets the standard for building high-performance client-side web apps. Node.js is a scalable application server that is used in thousands of websites, while GraphQL is becoming the standard way for large websites to provide data and services to their users. Together, these technologies, when reinforced with the capabilities of TypeScript, provide a cutting-edge stack for complete web application development. This book takes a hands-on approach to implementing modern web technologies and the associated methodologies for building full-stack apps. You’ll begin by gaining a strong understanding of TypeScript and how to use it to build high-quality web apps. The chapters that follow delve into client-side development with React using the new Hooks API and Redux. Next, you’ll get to grips with server-side development with Express, including authentication with Redis-based sessions and accessing databases with TypeORM. The book will then show you how to use Apollo GraphQL to build web services for your full-stack app. Later, you’ll learn how to build GraphQL schemas and integrate them with React using Hooks. Finally, you’ll focus on how to deploy your application onto an NGINX server using the AWS cloud. By the end of this book, you’ll be able to build and deploy complete high-performance web applications using React, Node, and GraphQL.

Who is this book for?

The book is for web developers who want to go beyond front-end web development and enter the world of full-stack web development by learning about modern web technologies and how they come together. A good understanding of JavaScript programming is required before getting started with this web development book.

What you will learn

  • Discover TypeScript's most important features and how they can be used to improve code quality and maintainability
  • Understand what React Hooks are and how to build React apps using them
  • Implement state management for your React app using Redux
  • Set up an Express project with TypeScript and GraphQL from scratch
  • Build a fully functional online forum app using React and GraphQL
  • Add authentication to your web app using Redis
  • Save and retrieve data from a Postgres database using TypeORM
  • Configure NGINX on the AWS cloud to deploy and serve your apps

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Dec 18, 2020
Length: 648 pages
Edition : 1st
Language : English
ISBN-13 : 9781839219931
Languages :
Tools :

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing

Product Details

Publication date : Dec 18, 2020
Length: 648 pages
Edition : 1st
Language : English
ISBN-13 : 9781839219931
Languages :
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
$19.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
$199.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just S$6 each
Feature tick icon Exclusive print discounts
$279.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just S$6 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total S$ 202.97
React 17 Design Patterns and Best Practices
S$74.99
Full-Stack React, TypeScript, and Node
S$66.99
Node Cookbook
S$60.99
Total S$ 202.97 Stars icon
Banner background image

Table of Contents

21 Chapters
Section 1:Understanding TypeScript and How It Can Improve Your JavaScript Chevron down icon Chevron up icon
Chapter 1: Understanding TypeScript Chevron down icon Chevron up icon
Chapter 2: Exploring TypeScript Chevron down icon Chevron up icon
Chapter 3: Building Better Apps with ES6+ Features Chevron down icon Chevron up icon
Section 2: Learning Single-Page Application Development Using React Chevron down icon Chevron up icon
Chapter 4: Learning Single-Page Application Concepts and How React Enables Them Chevron down icon Chevron up icon
Chapter 5: React Development with Hooks Chevron down icon Chevron up icon
Chapter 6: Setting Up Our Project Using create-react-app and Testing with Jest Chevron down icon Chevron up icon
Chapter 7: Learning Redux and React Router Chevron down icon Chevron up icon
Section 3: Understanding Web Service Development Using Express and GraphQL Chevron down icon Chevron up icon
Chapter 8: Learning Server-Side Development with Node.js and Express Chevron down icon Chevron up icon
Chapter 9: What is GraphQL? Chevron down icon Chevron up icon
Chapter 10: Setting Up an Express Project with TypeScript and GraphQL Dependencies Chevron down icon Chevron up icon
Chapter 11: What We Will Learn – Online Forum Application Chevron down icon Chevron up icon
Chapter 12: Building the React Client for Our Online Forum Application Chevron down icon Chevron up icon
Chapter 13: Set Up a Session State Using Express and Redis Chevron down icon Chevron up icon
Chapter 14: Setting Up Postgres and a Repository Layer with TypeORM Chevron down icon Chevron up icon
Chapter 15: Adding GraphQL Schema Part I Chevron down icon Chevron up icon
Chapter 16: Adding a GraphQL Schema – Part II Chevron down icon Chevron up icon
Chapter 17: Deploying an Application to AWS Chevron down icon Chevron up icon
Other Books You May Enjoy Chevron down icon Chevron up icon

Customer reviews

Top Reviews
Rating distribution
Full star icon Full star icon Full star icon Half star icon Empty star icon 3.5
(18 Ratings)
5 star 44.4%
4 star 5.6%
3 star 16.7%
2 star 22.2%
1 star 11.1%
Filter icon Filter
Top Reviews

Filter reviews by




Daniel Correa Apr 25, 2021
Full star icon Full star icon Full star icon Full star icon Full star icon 5
If you are a software developer, I always recommend learning a little of back-end and front-end development. Just to know how those things assemble each other. This book provides a great entire insight of this connection, however, this book requires you to have previous knowledge with JavaScript and Node.js.The book starts with an excellent explanation about the issues of JavaScript, and why TypeScript is a proper solution that should be used in the development of large/complex applications. I totally agree with this. Then, the author shows and explains the use of TypeScript and its features, including inheritance, class definition, interfaces, methods, getters and setters, and so on.The book also shows you excellents explanations about some JavaScript elements, including variable declarations, the foundation of asynchronous programming in JavaScript, callbacks, promises, and many more. Which is great, because we will use them a lot in the react application development. You will also learn fundamental elements of React, such as components, hooks, routing, tests, redux, state, and many more.One thing that I really enjoyed was the description of the web evolution. There is a chapter in which the author explains how websites were built in the past, what have changed, and why Single-Page applications - SPA (which are developed through the use of React) are important and trending.In this book, you will find many great short explanations about multiple topics, such as the website evolution (as I mentioned before), versioning, git, workflows, babel, webpack, web sessions, orm, and many more.In the practical side, you will be developing from very simple applications (which in many cases include just one file and its execution), to very complex real world applications. You will design a super forum application which includes categories, threads, users, login, points, and so on. This application is designed from multiple perspectives. You will design the client application with react, then you will develop the backend with node.js and express, and later you will start adding many other features and tools to create a very complex/real word application. Including, (i) redis to manage the session data, (ii) postgres to store the information, (iii) TypeORM an Object Relational Mapper, (iv) Graphql to act as a middleware between the requests from the front-end and the TypeORM extracted data, and also (v) many AWS elements (to deploy the application in the cloud).The book is very complete, however, there are two little details. (i) The first one, is the use of redis. From chapter 13 you will be using redis, redis is an in-memory data store which is used in the book to store the forum application session data. However, redis is only available for mac and linux, so windows users (such as me) have to look for another solution such as the use of virtual machines (to make it work). (ii) Some parts of the book code were a little difficult to follow for me, maybe because I’m totally new with React, and maybe because I’m not a fan of functional programming and other things like arrow functions. I prefer object-oriented programming (which is discussed in a chapter of the book, but it is not a lot used). But I’m sure that people that prefer this type of programming will not have these issues.
Amazon Verified review Amazon
Amazon Customer Sep 11, 2022
Full star icon Full star icon Full star icon Full star icon Full star icon 5
O livro tem uma boa didática, eu estou gostando.
Amazon Verified review Amazon
pfizzle Mar 03, 2021
Full star icon Full star icon Full star icon Full star icon Full star icon 5
book has philosophy of "learning by doing"
Amazon Verified review Amazon
Ziad Malik Jan 19, 2022
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Got this book a week prior to Christmas and having never build an API in my life and giving up on writing React Code since the old class style way just killed me I really hoped to be able to follow along using this book.And - a month and a half later, I am impressed. I now can confidently write Fullstack Code, and more importantly: write good Fullstack Code.I am personally a more fast-paced, hands-on learner so the writing style & speed suited me well. If you like things explained in extreme detail before applying it to the real world, this book is not for you. It explains a concept briefly and applies it immediately, helping me actually visualize what's being said.Even though it is fast-paced, the author does not forget to tell you about best practices, like how to handle State and Context vs Redux, etc. He also tells you about how things were in the past and how they are now, which makes me appreciate the technology and understand its purpose.However, one does feel like the second half of the book is being rushed. I would have loved to learn more about Redis as a database and not just a simple session storage, the hands-on chat app in the end was easy to build, but the explainations are nowhere near as comprehensive as the first half, although various new technologies were introduced, like TypeORM, Postgres, Redis and smaller libraries like bcrypt.jsAnother thing that's not so cools is that a lot of the code was outdated, mostly React Router, and co. But where it got quite annoying is the apollo code. With apollo v3 coming out a lot has changed and it took a good while to refactor. But in the end, I think it's not the authors fault, but I would have loved to see the code updated on Github..All in all, this is the dream book for pragmatic people, written in simple english, and lots of love and passion.9/10 would recommend to a friend!
Amazon Verified review Amazon
Riccardo Jul 28, 2021
Full star icon Full star icon Full star icon Full star icon Full star icon 5
As a professional software developer with react I would say that the book is very good written. The examples are not optimised as production ready but this is not the goal of the book. I really recommend this book if you want to start your journey as full stack engineer.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

What is included in a Packt subscription? Chevron down icon Chevron up icon

A subscription provides you with full access to view all Packt and licnesed content online, this includes exclusive access to Early Access titles. Depending on the tier chosen you can also earn credits and discounts to use for owning content

How can I cancel my subscription? Chevron down icon Chevron up icon

To cancel your subscription with us simply go to the account page - found in the top right of the page or at https://subscription.packtpub.com/my-account/subscription - From here you will see the ‘cancel subscription’ button in the grey box with your subscription information in.

What are credits? Chevron down icon Chevron up icon

Credits can be earned from reading 40 section of any title within the payment cycle - a month starting from the day of subscription payment. You also earn a Credit every month if you subscribe to our annual or 18 month plans. Credits can be used to buy books DRM free, the same way that you would pay for a book. Your credits can be found in the subscription homepage - subscription.packtpub.com - clicking on ‘the my’ library dropdown and selecting ‘credits’.

What happens if an Early Access Course is cancelled? Chevron down icon Chevron up icon

Projects are rarely cancelled, but sometimes it's unavoidable. If an Early Access course is cancelled or excessively delayed, you can exchange your purchase for another course. For further details, please contact us here.

Where can I send feedback about an Early Access title? Chevron down icon Chevron up icon

If you have any feedback about the product you're reading, or Early Access in general, then please fill out a contact form here and we'll make sure the feedback gets to the right team. 

Can I download the code files for Early Access titles? Chevron down icon Chevron up icon

We try to ensure that all books in Early Access have code available to use, download, and fork on GitHub. This helps us be more agile in the development of the book, and helps keep the often changing code base of new versions and new technologies as up to date as possible. Unfortunately, however, there will be rare cases when it is not possible for us to have downloadable code samples available until publication.

When we publish the book, the code files will also be available to download from the Packt website.

How accurate is the publication date? Chevron down icon Chevron up icon

The publication date is as accurate as we can be at any point in the project. Unfortunately, delays can happen. Often those delays are out of our control, such as changes to the technology code base or delays in the tech release. We do our best to give you an accurate estimate of the publication date at any given time, and as more chapters are delivered, the more accurate the delivery date will become.

How will I know when new chapters are ready? Chevron down icon Chevron up icon

We'll let you know every time there has been an update to a course that you've bought in Early Access. You'll get an email to let you know there has been a new chapter, or a change to a previous chapter. The new chapters are automatically added to your account, so you can also check back there any time you're ready and download or read them online.

I am a Packt subscriber, do I get Early Access? Chevron down icon Chevron up icon

Yes, all Early Access content is fully available through your subscription. You will need to have a paid for or active trial subscription in order to access all titles.

How is Early Access delivered? Chevron down icon Chevron up icon

Early Access is currently only available as a PDF or through our online reader. As we make changes or add new chapters, the files in your Packt account will be updated so you can download them again or view them online immediately.

How do I buy Early Access content? Chevron down icon Chevron up icon

Early Access is a way of us getting our content to you quicker, but the method of buying the Early Access course is still the same. Just find the course you want to buy, go through the check-out steps, and you’ll get a confirmation email from us with information and a link to the relevant Early Access courses.

What is Early Access? Chevron down icon Chevron up icon

Keeping up to date with the latest technology is difficult; new versions, new frameworks, new techniques. This feature gives you a head-start to our content, as it's being created. With Early Access you'll receive each chapter as it's written, and get regular updates throughout the product's development, as well as the final course as soon as it's ready.We created Early Access as a means of giving you the information you need, as soon as it's available. As we go through the process of developing a course, 99% of it can be ready but we can't publish until that last 1% falls in to place. Early Access helps to unlock the potential of our content early, to help you start your learning when you need it most. You not only get access to every chapter as it's delivered, edited, and updated, but you'll also get the finalized, DRM-free product to download in any format you want when it's published. As a member of Packt, you'll also be eligible for our exclusive offers, including a free course every day, and discounts on new and popular titles.