Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases now! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
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

eBook
€20.98 €29.99
Paperback
€36.99
Subscription
Free Trial
Renews at €18.99p/m

What do you get with Print?

Product feature icon Instant access to your digital eBook copy whilst your Print order is Shipped
Product feature icon Paperback book shipped to your preferred address
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Product feature icon AI Assistant (beta) to help accelerate your learning
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
Estimated delivery fee Deliver to Slovakia

Premium delivery 7 - 10 business days

€25.95
(Includes tracking information)

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 Print?

Product feature icon Instant access to your digital eBook copy whilst your Print order is Shipped
Product feature icon Paperback book shipped to your preferred address
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Product feature icon AI Assistant (beta) to help accelerate your learning
Estimated delivery fee Deliver to Slovakia

Premium delivery 7 - 10 business days

€25.95
(Includes tracking information)

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
€18.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
€189.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 €5 each
Feature tick icon Exclusive print discounts
€264.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 €5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total 112.97
React 17 Design Patterns and Best Practices
€41.99
Full-Stack React, TypeScript, and Node
€36.99
Node Cookbook
€33.99
Total 112.97 Stars icon

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

Most Recent
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
Most Recent

Filter reviews by




Mark Sep 21, 2023
Full star icon Full star icon Empty star icon Empty star icon Empty star icon 2
It starts off well with simple to follow exercises that cover the basic concepts but by the time you get to the main project the book just becomes a cut and paste exercise between the provided repo code and your editor. Instead of building up files step by step, like the App.css file, all of a sudden you just have to copy the whole thing from the repo because none of the components will layout and present themselves as shown in the book. You end up, then spending a lot of time trying to figure out what changes need to be made that aren't covered in the book at all. Not a great learning experience.
Subscriber review Packt
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
Just Some Guy Sep 05, 2022
Full star icon Full star icon Full star icon Empty star icon Empty star icon 3
This is a decent book. Given how few current React 17 TypeScript books are on the market, my short review is that it's pretty good overall, but not great (it's better for junior devs than for pros). That's the TL;DR review. Read on for more...This is actually 2 different books in one. The first 10 chapters offer an intro and overview of the various tools/techs described on the cover (TypeScript, React 17, Node, etc.). The writing is clear, the example code is simple and clear, and the author, Choi, methodically builds from the basics to more advanced concepts from ch. 1-10.This half of the book is certainly better for beginners than pros (For example, Choi writes a whole chapter on ES6 features that are already widespread to anyone working in React/JS as of 2022). That said, I wouldn't suggest anyone use this book as their 1st intro to any of the tech involved (i.e. learn TS, React, Node, etc. elsewhere first, if you _really_ want to _learn_ them) - because like most "full-stack" books, there's just too much to cover and not enough time to really learn anything in depth. If you already have a sense of these various technologies, but don't know them WELL, this book is perfect for you (pros will find the 1st half slow and basic, though).Unfortunately, the 2nd half of the book is where things start to break down. Chapters 1-10 are a variety of different topics and small one-off example tutorials. After that, chapters 11-17 all focus on building a single full-stack application based on the things you learned in 1-10, plus a slew of new things: Redis, TypeORM/Postgres, Apollo, Nginx.The ambition is respectable, but the book just moves way too fast (without enough depth) and cuts way too many corners to really pull it off. If you're a pro, this half of the book may be just your speed - but beginners will probably end up a bit overwhelmed, if not totally lost.Here are my main complaints:1) My BIGGEST complaint is that in the 2nd half, the majority of the actual _code_ isn't printed in the book. The author takes a lazy shortcut that always drives me crazy (when any book does it) – "Go to the Github repo and copy the code into a new file named SomeComponent.tsx, then make this edit..."While the 1st half included all the example code right in the book (often including unnecessary things like Create-react-app boilerplate, etc.), the 2nd half forces you to clone the repo, then often just describes what's in that code by line number or class name, etc., rather than actually including it in the book. This is just lazy, and I hate it when authors take this shortcut. Boo.2) Throughout the _entire_ book, there's a sloppy layout issue where almost every code sample that _is_ included is off by a slot in the page layout. Let me explain: Over and over again, there'll be a block of example code, then the paragraph _after_ that code describes the code you just read. It's clear this is a mistake by the way it's written (which always refers to the code as if it's coming up next, but you actually just read it). This is just a glaringly horrendous flaw, and the tech editor should be sacked for letting this go to print (all the editors, really). It may seem minor, but it's a constant distraction that adds confusion.Those could both be seen as stylistic nitpicks (pet peeves), and maybe they are. Here are my 3 main complaints about the actual content:3) Throughout the book, but _especially_ in the 2nd half, the actual TypeScript is not what I'd call "best practices" level code. It _is_ TypeScript, but often it turns out to be the lowest level of actual TS necessary to meet that standard. Rather than make extensive use of actual TS features, many times Choi does things that actually bypass the compiler (extensive use of the <any> type is the most obvious example). He generally applies the minimal amount of actual Type logic throughout his code as possible, beyond what React and the other libraries strictly require. Again, I'd advise you read other books to learn TypeScript itself before reading this.4) As a matter of development approach AND teaching approach, I think the order in which he builds his example app is totally backwards in the 2nd half. The app he builds is a simple Chat Forum (think Reddit-lite). It's actually a pretty decent app for a learning project, and his finished product is better than what I've read/built in a lot of other similar books (above complaints notwithstanding). BUT - as far as teaching goes (and the approach to building a real-world app), he starts with the React client, then builds backwards to the API, then the Node app, then finally the data model. And because he uses TypeORM, the data model itself is never even actually well thought out or explained as a core component of the whole project. Yes, he shows you how to implement data object classes via the ORM, but he barely does anything to explain the foundational logic of why those decisions on tables/columns/constraints/etc. were made.Totally missing in this book is any kind of discussion about the domain layer / business logic. He never really explores what the data model looks like (no UML / relationship diagrams, etc.). To _me_ that's just backwards - it's putting the cart before the horse. To build a _real_ app, you should start with the data models and business logic (user stories, behavior-driven, etc.), and build up from there. Building from the React client inwards is like choosing a car's leather seats and dashboard before you build the engine/drivetrain/chassis) . Obviously the UI is important, but if you build a real app this way you're pretty much gonna fail every time. It's just not a good way to teach building an app - which I'd let slide if Choi didn't promise up-front to teach the reader a production-ready way to do things.5) While the final chapter does a better job than many books of walking the reader through getting their app deployed to the cloud (AWS in this case), it's still way too fast, and actually teaches a few bad habits. Worse, he actually has the reader install EVERYTHING (Redis, Postgres, Apollo, Nginx, and Node) all on a SINGLE small Ubuntu VM (using multiple ports, obvi). It's nice that he makes an effort to include a proxy layer, but why bother if you're just gonna do it the most toy-like way possible? He should have _at_least_ offered an overview of deploying a multi-EC2 architecture (if not containers), with some diagrams and links to more architectural resources for further learning.6) One last complaint - while Choi does include a full chapter on testing in the 1st half, he doesn't even write a single test case (or even mention testing) at any point in the 2nd half of the book. This is, again, a lazy oversight and a missed opportunity (TDD, anyone?)....Oh, yeah, and nothing on CI/CD either. Doh.Final word: This actually isn't a bad book - it's decent (as full-stack books go). Given how few React TypeScript books there are on the market (in late 2022), if you need to learn this stuff, I say buy it. I'm just here to tell you where the weakness are, so you won't be disappointed when you run into them. ...Hopefully Choi will clean these all up and do better in the 2nd edition.
Amazon Verified review Amazon
Britton A. Kitchell Jul 13, 2022
Full star icon Full star icon Empty star icon Empty star icon Empty star icon 2
I think I’m done with Packt. This is the third book I’ve tried from them and they are not great.This book does a better job of explaining concepts and diving a little deeper (in contrast to the half-baked paint by numbers approach used in their “React Projects” book). But it is hard to follow a lot of the time.The code snippets do not have a +/- or holding system to indicate what’s being added/removed. Also, pieces are just missing (other books use … or something to indicate abbreviated areas), so it’s hard to tell if you should be deleting code, or where to put it.I also have issues with the pedagogy. The author will explain a concept and have you write code, only to say, don’t do it that way. Like let’s create some class components, okay now don’t use those, refactor to use functional components with hooks, okay now don’t use some of those hooks, refactor to use Redux. I can’t remember the entire history of React. Just teach us the right/current way. I’m never going to remember all of that and it’s confusing + a waste of time.
Amazon Verified review Amazon
AMol SOlanki Mar 04, 2022
Full star icon Full star icon Full star icon Full star icon Empty star icon 4
To understand the entire book, you must first be familiar with JavaScript. If you're new to js, make sure you understand the fundamentals. This is an excellent book for web developers who want to get started with backend technology. Choi does a better job of defining type script. How to create a single-page application with react. Section three explains web development using express and graphql in the simplest way possible for web developers
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 the delivery time and cost of print book? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela
What is custom duty/charge? Chevron down icon Chevron up icon

Customs duty are charges levied on goods when they cross international borders. It is a tax that is imposed on imported goods. These duties are charged by special authorities and bodies created by local governments and are meant to protect local industries, economies, and businesses.

Do I have to pay customs charges for the print book order? Chevron down icon Chevron up icon

The orders shipped to the countries that are listed under EU27 will not bear custom charges. They are paid by Packt as part of the order.

List of EU27 countries: www.gov.uk/eu-eea:

A custom duty or localized taxes may be applicable on the shipment and would be charged by the recipient country outside of the EU27 which should be paid by the customer and these duties are not included in the shipping charges been charged on the order.

How do I know my custom duty charges? Chevron down icon Chevron up icon

The amount of duty payable varies greatly depending on the imported goods, the country of origin and several other factors like the total invoice amount or dimensions like weight, and other such criteria applicable in your country.

For example:

  • If you live in Mexico, and the declared value of your ordered items is over $ 50, for you to receive a package, you will have to pay additional import tax of 19% which will be $ 9.50 to the courier service.
  • Whereas if you live in Turkey, and the declared value of your ordered items is over € 22, for you to receive a package, you will have to pay additional import tax of 18% which will be € 3.96 to the courier service.
How can I cancel my order? Chevron down icon Chevron up icon

Cancellation Policy for Published Printed Books:

You can cancel any order within 1 hour of placing the order. Simply contact customercare@packt.com with your order details or payment transaction id. If your order has already started the shipment process, we will do our best to stop it. However, if it is already on the way to you then when you receive it, you can contact us at customercare@packt.com using the returns and refund process.

Please understand that Packt Publishing cannot provide refunds or cancel any order except for the cases described in our Return Policy (i.e. Packt Publishing agrees to replace your printed book because it arrives damaged or material defect in book), Packt Publishing will not accept returns.

What is your returns and refunds policy? Chevron down icon Chevron up icon

Return Policy:

We want you to be happy with your purchase from Packtpub.com. We will not hassle you with returning print books to us. If the print book you receive from us is incorrect, damaged, doesn't work or is unacceptably late, please contact Customer Relations Team on customercare@packt.com with the order number and issue details as explained below:

  1. If you ordered (eBook, Video or Print Book) incorrectly or accidentally, please contact Customer Relations Team on customercare@packt.com within one hour of placing the order and we will replace/refund you the item cost.
  2. Sadly, if your eBook or Video file is faulty or a fault occurs during the eBook or Video being made available to you, i.e. during download then you should contact Customer Relations Team within 14 days of purchase on customercare@packt.com who will be able to resolve this issue for you.
  3. You will have a choice of replacement or refund of the problem items.(damaged, defective or incorrect)
  4. Once Customer Care Team confirms that you will be refunded, you should receive the refund within 10 to 12 working days.
  5. If you are only requesting a refund of one book from a multiple order, then we will refund you the appropriate single item.
  6. Where the items were shipped under a free shipping offer, there will be no shipping costs to refund.

On the off chance your printed book arrives damaged, with book material defect, contact our Customer Relation Team on customercare@packt.com within 14 days of receipt of the book with appropriate evidence of damage and we will work with you to secure a replacement copy, if necessary. Please note that each printed book you order from us is individually made by Packt's professional book-printing partner which is on a print-on-demand basis.

What tax is charged? Chevron down icon Chevron up icon

Currently, no tax is charged on the purchase of any print book (subject to change based on the laws and regulations). A localized VAT fee is charged only to our European and UK customers on eBooks, Video and subscriptions that they buy. GST is charged to Indian customers for eBooks and video purchases.

What payment methods can I use? Chevron down icon Chevron up icon

You can pay with the following card types:

  1. Visa Debit
  2. Visa Credit
  3. MasterCard
  4. PayPal
What is the delivery time and cost of print books? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela