<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Tran Minh Tri</title>
    <description>The latest articles on DEV Community by Tran Minh Tri (@tris909).</description>
    <link>https://dev.to/tris909</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F450164%2Fc60efba7-c938-476c-a054-5a00d2bc5bca.jpg</url>
      <title>DEV Community: Tran Minh Tri</title>
      <link>https://dev.to/tris909</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/tris909"/>
    <language>en</language>
    <item>
      <title>QuickStart example on how to build CI/CD using CircleCI for monorepo</title>
      <dc:creator>Tran Minh Tri</dc:creator>
      <pubDate>Sun, 07 Jan 2024 08:23:32 +0000</pubDate>
      <link>https://dev.to/tris909/quickstart-example-on-how-to-build-cicd-using-circleci-for-monorepo-57he</link>
      <guid>https://dev.to/tris909/quickstart-example-on-how-to-build-cicd-using-circleci-for-monorepo-57he</guid>
      <description>&lt;p&gt;Hello friends 😄, this is a quick-start example of how to build CI/CD pipelines using CircleCI and Monorepo. This guide will give you an example right out of the box so you can copy it and change it to fit your needs.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;By all means, please don't treat this as a guide but as an example. Me/myself has to struggle a lot to set up this to work with CircleCI with Monorepobut it is not perfect and I'm not an expert on this topic.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;Initial Problem:&lt;/strong&gt;&lt;/em&gt; Build pipelines for a project inside a Monorepo.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;What you can get from this quickstart guide:&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;How to set up CircleCI for Monorepo&lt;/li&gt;
&lt;li&gt;Full examples by code on how to set up them line by line&lt;/li&gt;
&lt;li&gt;How to trigger a job manually with CircleCI&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;Context:&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;This is what my folder structure looks like for Monorepo&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--gzcg0Otg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mko5uevwu9g9jn7749pz.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--gzcg0Otg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mko5uevwu9g9jn7749pz.PNG" alt="Image description" width="493" height="746"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is a CircleCI example of how to set up pipelines for a BackEnd project inside a Monorepo that requires 4 different stages including &lt;code&gt;build&lt;/code&gt; / &lt;code&gt;test&lt;/code&gt; / &lt;code&gt;deploy_to_dev_env&lt;/code&gt; / &lt;code&gt;deploy_to_prod_env&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Enough chitchat. Let's get to the code&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;Codes:&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;At the &lt;code&gt;root level&lt;/code&gt; of Monorepo, you need to have folder &lt;code&gt;.circleci/config.yml&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;version: 2.1

setup: true

orbs:
  path-filtering: circleci/path-filtering@1.0.0

workflows:
  Setup:
    jobs:
      - path-filtering/filter:
          base-revision: master
          config-path: ./BackEnd/config.yml
          mapping: |
            BackEnd/.* run-backend-jobs true
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Inside &lt;code&gt;BackEnd&lt;/code&gt; project ( one of the project of Monorepo that you want to setup pipelines ), we have &lt;code&gt;config.yml&lt;/code&gt; at the root level of &lt;code&gt;BackEnd&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;version: 2.1

orbs:
  node: circleci/node@5.2.0

parameters:
  run-backend-jobs:
    type: boolean
    default: false

jobs:
  BE_build:
    executor:
      name: node/default
      tag: "18.16"
    steps:
      - checkout
      - run:
          command: |
            cd BackEnd
            node --version
            npm install
            npm run build
  BE_unit_test:
    executor:
      name: node/default
    steps:
      - checkout
      - run:
          command: |
            cd BackEnd
            node --version
            npm install
            npm run build
            npm run test:ci
  BE_deploy_dev:
    machine:
      image: ubuntu-2004:current
    resource_class: medium
    environment:
      ENV: dev
    steps:
      - run:
          name: Deploy Introspection's BackEnd to Dev Environment
          command: |
            response=$(curl -s -w "%{http_code}" -o response.txt $DEPLOY_DEV_URI)
            response_code=${response:(-3)}
            if [ $response_code -eq 200 ]; then
              echo "Deployment to dev env successful!"
              cat response.txt  # Print the response body
            else
              echo "Deployment to dev env failed with response code: $response_code"
              cat response.txt  # Print the response body
              exit 1
            fi
  BE_deploy_prod:
    machine:
      image: ubuntu-2004:current
    resource_class: medium
    environment:
      ENV: prod
    steps:
      - run:
          name: Deploy Introspection's BackEnd to PROD Environment
          command: |
            response=$(curl -s -w "%{http_code}" -o response.txt $DEPLOY_PROD_URI)
            response_code=${response:(-3)}
            if [ $response_code -eq 200 ]; then
              echo "Deployment to production successful!"
              cat response.txt  # Print the response body
            else
              echo "Deployment to production failed with response code: $response_code"
              cat response.txt  # Print the response body
              exit 1
            fi

workflows:
  BackEnd:
    when: &amp;lt;&amp;lt; pipeline.parameters.run-backend-jobs &amp;gt;&amp;gt;
    jobs:
      - BE_build
      - BE_unit_test:
          requires:
            - BE_build
      - request_manual_approve_before_deploy_to_dev:
          type: approval
          requires:
            - BE_build
            - BE_unit_test
      - BE_deploy_dev:
          requires:
            - request_manual_approve_before_deploy_to_dev
          filters:
            branches:
              only: master
      - request_manual_approve_before_deploy_to_prod:
          type: approval
          requires:
            - BE_deploy_dev
      - BE_deploy_prod:
          requires:
            - request_manual_approve_before_deploy_to_prod
          filters:
            branches:
              only: master

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now for this example above, many things won't fit your need like the fact that I'm using &lt;code&gt;Render&lt;/code&gt; as the deployment service, and the jobs that I have for my BackEnd &lt;code&gt;workflows&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;What you really need to keep in mind is whatever is under &lt;code&gt;command: |&lt;/code&gt; is the script that you can run locally to deploy your project so you just need to figure that block out yourself and insert that block into there to make it work for you.&lt;/p&gt;

&lt;p&gt;There is also a quick example of how to manually approve a job on CircleCI to make it run like the example below ( This block of code below is inside &lt;code&gt;workflows&lt;/code&gt; of the block of code above ):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;      - request_manual_approve_before_deploy_to_dev:
          type: approval
          requires:
            - BE_build
            - BE_unit_test
      - BE_deploy_dev:
          requires:
            - request_manual_approve_before_deploy_to_dev
          filters:
            branches:
              only: master
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With all of that, hopefully, you have something like this in your &lt;code&gt;CircleCI&lt;/code&gt; as well :&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--uP1nKsnw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/d4xip4gb4snbfr0p6n3e.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--uP1nKsnw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/d4xip4gb4snbfr0p6n3e.PNG" alt="Image description" width="800" height="230"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Now this is far from perfect but you can even work on circle.ci/config.yml in the root config to work out what changes happen on what project inside Monorepo to trigger that project pipelines only. I haven't actually figured it out yet but if do please feel free to even comment on the solution below for everyone to check it out.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I hope this post helps you on your journey to test out CircleCI and start building pipelines for your own projects. A full-on example can be viewed here line by line through &lt;a href="https://github.com/Tris-909/Introspection"&gt;https://github.com/Tris-909/Introspection&lt;/a&gt; &lt;/p&gt;

</description>
      <category>circleci</category>
      <category>node</category>
      <category>monorepo</category>
    </item>
    <item>
      <title>Go course reviewer</title>
      <dc:creator>Tran Minh Tri</dc:creator>
      <pubDate>Mon, 28 Aug 2023 14:28:58 +0000</pubDate>
      <link>https://dev.to/tris909/go-course-reviewer-18m5</link>
      <guid>https://dev.to/tris909/go-course-reviewer-18m5</guid>
      <description>&lt;p&gt;So I spent my last week learning Go as a new backend language that I can use to build out awesome backend. &lt;/p&gt;

&lt;p&gt;Go is famous for powerful performance and claimed to be easy to learn. &lt;/p&gt;

&lt;p&gt;Knowing what I know, It's best for me to find a reliable source to first start learning Go so I choose &lt;strong&gt;Go: The Complete Developer's Guide (Golang)&lt;/strong&gt; from &lt;strong&gt;Stephen Grider&lt;/strong&gt; on Udemy.&lt;/p&gt;

&lt;p&gt;This is absolutely not a paid promotion or anything, I bought the course with dirt cheap price on Udemy and gets quite good knowledges about Go languages from it, so I would definitely recommend it. &lt;/p&gt;

&lt;p&gt;For summary it can teach you about : &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Many basics like : Variables in Go, Functions, How to write a Go file and run it, how to "import" Go files code to use in another Go file code.&lt;/li&gt;
&lt;li&gt;Many data type and how to use them like : primitive types, array or slices, interfaces, struct, maps&lt;/li&gt;
&lt;li&gt;Many important Go features like : Pointer, Receiver Function, Reference types and Value types, Routine and Channel&lt;/li&gt;
&lt;li&gt;How to write test files in Go&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This course won't teach you how to build a fully functional app with Golang backend but it give you a very solid knowledge about what Golang is and how it works. &lt;/p&gt;

&lt;p&gt;After you learn the code, you can try this link &lt;a href="https://www.freecodecamp.org/news/best-resources-to-learn-golang-for-free/"&gt;https://www.freecodecamp.org/news/best-resources-to-learn-golang-for-free/&lt;/a&gt; to actually build out backend using Golang. &lt;/p&gt;

&lt;p&gt;I also have written a few notes about Go here &lt;a href="https://github.com/Tris-909/KnowledgeStores/blob/master/Golang/Golang.md"&gt;https://github.com/Tris-909/KnowledgeStores/blob/master/Golang/Golang.md&lt;/a&gt;, I would absolutely love it if anyone who reads this can go through the course and make some pull requests directly to that MD files to correct me on some points if it feels wrong.&lt;/p&gt;

&lt;p&gt;Well that it is for Golang, wish you all the best on your learning journey.&lt;/p&gt;

&lt;p&gt;Hope anyone can provide me some goods Golang learning materials.&lt;/p&gt;

</description>
      <category>go</category>
      <category>course</category>
    </item>
    <item>
      <title>I created my own email server to send emails into my gmail for My Portfolio</title>
      <dc:creator>Tran Minh Tri</dc:creator>
      <pubDate>Sun, 28 Nov 2021 02:45:23 +0000</pubDate>
      <link>https://dev.to/tris909/i-created-my-own-email-server-to-send-emails-into-my-gmail-for-my-portfolio-29l2</link>
      <guid>https://dev.to/tris909/i-created-my-own-email-server-to-send-emails-into-my-gmail-for-my-portfolio-29l2</guid>
      <description>&lt;p&gt;I have my portfolio here at &lt;a href="https://tranminhtri.com/" rel="noopener noreferrer"&gt;My Portfolio&lt;/a&gt;. Date after date, there are peoples send message to me through the contact form.&lt;/p&gt;

&lt;p&gt;Initially, I used emailJS to handle sending mails to my gmail for a peace of mind. But their free tier is quite low, only allow 200 requests per months. So I decided to create my own server to send mails to mine gmail so I can have better flexibility and control over it.&lt;/p&gt;

&lt;p&gt;This is also a guide on how to use nodemailer to send mail to gmail. There are many things need to sort out before you can use nodemailer to make it works well with gmail. I hope this guide can help you ( and also help myself in the future if I need it 😉 ).&lt;/p&gt;

&lt;h1&gt;
  
  
  1/ Install Packages and set up basic express App
&lt;/h1&gt;

&lt;p&gt;You need to do a &lt;code&gt;npm init&lt;/code&gt; first then just go along with default configuration&lt;/p&gt;

&lt;p&gt;We need a few packages to make sure our server works :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install express nodemailer nodemailer-smtp-transport dotenv cors
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install --save-dev nodemon
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Your package.json should look like this now :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "name": "my-portfolio-server",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "start": "nodemon ./index.js",
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "cors": "^2.8.5",
    "dotenv": "^10.0.0",
    "express": "^4.17.1",
    "nodemailer": "^6.7.2",
    "nodemailer-smtp-transport": "^2.7.4"
  },
  "devDependencies": {
    "nodemon": "^2.0.15"
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I will explain why we need each of them : &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;cors : to resolve CORS when you send a request from your website to this server&lt;/li&gt;
&lt;li&gt;dotenv : to use environment variables in your server&lt;/li&gt;
&lt;li&gt;express : to set up an Express app&lt;/li&gt;
&lt;li&gt;nodemailer and nodemailer-smtp-transport : to send mails to gmail&lt;/li&gt;
&lt;li&gt;nodemon : to test your local server app live&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  2/ Set up local config :
&lt;/h1&gt;

&lt;p&gt;Now you need to create a &lt;code&gt;.env&lt;/code&gt; file and &lt;code&gt;.gitignore&lt;/code&gt; file.&lt;/p&gt;

&lt;p&gt;We will get to &lt;code&gt;git&lt;/code&gt; first. You may need to do a &lt;code&gt;git init&lt;/code&gt; then push your current project on an existing branch ( in my case it's Github ) We will need that so later you can deploy it to Heroku ( I used Heroku but if you don't feel free to skip the deployment step and do it on yourown )&lt;/p&gt;

&lt;p&gt;In your &lt;code&gt;.env&lt;/code&gt; file, make sure they have these :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;MY_GMAIL={Your Gmail here}
MY_GMAIL_PASSWORD={Your Gmail Password}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then in your &lt;code&gt;.gitignore&lt;/code&gt;, also make sure they look like this :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.env
node_modules/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You don't want to push your credentials to Github to the public. So that's why we need &lt;code&gt;.gitignore&lt;/code&gt; and also we need credentials of your own gmail so we can use it later to send mails using nodemailer.&lt;/p&gt;

&lt;h1&gt;
  
  
  3/ Set up your gmail account to make sure nodemailer works :
&lt;/h1&gt;

&lt;p&gt;Log into your Gmail Account then click on this&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ft0yollvwzub0yd9thgvh.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ft0yollvwzub0yd9thgvh.PNG" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You need to enable &lt;code&gt;less secure app access&lt;/code&gt; and &lt;code&gt;display unlock captcha&lt;/code&gt; for your gmail account &lt;a href="https://accounts.google.com/b/0/DisplayUnlockCaptcha" rel="noopener noreferrer"&gt;https://accounts.google.com/b/0/DisplayUnlockCaptcha&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Then you have to follow this 6 steps at &lt;a href="https://support.google.com/accounts/answer/185833?hl=en" rel="noopener noreferrer"&gt;https://support.google.com/accounts/answer/185833?hl=en&lt;/a&gt; to get the password that you can put it in &lt;code&gt;.env&lt;/code&gt; file or this won't work&lt;/p&gt;

&lt;p&gt;I know it's a lengthy process. But trust me, I have to go through my StackOverflow issues and answers to leave them here for you so you can have a peace of mind. Nodemailer doesn't work well with Gmail but once you have set them up, you are good to go for life.&lt;/p&gt;

&lt;p&gt;Now you have set up both your gmail config and local config. We can start writting our server.&lt;/p&gt;

&lt;h1&gt;
  
  
  4/ Build out your server
&lt;/h1&gt;

&lt;p&gt;I just gonna throw them here just because they only have a file and one endpoint.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const express = require('express')
const nodemailer = require('nodemailer');
const smtpTransport = require('nodemailer-smtp-transport');
const cors = require('cors');

// This makes .env file work
require('dotenv').config();

// Env Variables
// You may not see 'PORT' mentioned in .env file above because this is used for HEROKU deployment only
const PORT = process.env.PORT;
const MY_GMAIL = process.env.MY_GMAIL;
const MY_GMAIL_PASSWORD = process.env.MY_GMAIL_PASSWORD;

const app = express()
const port =  PORT || 5000;

// You need this so when you send a request from frontend with a different url like https://tranminhtri.com it won't throw CORS errors
app.use(cors());

// You can choose different endpoint like /email, /mail or anything
app.post('/sendMessage', (req, res) =&amp;gt; {
    // I used `name`, `email`, `message` for my Form so I extract them here, feel free to expand them as you need
    const { name, email, message } = req.query;

    const transporter = nodemailer.createTransport(smtpTransport({
        service: 'gmail',
        host: 'smtp.gmail.com',
        auth: {
          user: MY_GMAIL,
          pass: MY_GMAIL_PASSWORD
        }
    }));

    const mailOptions = {
        from: email,
        to: MY_GMAIL,
        subject: `A Message from ${email} (My Portfolio)`,
        text: `
        Email: ${email}

        Name: ${name}

        Message: ${message}
        `
    };
      transporter.sendMail(mailOptions, (error, info) =&amp;gt; {
        if (error) {
          console.log(error);
        } else {
          console.log('Email sent: ' + info.response);
        }
      });

    res.status(200).send('Send email successfully');
});

app.listen(port, () =&amp;gt; {
  console.log(`Example app listening at ${port}`)
})
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The file need to be named &lt;code&gt;index.js&lt;/code&gt; just for deployment later on, as mentioned in package.json it's &lt;code&gt;nodemon ./index.js&lt;/code&gt; as well.&lt;/p&gt;

&lt;p&gt;Your file structure should look like this :&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frsqg23bhonqw14xc5ywi.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frsqg23bhonqw14xc5ywi.PNG" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The idea behind this is simple, built and endpoint that will take whatever data coming from the frontend and pass them into nodemailer so they will be directed to your gmail. &lt;/p&gt;

&lt;p&gt;The whole part from &lt;code&gt;transporter&lt;/code&gt;, &lt;code&gt;mailOptions&lt;/code&gt; and &lt;code&gt;transporter.sendMail&lt;/code&gt; is just syntax so if you want to know more feel free to visit &lt;a href="https://nodemailer.com/usage/" rel="noopener noreferrer"&gt;https://nodemailer.com/usage/&lt;/a&gt; and &lt;a href="https://nodemailer.com/message/" rel="noopener noreferrer"&gt;https://nodemailer.com/message/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The Source code for the whole server is here if you need to compare code line by line : &lt;a href="https://github.com/Tris-909/My-Portfolio-Server" rel="noopener noreferrer"&gt;https://github.com/Tris-909/My-Portfolio-Server&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  5/ Local test :
&lt;/h1&gt;

&lt;p&gt;You can run&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm start
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;to start your local development &lt;/p&gt;

&lt;p&gt;If you hit the endpoint with a post request like a screen shoot below, it should send a mail to your gmail account : &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fog4a4lwi4t216jzfmhaa.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fog4a4lwi4t216jzfmhaa.PNG" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now everything is working fine locally. You can deploy it then integrate it with your websites.&lt;/p&gt;

&lt;h1&gt;
  
  
  6/ Deployment Heroku ( Optional ) :
&lt;/h1&gt;

&lt;p&gt;Different platform have different ways to deploy an app or a server. I used Heroku because it's quick and easy and generous for it free tier. But if you are using a different platform I can't really help you, you have to figure it out on your own.&lt;/p&gt;

&lt;p&gt;There are gonna be a few steps through this, and this is quite prone to error so I hope you can stick with it ( Deployment always be a pain 🙂 )&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Step 1 : Create your own heroku account if you haven't gotten one yet&lt;/li&gt;
&lt;li&gt;Step 2 : Run &lt;code&gt;node -v&lt;/code&gt; to get the version of your current nodejs env then add these to your package.json :
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  "engines": {
    "node": "16.13.0"
  }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Mine is 16.13.0 so I put it there&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Step 3 : Alter your &lt;code&gt;scripts&lt;/code&gt; inside package.json to make heroku works :
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  "scripts": {
    "start": "node ./index.js",
    "dev": "nodemon ./index.js"
  },
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Heroku runs &lt;code&gt;npm start&lt;/code&gt; behind the screen for deployment so you need to move your development script into something else like above.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Step 4 : Install Heroku CLI and create your app through command line, You need to follow this &lt;a href="https://devcenter.heroku.com/articles/heroku-cli" rel="noopener noreferrer"&gt;https://devcenter.heroku.com/articles/heroku-cli&lt;/a&gt; until step &lt;strong&gt;Getting Started&lt;/strong&gt; to create your app on heroku&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now if you go to heroku dashboard, you will see your app like this, mine is &lt;code&gt;obscure-brook-87266&lt;/code&gt; &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frl8avnxmbp1hjtv72x0k.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frl8avnxmbp1hjtv72x0k.PNG" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now click on the project, and go to &lt;code&gt;Deploy&lt;/code&gt; tab, then connect your app to your Github Account ( This is why I need you to commit and push it to Github at the start ) before you go to click &lt;code&gt;deploy&lt;/code&gt;, go to &lt;code&gt;Settings&lt;/code&gt; tab and click on &lt;code&gt;Reveal Config Vars&lt;/code&gt;, you need to add env variables under the same name as your &lt;code&gt;.env&lt;/code&gt; file.&lt;/p&gt;

&lt;p&gt;After that you can go to &lt;code&gt;Deploy&lt;/code&gt; and click on &lt;code&gt;Manual Deploy&lt;/code&gt; to wait for your app to deploy. And then that's it. You are done.&lt;/p&gt;

&lt;p&gt;Try to use POSTMAN again to test it out but replace your URL with the new URL provided by Heroku.&lt;/p&gt;

&lt;p&gt;If you follow the whole guide till now everything should work as expected. It's not a smooth process for me I have to read a lot of StackOverflow issues and answers to figure it all out but I hope this will help you in some ways. &lt;/p&gt;

&lt;p&gt;Good bye and have a good day 😙&lt;/p&gt;

</description>
      <category>nodemailer</category>
      <category>express</category>
      <category>cors</category>
      <category>gmail</category>
    </item>
    <item>
      <title>Before I land a job as a developer, mistakes that I've made by learning how to code by myself</title>
      <dc:creator>Tran Minh Tri</dc:creator>
      <pubDate>Sun, 29 Aug 2021 03:33:18 +0000</pubDate>
      <link>https://dev.to/tris909/before-i-land-a-job-as-a-developer-mistakes-that-i-ve-made-by-learning-how-to-code-by-myself-j2k</link>
      <guid>https://dev.to/tris909/before-i-land-a-job-as-a-developer-mistakes-that-i-ve-made-by-learning-how-to-code-by-myself-j2k</guid>
      <description>&lt;p&gt;Before become a full stack developer by learning how to code as a self-taught developer for a year. &lt;/p&gt;

&lt;p&gt;I've made many mistakes that now when I look back, I wish I didn't do it. These mistakes costed me my time, mental health and possibly money ( it's a small amount to me but I know there are peoples spent way more than I am ). &lt;/p&gt;

&lt;p&gt;These mistakes could possibly block you from become a developer or make you suffer a lot before you can land your first job. &lt;/p&gt;

&lt;p&gt;All the things below I about to say is my personal opinion, feel free to skip it but if you can find a small value in this blog, then cheer mate.&lt;/p&gt;

&lt;h2&gt;
  
  
  First mistake : Learning way too much without focusing on your goals and the reason why
&lt;/h2&gt;

&lt;p&gt;When I'm 20. After a few months of learning how to code. I went to apply a few positions, not really a 'few' but many positions that I think I can apply to earn some experience. &lt;/p&gt;

&lt;p&gt;Now that's all good. The problem is there are too many skills and I'm being too greedy about this. &lt;/p&gt;

&lt;p&gt;I remembered I've learned PHP and React-Native before but now the only skill I actually learn and use from day to day is React. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpx3i5413ohm4qxct4qms.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpx3i5413ohm4qxct4qms.jpg" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You may wonder, what's so bad about that ? &lt;/p&gt;

&lt;p&gt;The problem is by greed for every dev jobs out there, I'm not focusing on any particular skill. I didn't build out any big and complicated project using that specific language or framework. I'm half-good at everything and because I'm half-good. &lt;/p&gt;

&lt;p&gt;The reality that I'm no good. No real strong point and no real focus.&lt;/p&gt;

&lt;p&gt;You know the type of person who knows everything but in fact they only know the surface and that's no where match to the level you need to work in real world.&lt;/p&gt;

&lt;p&gt;Looking back what I should have done is start by researching about the job market to understand what skill is the most important one for me to land a job as a developer then build out many projects using that one.&lt;/p&gt;

&lt;p&gt;Now I know there are peoples reading to this point a be like : "What the hell is this guy is talking about ? Should developer always learn new things as their jobs ? Does this means that you can't apply to any jobs you don't qualify 100% for ?" &lt;/p&gt;

&lt;p&gt;If you are thinking like this, you are totally missing the point. The fact that a developer has like 80-90% skill requirements for the job and learn the rest when they are on site is totally different from a guy who are no good and has his skills somewhere at 40-50% thinking that he will be able to win the job over all other 20-30 peoples applying to the same job. &lt;/p&gt;

&lt;p&gt;If you apply directly without any helps from your friends, colleges, or even family. Understand that your skills must be at the top and you should have a strong point to sell. Jack of all trades is a joke and most of the times you are being way too confident about knowing anything rather than actually know it and use it professionally. &lt;/p&gt;

&lt;h2&gt;
  
  
  Second mistake : Learning like a parrot.
&lt;/h2&gt;

&lt;p&gt;I have done so many tutorials. Yes that's me. The ugly true starts coming out after a few months of self-learning by watching other peoples code then re-write what they code. &lt;/p&gt;

&lt;p&gt;I don't really know how to build things from scratch. That's what I realize. And believe me it's hard truth. &lt;/p&gt;

&lt;p&gt;Ever feel likes you want to build out something that's really cool but then you don't know where to start, what technologies to use. How will you structure your databases. How will you build out your backend or frontend.&lt;/p&gt;

&lt;p&gt;Yea that feeling. That's when you realize all the time you spent learning how to code. Indeed you learned how to code, but you learn the syntax rather than learn about the system the problem. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4ifxalg1estqs5rzlaaz.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4ifxalg1estqs5rzlaaz.jpg" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This will soon become even a bigger issue if you go work for companies and they start a new fresh project from scratch. Imagine all that pipelines, CI-CD, frontend, backend and so much more. If you just starting out as a junior developer. Well that's okay but one day you will become a mid level or a senior one you will have to do all of that. &lt;/p&gt;

&lt;p&gt;So be aware, tutorials are great for learning how to code when you just start. But don't depend on them. &lt;/p&gt;

&lt;p&gt;Learn the syntax, learn the fundamentals. Learn the "why". Then move one build your own application using all that technologies. Or you can follow a tutorial to some point. Then stop and keep building it using your own idea and rebuild the structure of the application to fit your needs.&lt;/p&gt;

&lt;p&gt;Building many features all alone by yourself is hard. It will take time and will cause you many frustration but it will definitely help you in the long run. &lt;/p&gt;

&lt;p&gt;You will have to build stuffs from scratch and that is freaky important. Believe me.&lt;/p&gt;

&lt;h2&gt;
  
  
  Third mistake : Not apply for job early
&lt;/h2&gt;

&lt;p&gt;Don't wait for a perfect moment. In fact you will never be perfect. None of us are perfect and even the senior developers are not perfect. &lt;/p&gt;

&lt;p&gt;You can't never stop learning something new in this field. As soon as you have the frontend skills : HTML, CSS, JS, a framework. You can start applying immediately.&lt;/p&gt;

&lt;p&gt;This will force you to build out a resume. It force you to think about your selling points. It force you to be aware of your current level and try harder to be job-ready. &lt;/p&gt;

&lt;p&gt;If you are learning how to code as a hobby. You will never force yourself learning or working on stuffs that's hard and no one hand holding your through it but are required. &lt;/p&gt;

&lt;p&gt;Applying jobs early also bring many opportunities that you're not aware of if you are that kind of person who is way too modest and thinking you're no worth. &lt;/p&gt;

&lt;p&gt;Personally, Applying for jobs give me the motivation to code every single day. More and more interviews just keep coming and the more I see the more I know that peoples are giving out recognition for my skills. That what keep me coding every single day. Knowing I will eventually break free and land my first job.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpw511k8yoqpuhf49nvlb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpw511k8yoqpuhf49nvlb.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The job market is not high demand as you think, believe me. There are many many peoples applying to the same tech position. I've been there I know. &lt;/p&gt;

&lt;p&gt;They only short for senior developer that agree to mid level salary. There are no shortage for new peoples. My job I'm working right now has nearly 50 peoples applied to it with degrees and experiences. The only reason I get hired is the attitude : 'All I need is experiences, I will work with minimum pay".&lt;/p&gt;

&lt;p&gt;The story that graduates tech earn around 100k is certainly not the case. Positioning yourself to embrace it. You need experience than money. Especially if you're self-taught. Close that expectation now and it will be easier for you land job in the tech industry. &lt;/p&gt;

&lt;p&gt;You will eventually get paid a lot but it will not come right out of the door. &lt;/p&gt;

&lt;p&gt;So 2 things : &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Applying for jobs early&lt;/li&gt;
&lt;li&gt;Put down your ego and expectation. Your grow in career is the most important thing. &lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Fourth reason : Spending way too much ( This is not my mistake btw, I'm just putting it here because why not. I saw many peoples have this )
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnk7qqulpy7a83rkf6k5i.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnk7qqulpy7a83rkf6k5i.jpeg" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You don't need expensive bootcamp to learn how to code. You may don't even need a 4 years CS degree consider the fact that they don't really teach you about real skills you gonna use date to date as a developer. &lt;/p&gt;

&lt;p&gt;There are many coding platform or courses will cost you as much as 15$-20$ that will provide you immense value and knowledge. Me personally, I would recommend people around 5 courses so they can be job-ready after finishing all of those. &lt;/p&gt;

&lt;p&gt;Sometime being in debt, working a labour job for 8 hours a day is what stopping you from becoming a developer. No one can really put in the work to become a developer if they never have a chance. I solely believe I'm no special than a guy who work in the supermarket stocking items. If the guy in the supermarket know about this and create enough room to create an escape. He will be able to make it and be way more successful the he could ever imagine. &lt;/p&gt;

&lt;p&gt;So believe me, don't create debt learning how to code. Don't push extra pressures on yourself. It won't come fast by any means. Just being patient and it will come. But create too many worries around yourself like debts and etc... You won't be able to make it.&lt;/p&gt;

&lt;p&gt;Now I'm not saying that's all you need. You need proofs. Lot of them, things to show to other peoples to convince them you know what you are talking about and why you're good at what you're doing. And that's : &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;PORTFOLIO&lt;/li&gt;
&lt;li&gt;GITHUB &lt;/li&gt;
&lt;li&gt;LinkedIn that record your grow as a developer&lt;/li&gt;
&lt;li&gt;Twitter ? ( I don't really use this ) &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;But Github and Portfolio is a must, I won't say otherwise. I don't believe in story where you get the job from your friends by chance. I just point out if you gonna apply the job directly and compete with everyone else. If you don't have experience and you don't even have portfolio or github. You will lost 99% of the time ( I really want to say 100% but you know nothing is absolute ). &lt;/p&gt;

&lt;p&gt;What you really need is time to learn how to code everyday and a dedication that you will never quit even if that's the 400th application you have failed.&lt;/p&gt;

&lt;p&gt;One more thing, after you have worked as a developer. You will be self-teaching yourself how to code anyway. There are no bootcamps that will help you. So why don't save yourself a favor and start doing it now to form a habit. &lt;/p&gt;

&lt;h2&gt;
  
  
  END :
&lt;/h2&gt;

&lt;p&gt;All the things above may be harsh but it's the truth. I wish when I first starting out someone will say all of this to me. &lt;/p&gt;

&lt;p&gt;Believe me guys, I'm not trying to be a dick. But I've been there and done that. I worked at McDonald before becoming a developer. I spent so many hours just learning how to code. &lt;/p&gt;

&lt;p&gt;Looking back I'm not really regret anything particularly. But if I know these things it maybe easier for me in some ways. &lt;/p&gt;

&lt;p&gt;That's it guys. Hope you find some values out of it.&lt;/p&gt;

&lt;p&gt;--peace-- &lt;/p&gt;

</description>
      <category>advices</category>
      <category>career</category>
    </item>
    <item>
      <title>Courses that I've taken to become a fullStack Developer from complete beginner</title>
      <dc:creator>Tran Minh Tri</dc:creator>
      <pubDate>Sat, 26 Jun 2021 01:53:44 +0000</pubDate>
      <link>https://dev.to/tris909/courses-that-i-ve-taken-to-become-a-fullstack-developer-from-complete-beginner-3g4e</link>
      <guid>https://dev.to/tris909/courses-that-i-ve-taken-to-become-a-fullstack-developer-from-complete-beginner-3g4e</guid>
      <description>&lt;p&gt;In this post I will share with you guys courses that I have taken and found it useful related to my date-to-date work as a developer.&lt;/p&gt;

&lt;p&gt;Please take this as a reference only, because your developer job may have many different skills but on the basic level to become a developer these skills will be pretty much help you get there. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;I recommend you to open a Github profile and start documenting your journey to become a developer because this would be super helpful for you to land that interview based on your Github alone&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  1/ The Web Developer Bootcamp 2021 - Colt Steele
&lt;/h2&gt;

&lt;p&gt;This course is good for beginners who don't even know how to code but want to understand on the very basic level of things. &lt;/p&gt;

&lt;p&gt;You will learn HTML CSS JavaScript Git API AJAX and many more. This should take your around a few months to finish it and at that point you should know at least the basics of all the things above.&lt;/p&gt;

&lt;p&gt;After this you may not know CSS or JS at the level you should be so the next 2 courses will make it up to you. &lt;/p&gt;

&lt;h2&gt;
  
  
  2/ The Complete JavaScript Course 2021: From Zero to Expert! - Jonas
&lt;/h2&gt;

&lt;h2&gt;
  
  
  3/ Advanced CSS and Sass: Flexbox, Grid, Animations and More! - Jonas
&lt;/h2&gt;

&lt;p&gt;These 2 courses will bring you CSS and JavaScript to the next level. You will start working on more complicated projects and concepts. &lt;/p&gt;

&lt;p&gt;I remembered after these 2 courses I have become so much confident about HTML, CSS, JavaScript. It will lay a solid foundation for you to start learning more complicated courses. &lt;/p&gt;

&lt;p&gt;Now you can pick up framework to prepare yourself for real because there are no jobs that you'll use plaint HTML CSS JavaScript. They all use framework or even many frameworks and libraries to get the work done quick and easy.&lt;/p&gt;

&lt;h2&gt;
  
  
  4/ React - The Complete Guide - Maximilian Schwarzmüller
&lt;/h2&gt;

&lt;h2&gt;
  
  
  5/ React Complete React Developer in 2021 (w/ Redux, Hooks, GraphQL) - Andrei Neagoie
&lt;/h2&gt;

&lt;h2&gt;
  
  
  6/ Modern React with Redux - Stephen Grider
&lt;/h2&gt;

&lt;p&gt;React is one of the most popular library out there and no doubt about that. There are many reasons I choose React like : &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Huge job market value and demand ( If you are serious about being a developer you should consider this as your first reason ) &lt;/li&gt;
&lt;li&gt;Robust, easy to learn and easy to use &lt;/li&gt;
&lt;li&gt;Huge community support and ecosystem &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;There are many other technical reasons but we don't really need to go deep into that right now. &lt;/p&gt;

&lt;p&gt;React is so big and to be honest it won't be replace anywhere soon because so many businesses built based on it. So you won't even have to worry about being jobless knowing this ( Ps: compared to Jquery ;) )&lt;/p&gt;

&lt;p&gt;After finishing all these courses you should be job ready at least for a FrontEnd position so get yourself out there and looking for jobs because no learning exp is better than working exp.&lt;/p&gt;

&lt;p&gt;But we are not done yet ;) So stay tune. &lt;/p&gt;

&lt;h2&gt;
  
  
  7/ The Complete Node.js Developer Course (3rd Edition) - Andrew Mead
&lt;/h2&gt;

&lt;h2&gt;
  
  
  8/ MERN eCommerce From Scratch - Brad Traversy
&lt;/h2&gt;

&lt;p&gt;It's time for you to start learning more about BackEnd . I recommend you learn NodeJS because you can still use JavaScript which at this point I reckon you are very comfortable with. &lt;/p&gt;

&lt;p&gt;These courses will teach you how to build an API, how to communicate between FE and BE, how to make private/public API, how to build a server of some sort and more. Very useful if you are planning become a MERN Developer like me. &lt;/p&gt;

&lt;p&gt;After these 2 courses you should be able to understand how FrontEnd work with BackEnd. How to build a FullStack application even at the basic level. &lt;/p&gt;

&lt;p&gt;What I will recommend you do right now is go and build a &lt;strong&gt;Portfolio&lt;/strong&gt; that have many projects built and developed by you ( hopefully ). Now you will learn to do stuffs on your own even thou when learning courses you should be able to do it before watching the video to be fair. &lt;/p&gt;

&lt;p&gt;All of these courses above along with many hours you spend outside of courses to work on your portfolio and projects that you have developed should take you around a year to be fair. If you finish all of these in 3-4 months you probably flying from video and video and applying ZERO what you're learning so take your time and don't rush even if you have to do another job while doing all of this. &lt;/p&gt;

&lt;h1&gt;
  
  
  Bonus
&lt;/h1&gt;

&lt;p&gt;TypeScript &lt;/p&gt;

&lt;h2&gt;
  
  
  9/ Typescript: The Complete Developer's Guide - Stephen Grider
&lt;/h2&gt;

&lt;p&gt;TypeScript is rising and if you want to go far into your career as a developer. TypeScript won't hurt. Many companies that are hiring developers, they are looking for TypeScript related now. Many high paying developer jobs you will see this skill once every few times. &lt;/p&gt;

&lt;p&gt;CI-CD of choice &lt;/p&gt;

&lt;h2&gt;
  
  
  10/ GitLab CI: Pipelines, CI/CD and DevOps for Beginners - Learn with Valentine
&lt;/h2&gt;

&lt;p&gt;Every single interview they will ask you if you have any experience related to CI-CD of some kind even if that is a junior position. If you are a junior developer they may ignore and accept that you don't know CI-CD. But the longer you work in the industry, it will become compulsory to know and even build pipeline to deploy code. &lt;/p&gt;

&lt;p&gt;You can always consider this after you have studied all the things above. &lt;/p&gt;

&lt;p&gt;End.&lt;br&gt;
Now I may have taken even more courses and more projects on Youtube or other sources. But all the courses above are what I think will provide for you so much related industrial knowledge. &lt;/p&gt;

&lt;p&gt;Developer requirements now are insane. I don't want to be a hater but the story I become a developer for 3 months 6 months always have something behind backing up for them that you don't know. So if you are a complete beginner who don't even know how to code a single line of code. You should take your time and always look out for opportunity to learn and improve yourself.&lt;/p&gt;

&lt;p&gt;Now that's all. I hope this blog will help anyone who want to learn about how to become a FullStack Developer. Wish everyone a good day and thank you all.&lt;/p&gt;

</description>
      <category>courses</category>
      <category>recommend</category>
    </item>
    <item>
      <title>How to use Redux with TypeScript ?</title>
      <dc:creator>Tran Minh Tri</dc:creator>
      <pubDate>Sat, 03 Apr 2021 02:49:25 +0000</pubDate>
      <link>https://dev.to/tris909/how-to-use-redux-with-typescript-1oag</link>
      <guid>https://dev.to/tris909/how-to-use-redux-with-typescript-1oag</guid>
      <description>&lt;p&gt;In this small tutorial, I will show you how to use Redux with TypeScript. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Disclaimer:&lt;/strong&gt; I want to do this tutorial as a way to re-do what I learn and at the same time I want to share this knowledge with anyone who needs it. I can't make sure this is the best practice. But if you just want to find out how you can use redux with TypeScript this is one of them.&lt;/p&gt;

&lt;p&gt;We will make a small application that simply reaches out to an API then fetches some data and dumps it out the screen. Now, this app may be small and that's okay because our main focuses are :&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;How to setUp a react-typescript project&lt;/li&gt;
&lt;li&gt;How to setUp a redux store in our project&lt;/li&gt;
&lt;li&gt;How to create an actionCreator that will perform an Async/Await Request &lt;/li&gt;
&lt;li&gt;How to use this actionCreator in our components.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This tutorial requires you to know : &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;React &lt;/li&gt;
&lt;li&gt;Redux &lt;/li&gt;
&lt;li&gt;ES6 (async/await) &lt;/li&gt;
&lt;li&gt;Basic of TypeScript&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;At the end of this tutorial, I will include some useful links for anyone who wants to learn more about TypeScript. &lt;/p&gt;

&lt;h1&gt;
  
  
  Why TypeScript ?
&lt;/h1&gt;

&lt;p&gt;We know that TypeScript is rising ⭐ .Especially at the enterprise level where we have a lot of code to manage. People want to understand and see how data flow in their web applications. &lt;/p&gt;

&lt;p&gt;I mean JavaScript works just fine. There nothing wrong with JavaScript except for the fact that with JavaScript alone it is really hard for you to come into a legacy codebase to build a new feature and this feature includes dozens of files😵 . All these files contain different variables, functions that are not written by you. So it will take you a lot of time to understand all of that without any directions whatsoever. &lt;/p&gt;

&lt;p&gt;That is where TypeScript comes in. It will define &lt;code&gt;type&lt;/code&gt; for nearly everything. Plus this &lt;code&gt;type&lt;/code&gt; thing is also a protection for the app itself and this protection will prevent you from passing in the wrong type and causing more errors that you don't even know about. &lt;/p&gt;

&lt;p&gt;The downside of TypeScript however is that it is somewhat re-invent the wheel (debatable). TypeScript does not help you build faster features especially if you are someone who doesn't understand TypeScript well enough. You can think of writing TypeScript as somewhat the same as writing tests.&lt;/p&gt;

&lt;p&gt;You will have more errors than before because simply the app doesn't want to accept your type for some reason and you waste more time looking for the answer why 😡 .Believe me, It happens. &lt;/p&gt;

&lt;p&gt;But it is undeniable that If we choose to use TypeScript we are choosing to develop an app that will eventually have ten thousand lines of code 📄 and make our future easier by making it more maintainable. &lt;/p&gt;

&lt;p&gt;Plus as a developer. There are a lot of companies that desire a developer with experience with TypeScript 💰 💰 💰 .And that alone is a good reason to start learning it. &lt;/p&gt;

&lt;h1&gt;
  
  
  Tutorial :
&lt;/h1&gt;

&lt;h3&gt;
  
  
  Start our new react-typeScript project :
&lt;/h3&gt;

&lt;p&gt;You need to choose a directory where you want your app to be and then open a command line in that directory then type this in : &lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

npx create-react-app PROJECT_NAME --template typescript


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Okay now go sipping some ☕ ☕ ☕ waiting for the npm packages to do it things &lt;/p&gt;

&lt;h3&gt;
  
  
  Install packages :
&lt;/h3&gt;

&lt;p&gt;We will install some packages that allow us to work with both typeScript and redux. Open another command line in the project directory and type : &lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

npm install --save @types/react-redux axios react-redux redux redux-thunk 


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;We just install 5 packages, I will go through each and single one of them with you : &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;types/react-redux : for defining types for react-redux packages. When you use packages with typescript you have to download their &lt;code&gt;type&lt;/code&gt; packages as well. &lt;/li&gt;
&lt;li&gt;axios : this is for working with ajax easier. We actually don't need it but I love it so yea 😆 &lt;/li&gt;
&lt;li&gt;react-redux : You need this to work connect redux to react &lt;/li&gt;
&lt;li&gt;redux : Redux library itself &lt;/li&gt;
&lt;li&gt;redux-thunk : You need this to create an actionCreator &lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Understand what we want to build :
&lt;/h3&gt;

&lt;p&gt;We gonna build a simple reducer that has an initialState of 3 things: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;comments: Comment[]&lt;/li&gt;
&lt;li&gt;loading : boolean&lt;/li&gt;
&lt;li&gt;error : string | null &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We will reach out to an API and fetch the comments array of that post with our input as postId then dump all comments out to the screens. &lt;/p&gt;

&lt;p&gt;This is the API we will use : &lt;code&gt;https://jsonplaceholder.typicode.com/comments?postId=1&lt;/code&gt; .The postId will be inserted from an input that we gonna build later.&lt;/p&gt;

&lt;p&gt;(PICTURE DEMO HERE)&lt;/p&gt;

&lt;h3&gt;
  
  
  SetUp Our Reducer
&lt;/h3&gt;

&lt;p&gt;This should be your project folder structure at the moment : &lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0nxkqdxxcux382gj3d6e.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0nxkqdxxcux382gj3d6e.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Go and create a folder structure like this : &lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frg1xmtp7ftm008pr3sxl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frg1xmtp7ftm008pr3sxl.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is what your normal reducer looks like : &lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4hcwz5jlrexoz42i07ov.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4hcwz5jlrexoz42i07ov.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This won't work in TypeScript because we did not define a type for both state and action of this reducer.Now we will define a type for our state first : &lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;

&lt;span class="kr"&gt;interface&lt;/span&gt; &lt;span class="nx"&gt;Comment&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;postId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nx"&gt;email&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nx"&gt;body&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kr"&gt;interface&lt;/span&gt; &lt;span class="nx"&gt;State&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;comments&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Comment&lt;/span&gt;&lt;span class="p"&gt;[],&lt;/span&gt;
    &lt;span class="nx"&gt;loading&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;boolean&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt; 
&lt;span class="p"&gt;}&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Pretty normal right ? Next we will create a type for our actions. &lt;br&gt;
The thing with our actions is that based on action.type we will have different kind of payloads. In this case we have 3 different action.types so we need 3 different types of action for this. &lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;

&lt;span class="kr"&gt;enum&lt;/span&gt; &lt;span class="nx"&gt;ActionType&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;GET_POST_COMMENTS_PENDING&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;GET_POST_COMMENTS_PENDING&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nx"&gt;GET_POST_COMMENTS_SUCCESS&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;GET_POST_COMMENTS_SUCCESS&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nx"&gt;GET_POST_COMMENTS_FAIL&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;GET_POST_COMMENTS_FAIL&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kr"&gt;interface&lt;/span&gt; &lt;span class="nx"&gt;actionPending&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;ActionType&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;GET_POST_COMMENTS_PENDING&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kr"&gt;interface&lt;/span&gt; &lt;span class="nx"&gt;actionSuccess&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;ActionType&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;GET_POST_COMMENTS_SUCCESS&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;payload&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;[];&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kr"&gt;interface&lt;/span&gt; &lt;span class="nx"&gt;actionFail&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;ActionType&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;GET_POST_COMMENTS_FAIL&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;payload&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt; &lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="nx"&gt;Action&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;actionPending&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="nx"&gt;actionSuccess&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="nx"&gt;actionFail&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;commentReducer&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;state&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;State&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;initialState&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;action&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Action&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;&lt;span class="nx"&gt;State&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="p"&gt;...}&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;I know that our code in this file is messy but It's okay. We will re-factor them later. That's why in the folder redux structure you see I create 2 other folders. &lt;/p&gt;

&lt;p&gt;But before close this chapter, I need you to create a compbine File in your reducers to combine all reducers like this : &lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;

&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;combineReducers&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;redux&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;commentReducer&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./index.ts&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;reducers&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;combineReducers&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
&lt;span class="na"&gt;comments&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;commentReducer&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;reducers&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="c1"&gt;//This RootState is required to use useSelector later on &lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="nx"&gt;RootState&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;ReturnType&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="k"&gt;typeof&lt;/span&gt; &lt;span class="nx"&gt;reducers&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;At this point we already have our reducer ready. &lt;/p&gt;

&lt;h3&gt;
  
  
  Create an actionCreator and re-factor code :
&lt;/h3&gt;

&lt;p&gt;Create a new file in dir: 'actionTypes' in redux dir. Then put all these codes in there and export our Action : &lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;

&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;Comment&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;../reducers/index&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kr"&gt;enum&lt;/span&gt; &lt;span class="nx"&gt;ActionType&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;GET_POST_COMMENTS_PENDING&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;GET_POST_COMMENTS_PENDING&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nx"&gt;GET_POST_COMMENTS_SUCCESS&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;GET_POST_COMMENTS_SUCCESS&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nx"&gt;GET_POST_COMMENTS_FAIL&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;GET_POST_COMMENTS_FAIL&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kr"&gt;interface&lt;/span&gt; &lt;span class="nx"&gt;actionPending&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;ActionType&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;GET_POST_COMMENTS_PENDING&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kr"&gt;interface&lt;/span&gt; &lt;span class="nx"&gt;actionSuccess&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;ActionType&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;GET_POST_COMMENTS_SUCCESS&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;payload&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Comment&lt;/span&gt;&lt;span class="p"&gt;[];&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kr"&gt;interface&lt;/span&gt; &lt;span class="nx"&gt;actionFail&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;ActionType&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;GET_POST_COMMENTS_FAIL&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;payload&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt; &lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="nx"&gt;Action&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;actionPending&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="nx"&gt;actionSuccess&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="nx"&gt;actionFail&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Then import our Action and ActionTypes in our reducer File and replace the action.types the put some info in return statement and That's it. This is what our reducer currently looks like : &lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;

&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;Action&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;ActionType&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;../actionTypes/index&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kr"&gt;interface&lt;/span&gt; &lt;span class="nx"&gt;Comment&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;postId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nx"&gt;email&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nx"&gt;body&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kr"&gt;interface&lt;/span&gt; &lt;span class="nx"&gt;State&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;comments&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Comment&lt;/span&gt;&lt;span class="p"&gt;[];&lt;/span&gt;
    &lt;span class="nl"&gt;loading&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;boolean&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;error&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;initialState&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;comments&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[],&lt;/span&gt;
    &lt;span class="na"&gt;loading&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
    &lt;span class="na"&gt;error&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt; 
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;commentReducer&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;state&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;State&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;initialState&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;action&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Action&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;&lt;span class="nx"&gt;State&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;switch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;action&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="kd"&gt;type&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="nx"&gt;ActionType&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="na"&gt;GET_POST_COMMENTS_PENDING&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="na"&gt;loading&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt; 
            &lt;span class="p"&gt;}&lt;/span&gt; 
        &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="nx"&gt;ActionType&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="na"&gt;GET_POST_COMMENTS_SUCCESS&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="na"&gt;loading&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                &lt;span class="na"&gt;comments&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;action&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;payload&lt;/span&gt;
            &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="nx"&gt;ActionType&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="na"&gt;GET_POST_COMMENTS_FAIL&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="na"&gt;loading&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                &lt;span class="na"&gt;error&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;action&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;payload&lt;/span&gt; 
            &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="nl"&gt;default&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; 
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;state&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Now we will create an actionCreator, if you have create an actionCreator before, then do it yourself then compare with code below :&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;

&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;axios&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;axios&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;Dispatch&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;redux&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;ActionType&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;Action&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;../actionTypes&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;getComments&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;postId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;async &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="na"&gt;dispatch&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Dispatch&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Action&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nf"&gt;dispatch&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
            &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;ActionType&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;GET_POST_COMMENTS_PENDING&lt;/span&gt;
        &lt;span class="p"&gt;});&lt;/span&gt;

        &lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;axios&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`https://jsonplaceholder.typicode.com/comments?postId=&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;postId&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

            &lt;span class="nf"&gt;dispatch&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
                &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;ActionType&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;GET_POST_COMMENTS_SUCCESS&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                &lt;span class="na"&gt;payload&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt;  
            &lt;span class="p"&gt;});&lt;/span&gt;

        &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;catch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;err&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="nf"&gt;dispatch&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
                &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;ActionType&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;GET_POST_COMMENTS_FAIL&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                &lt;span class="na"&gt;payload&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;err&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;message&lt;/span&gt;
            &lt;span class="p"&gt;});&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt; 


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;There not much of a different from normal actionCreator except you need to define type of dispatch before using it &lt;code&gt;dispatch: Dispatch&amp;lt;Action&amp;gt;&lt;/code&gt; &lt;/p&gt;

&lt;h3&gt;
  
  
  Create a store and connect to our app then use our actionCreator to fetch some data then dump them to the screen :
&lt;/h3&gt;

&lt;p&gt;You need to create a store.ts file in your redux dir. &lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;

&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;createStore&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;applyMiddleware&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;redux&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;thunk&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;redux-thunk&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;reducers&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./reducers/combine&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;store&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;createStore&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;reducers&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{},&lt;/span&gt; &lt;span class="nf"&gt;applyMiddleware&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;thunk&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Because this is a simple app I will build everything in App.tsx file.Go to your index.tsx file  in your src directory to provide your store:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;

&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;react&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;ReactDOM&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;react-dom&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./index.css&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;App&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./App&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;reportWebVitals&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./reportWebVitals&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;store&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./redux/store&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; 
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;Provider&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;react-redux&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nx"&gt;ReactDOM&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;render&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;React&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;StrictMode&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Provider&lt;/span&gt; &lt;span class="nx"&gt;store&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;store&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;App&lt;/span&gt; &lt;span class="o"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/Provider&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;  &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/React.StrictMode&amp;gt;&lt;/span&gt;&lt;span class="err"&gt;,
&lt;/span&gt;  &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getElementById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;root&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;We also need to create a custom hook to be able to use useSelector with TypeScript, you just need to create a file called &lt;code&gt;useTypeSelector&lt;/code&gt; and pass this in : &lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;

&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;useSelector&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;TypedUseSelectorHook&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;react-redux&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;RootState&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;../redux/reducers/combine&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;useTypedSelector&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;TypedUseSelectorHook&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;RootState&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;useSelector&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;This is documented in React-Redux with TypeScript. That is just how it is to use useSelector so there nothing much to talk about this.  &lt;/p&gt;

&lt;p&gt;Okay now go to App.tsx, After this file I think we are done for this tutorial : &lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;

&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;useState&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;react&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;getComments&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./redux/actionCreators/getComment&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;useDispatch&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;react-redux&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;useTypedSelector&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./hooks/useTypeSelector&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;App&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;dispatch&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useDispatch&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;postId&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setPostID&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useState&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;""&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;comments&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;loading&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;error&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useTypedSelector&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;state&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;state&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;comments&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;onSubmitHandler&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;async &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;FormEvent&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;HTMLFormElement&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;preventDefault&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

    &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;dispatch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;getComments&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;postId&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
      &lt;span class="o"&gt;&amp;lt;&amp;gt;&lt;/span&gt;
      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;form&lt;/span&gt; &lt;span class="nx"&gt;onSubmit&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;onSubmitHandler&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
          &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;input&lt;/span&gt; &lt;span class="kd"&gt;type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;number&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;postId&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="nx"&gt;onChange&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{(&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;setPostID&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;target&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;)}&lt;/span&gt; &lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;          &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;button&lt;/span&gt; &lt;span class="kd"&gt;type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;submit&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;submit&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/button&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/form&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;
      &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nx"&gt;loading&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
          &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Loading&lt;/span&gt;&lt;span class="p"&gt;...&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;        &lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
          &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;ul&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
            &lt;span class="p"&gt;{&lt;/span&gt;
              &lt;span class="nx"&gt;comments&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;comment&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;li&lt;/span&gt; &lt;span class="nx"&gt;key&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;comment&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;comment&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;body&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/li&amp;gt;&lt;/span&gt;&lt;span class="err"&gt;)
&lt;/span&gt;              &lt;span class="p"&gt;})&lt;/span&gt;
            &lt;span class="p"&gt;}&lt;/span&gt;
          &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/ul&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;        &lt;span class="p"&gt;)&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;
      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;App&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;And that is it, you may notice there aren't many differents with normal React components except &lt;code&gt;event: React.FormEvent&amp;lt;HTMLFormElement&amp;gt;&lt;/code&gt; and &lt;code&gt;import { useTypedSelector } from './hooks/useTypeSelector';&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This is our final result : &lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2khtpwzpkly3cq3lgmyf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2khtpwzpkly3cq3lgmyf.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now this is ugly 😅 I have to admit it. But this is not a tutorial about CSS. You can always add that later and it is really trivial to focus on CSS in this tutorial. &lt;/p&gt;

&lt;p&gt;My point is this tutorial will help you understand how to setUp redux-store with React using TypeScript, how to create an ActionCreator and how to use this ActionCreator in your app.&lt;/p&gt;

&lt;p&gt;Here is the source code for the app : &lt;a href="https://github.com/Tris-909/TypeScript-Redux" rel="noopener noreferrer"&gt;Here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you want to dive deeper into this topic, please visit this link :&lt;br&gt;
&lt;a href="https://react-typescript-cheatsheet.netlify.app/docs/basic/getting-started/function_components" rel="noopener noreferrer"&gt;Here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I hope this will help you 😂 the main reason I do this tutorial is solidating my knowledge but if it helps you in some way then I glad. Please give me a star on Github if this helps you :3 &lt;/p&gt;

&lt;p&gt;-- peace -- &lt;/p&gt;

</description>
      <category>tutorial</category>
      <category>typescript</category>
      <category>react</category>
      <category>redux</category>
    </item>
    <item>
      <title>Let's share our personal websites and see how we can we improve it.</title>
      <dc:creator>Tran Minh Tri</dc:creator>
      <pubDate>Fri, 19 Mar 2021 07:08:58 +0000</pubDate>
      <link>https://dev.to/tris909/let-s-share-our-personal-websites-and-see-how-we-can-we-improve-it-2ll3</link>
      <guid>https://dev.to/tris909/let-s-share-our-personal-websites-and-see-how-we-can-we-improve-it-2ll3</guid>
      <description>&lt;p&gt;Hi everyone, I am Tri Tran - Fullstack Developer 😊&lt;/p&gt;

&lt;p&gt;Every Web Developer should have a portfolio especially a junior one. Nowadays, web development has become very competitive. Knowing the skills is not enough and you also should need a portfolio to contain projects related to that skills and show up your personality 😗&lt;/p&gt;

&lt;p&gt;Today I want to make a post where people can come in and share their personal websites then receive opinions on how people think it looks and improves it together. &lt;/p&gt;

&lt;p&gt;I will share mine first. I have built and made changes to this website for a couple of months. Thank to my personal website I got many callbacks and interviews just by seeing my resume and portfolio even though I don't have a degree and any commercial experience 😄 then eventually land my first job. &lt;/p&gt;

&lt;p&gt;This is my portfolio : &lt;a href="https://tranminhtri.com/"&gt;Portfolio&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Please give me your opinion on how it looks and what I can do to improve and I would do the same for you as well ! 😆&lt;/p&gt;

</description>
      <category>showdev</category>
      <category>portfolio</category>
      <category>improve</category>
    </item>
    <item>
      <title>5 hours GraphQL Tutorial with NodeJS and Express</title>
      <dc:creator>Tran Minh Tri</dc:creator>
      <pubDate>Thu, 18 Mar 2021 08:26:14 +0000</pubDate>
      <link>https://dev.to/tris909/5hours-graphql-tutorial-with-nodejs-and-express-12l1</link>
      <guid>https://dev.to/tris909/5hours-graphql-tutorial-with-nodejs-and-express-12l1</guid>
      <description>&lt;p&gt;This is a tutorial that will show you how to make a graphQL server using graphQL, NodeJS, Express, MongoDB. &lt;/p&gt;

&lt;p&gt;At the end of this tutorial. You should know how graphQL works, be able to set-up a basic server that has one endpoint but allow you to gather information from many different databases in a single cluster. &lt;/p&gt;

&lt;h2&gt;
  
  
  Why GraphQL?
&lt;/h2&gt;

&lt;p&gt;Normally, when you build APIs, you normally have many different endpoints for many different purposes. &lt;/p&gt;

&lt;p&gt;The result is when you need changes on the front-end, you have to go back to the back-end and fix the API to make it return the right data. It is easy for you to do this when you have 10 APIs, but when you have 40, 50+ APIs with different complicated data to return it makes things harder to maintain. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fmax%2F2000%2F1%2AfeOd6UwyHF71rRmRtj_B7g.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fmax%2F2000%2F1%2AfeOd6UwyHF71rRmRtj_B7g.png" alt="how grapql works"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This same problem happens to Facebook so they decide to invent graphQL. Now we have many more pros like : &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Smaller payload &lt;/li&gt;
&lt;li&gt;Fetching all data as one &lt;/li&gt;
&lt;li&gt;Pre-defined Schema ( How your data should look like, this helps you have better understanding of data-flow in your app )&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We also have some cons as well : &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Learning Curve (Yes! You need to spend time learning it )&lt;/li&gt;
&lt;li&gt;Not popular ( It is strong. But GraphQL just provides a new way to manage and write your APIs. It does feel life-changing but RESTful APIs work just fine in many cases. In fact, you may never need GraphQL if you don't do it in your day-to-day job as a developer ). &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Still, If you still like GraphQL and want to see how you can create a basic server that allows you to fetch data from graphQL. Then this tutorial is for you. &lt;/p&gt;

&lt;h1&gt;
  
  
  Tutorial :
&lt;/h1&gt;

&lt;h2&gt;
  
  
  Installing npm packages :
&lt;/h2&gt;

&lt;p&gt;_ Firstly, you need to choose a directory and run &lt;code&gt;npm init&lt;/code&gt; to start the project. &lt;br&gt;
_ Then install these packages (we will need them later on ): &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;cors ( workaround CORS problems ) &lt;/li&gt;
&lt;li&gt;dotenv ( using environment variables ) &lt;/li&gt;
&lt;li&gt;express ( express server ) &lt;/li&gt;
&lt;li&gt;express-graphql ( connecting express with graphql ) &lt;/li&gt;
&lt;li&gt;mongoose ( working with mongoDB ) &lt;/li&gt;
&lt;li&gt;nodemon  ( keep your server on watch mode ) &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Your packages.json should look like this (versions of packages are not important, you just need to install the latest) : &lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fp0qh053g9yawrk6z4dbo.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fp0qh053g9yawrk6z4dbo.PNG" alt="packages"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  SetUp a databases with MongoDB
&lt;/h2&gt;

&lt;p&gt;We also need free-tier databases hosted on &lt;a href="https://www.mongodb.com/" rel="noopener noreferrer"&gt;MongoD&lt;/a&gt; so we can see if our API works. &lt;/p&gt;

&lt;p&gt;You should be able to go to MongoDB create an account if you don't have one and create a project. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsb1lbu20axwbmpynggc3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsb1lbu20axwbmpynggc3.png" alt="MongoDB"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When you have the project, choose &lt;code&gt;connect&lt;/code&gt; &amp;gt; &lt;code&gt;connect using mongodb compass&lt;/code&gt; and try to look for the string like this : &lt;/p&gt;

&lt;p&gt;&lt;code&gt;mongodb+srv://admin:${process.env.MONGO_DB_PASSWORD}@graphql.oumb8.mongodb.net/test&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;admin&lt;/code&gt; and &lt;code&gt;password&lt;/code&gt; could be different but it is okay. That's on you. Now just save it somewhere we will need it later.&lt;/p&gt;
&lt;h2&gt;
  
  
  SetUp Server ( app.js )
&lt;/h2&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;express&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;express&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="c1"&gt;// grapqlHTTP allows us to use built-in interfaces to test our API&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;graphqlHTTP&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;express-graphql&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// Using environment variable to store mongoDB databases password&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;dotenv&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;dotenv&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;dotenv&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;config&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="c1"&gt;// Connecting mongoose with databases&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;mongoose&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;mongoose&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;mongoose&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;connect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`mongodb+srv://admin:&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;MONGO_DB_PASSWORD&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;@graphql.oumb8.mongodb.net/test`&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt; 
    &lt;span class="na"&gt;useNewUrlParser&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;useUnifiedTopology&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt; 
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="nx"&gt;mongoose&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;connection&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;once&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;open&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Connected to databases&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="c1"&gt;// CORS &lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;cors&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;cors&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// GrapQL Schema ( We haven't created it yet but we will soon )&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;schema&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./schema/schema&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;app&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;express&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;use&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;cors&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt;
&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;use&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/graphql&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nf"&gt;graphqlHTTP&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
    &lt;span class="na"&gt;graphiql&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;schema&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;schema&lt;/span&gt;
&lt;span class="p"&gt;}));&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;port&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;PORT&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="mi"&gt;5000&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;listen&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;port&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`SERVER IS RUNNING ON PORT &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;port&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Now I know this is long. But all of the things above are just boilerplate. So don't stress yourself too much. It always required a lot to setup a server even it is just a basic one. &lt;/p&gt;

&lt;p&gt;Also, create .env file like this to use your environment variables:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;MONGO_DB_PASSWORD=your-mongodb-password
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Create Mongoose Model
&lt;/h2&gt;

&lt;p&gt;Mongoose models are used to define how your data will be stored in mongoDB and also it is a way to connect to mongoDB to perform CRUD operations and more.&lt;/p&gt;

&lt;p&gt;We will create 3 simple Mongoose Models : User, Hobby, Post &lt;br&gt;
User.js&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;mongoose&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;mongoose&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;UserSchema&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;mongoose&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Schema&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
    &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;String&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;age&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;Number&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;job&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;String&lt;/span&gt; 
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="nx"&gt;module&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;exports&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;mongoose&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;model&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;User&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;UserSchema&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Basically, we just create a UserSchema that will have name, age, job fields. Now we just need to do the same with Post and Hobby.&lt;/p&gt;

&lt;p&gt;PostModel should have: comment, userId&lt;br&gt;
HobbyModel should have: title, description, userId&lt;br&gt;&lt;br&gt;
I believe you can do it on your own. It is the same as UserModel.&lt;/p&gt;
&lt;h2&gt;
  
  
  Create GraphQL RootQuery and Mutation:
&lt;/h2&gt;
&lt;h4&gt;
  
  
  1.Definition about RootQuery and Mutation :
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;RootQuery&lt;/strong&gt; is where you can define what queries you want to build. Basically, all queries of your graphql API are stored in this RootQuery. So you can access it through a single endpoint. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Mutation&lt;/strong&gt; also just works like RootQuery but now it is used to store methods used to change your data instead of just read it.&lt;/p&gt;

&lt;p&gt;Eventually, you will provide it to GraphQLSchema like this :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;RootQuery&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;...&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;Mutation&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;...&lt;/span&gt;

&lt;span class="nx"&gt;module&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;exports&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;graphql&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;GraphQLSchema&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
    &lt;span class="na"&gt;query&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;RootQuery&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;mutation&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Mutation&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  2.Define types for RootQuery :
&lt;/h4&gt;

&lt;p&gt;Just like we talked about one of the pros of RootQuery, we have pre-defined schema in GraphQL to help us to know what Queries from RootQuery will return. All of this is thank to &lt;code&gt;types&lt;/code&gt; we will define in RootQuery. &lt;/p&gt;

&lt;p&gt;A type in GraphQL will have 2 basic fields: name, fields and in every field of fields we have 3 basic fields: type, args (optional), resolve.&lt;/p&gt;

&lt;p&gt;Enough for talking, we will now create a UserType to see what is a type in GraphQL. &lt;/p&gt;

&lt;p&gt;Schema.js&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;graphql&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;graphql&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;User&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;../models/User&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;Post&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;../models/Post&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;Hobby&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;../models/Hobby&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;UserType&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;graphql&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;GraphQLObjectType&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
&lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;UserType&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;//We will use this `name` in RootQuery&lt;/span&gt;
&lt;span class="na"&gt;fields&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;({&lt;/span&gt;
        &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;graphql&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;GraphQLID&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;
        &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;graphql&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;GraphQLString&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;
        &lt;span class="na"&gt;age&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;graphql&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;GraphQLInt&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;
        &lt;span class="na"&gt;job&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;graphql&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;GraphQLString&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;
        &lt;span class="na"&gt;posts&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;graphql&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;GraphQLList&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;PostType&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
            &lt;span class="nf"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;parent&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;args&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;postArrays&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;Post&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;find&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
                    &lt;span class="na"&gt;userId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;parent&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;
                &lt;span class="p"&gt;});&lt;/span&gt;

                &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;postArrays&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
            &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="p"&gt;},&lt;/span&gt;
        &lt;span class="na"&gt;hobbies&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;graphql&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;GraphQLList&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;HobbyTypes&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
            &lt;span class="nf"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;parent&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;args&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;hobbiesArray&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;Hobby&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;find&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
                    &lt;span class="na"&gt;userId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;parent&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt; 
                &lt;span class="p"&gt;});&lt;/span&gt;

                &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;hobbiesArray&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
            &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I will explain. Here in this UserType when we query for users we will expect to see 6 fields in return for each user and that are: id, name, job, age, posts, hobbies.&lt;/p&gt;

&lt;p&gt;In this case, posts and hobbies are more special mainly because they have their own databases on MongoDB. we will need to use &lt;code&gt;args&lt;/code&gt; (optional) and &lt;code&gt;resolve(parent,args){}&lt;/code&gt; to fetch them from their own databases. &lt;/p&gt;

&lt;p&gt;&lt;code&gt;args&lt;/code&gt;: is where you will provide arguments that will be used in &lt;code&gt;resolve&lt;/code&gt; method used to fetch data.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;resolve(parent, args){}&lt;/code&gt;: is where you fetch your data and will have access to the parent element (User databases) and args that you provided earlier.&lt;/p&gt;

&lt;p&gt;In &lt;code&gt;resolve(parent, args){}&lt;/code&gt;, we just connect to our databases and doing Mongoose stuffs. This is not a tutorial about how to work with Mongoose so I guess you can figure this out. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Knowing that fields in GraphQL and Mongoose Models don't have to be exactly 100% like each other. Fields in GraphQL act like bridge between your databases where you can keep gathering information by jumping between Types while Model in Mongoose defines how your data will be stored in your databases. These two are different.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You can do the same for HobbyType and PostType then come back here to check.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;HobbyTypes&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;graphql&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;GraphQLObjectType&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
    &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;HobbyType&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;description&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Model for HobbyType&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;fields&lt;/span&gt;&lt;span class="p"&gt;:()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;({&lt;/span&gt;
        &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;graphql&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;GraphQLID&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;
        &lt;span class="na"&gt;title&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;graphql&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;GraphQLString&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;
        &lt;span class="na"&gt;description&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;graphql&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;GraphQLString&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;
        &lt;span class="na"&gt;user&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;UserType&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="nf"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;parent&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;args&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;user&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;User&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;findById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;parent&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;userId&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

                &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
            &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;})&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;PostType&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;graphql&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;GraphQLObjectType&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
    &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;PostType&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;description&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Model for PostType&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;fields&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;({&lt;/span&gt;
        &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;graphql&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;GraphQLID&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;
        &lt;span class="na"&gt;comment&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;graphql&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;GraphQLString&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;
        &lt;span class="na"&gt;user&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;UserType&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;

            &lt;span class="nf"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;parent&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;args&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;user&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;User&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;findById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;parent&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;userId&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

                &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
            &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;})&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this situation, &lt;code&gt;user&lt;/code&gt; field from &lt;code&gt;fields&lt;/code&gt; acts like a bridge. You can gather userInfo then in userInfo you will have a post inside a postArray that contain info about the user and this user (same user) have a postArray and the cycle repeat. This is the power of GraphQL. &lt;strong&gt;You can freely fetch data by jumping between databases as long as you define them in &lt;code&gt;fields&lt;/code&gt;&lt;/strong&gt;.&lt;/p&gt;

&lt;h4&gt;
  
  
  3.Building RootQuery :
&lt;/h4&gt;

&lt;p&gt;If you know how to build Types like above, you will know how to build RootQuery. It's basically the same.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;RootQuery&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;graphql&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;GraphQLObjectType&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
    &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;RootQuery&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;fields&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;user&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;UserType&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="na"&gt;args&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;graphql&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;GraphQLID&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
            &lt;span class="p"&gt;},&lt;/span&gt;
            &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="nf"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;parent&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;args&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;user&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;User&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;findById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;args&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

                &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
            &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="p"&gt;},&lt;/span&gt;
        &lt;span class="na"&gt;users&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;graphql&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;GraphQLList&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;UserType&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
            &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="nf"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;parent&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;args&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;users&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;User&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;find&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

                &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;users&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
            &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="p"&gt;},&lt;/span&gt;

        &lt;span class="na"&gt;hobby&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;HobbyTypes&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="na"&gt;args&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;graphql&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;GraphQLID&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
            &lt;span class="p"&gt;},&lt;/span&gt;
            &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="nf"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;parent&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;args&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;hobby&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;Hobby&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;findById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;args&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

                &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;hobby&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
            &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="p"&gt;},&lt;/span&gt;
        &lt;span class="na"&gt;hobbies&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;graphql&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;GraphQLList&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;HobbyTypes&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
            &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="nf"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;parent&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;args&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;hobbies&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;Hobby&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;find&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

                &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;hobbies&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
            &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="p"&gt;},&lt;/span&gt;

        &lt;span class="na"&gt;post&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;PostType&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="na"&gt;args&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;graphql&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;GraphQLID&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
            &lt;span class="p"&gt;},&lt;/span&gt;
            &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="nf"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;parent&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;args&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;post&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;Post&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;findById&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
                    &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;args&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;
                &lt;span class="p"&gt;});&lt;/span&gt;

                &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;post&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
            &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="p"&gt;},&lt;/span&gt;
        &lt;span class="na"&gt;posts&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;graphql&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;GraphQLList&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;PostType&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
            &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="nf"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;parent&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;args&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;posts&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;Post&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;find&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

                &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;posts&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
            &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You will have 6 queries, but if you can understand how we build &lt;code&gt;user&lt;/code&gt; query, you will understand the rest. &lt;/p&gt;

&lt;p&gt;&lt;code&gt;user&lt;/code&gt; query will fetch a user using &lt;code&gt;id&lt;/code&gt; provided in &lt;code&gt;args&lt;/code&gt;. &lt;code&gt;user&lt;/code&gt; has the &lt;code&gt;UserType&lt;/code&gt; so when it returns a user, it will return 6 fields including &lt;code&gt;posts&lt;/code&gt; and &lt;code&gt;hobbies&lt;/code&gt; of this user. &lt;code&gt;posts&lt;/code&gt; and &lt;code&gt;hobbies&lt;/code&gt; are generated in UserType itself and not by we define &lt;code&gt;posts&lt;/code&gt; and &lt;code&gt;hobbies&lt;/code&gt; in RootQuery. These two are also different.  &lt;/p&gt;

&lt;p&gt;That is it for RootQuery. By this time, if you have data stored in MongoDB you will be able to test your GraphQL API using localhost, on how to actually call your GraphQL API I recommend you watch &lt;a href="https://www.youtube.com/watch?v=0ZJI4cBS4JM" rel="noopener noreferrer"&gt;15 mins tutorial&lt;/a&gt; since it really time-consuming for me to explain it here. &lt;/p&gt;

&lt;h4&gt;
  
  
  4.Building Mutation:
&lt;/h4&gt;

&lt;p&gt;The same idea with RootQuery. I will only post one method for mutation so you can understand how can you write a Mutation for GraphQLSchema :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;Mutation&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;graphql&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;GraphQLObjectType&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
    &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Mutation&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;fields&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;({&lt;/span&gt;
        &lt;span class="na"&gt;createUser&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;UserType&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="na"&gt;args&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nx"&gt;graphql&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;GraphQLNonNull&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;graphql&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;GraphQLString&lt;/span&gt;&lt;span class="p"&gt;)},&lt;/span&gt;
                &lt;span class="na"&gt;age&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;graphql&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;GraphQLNonNull&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;graphql&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;GraphQLInt&lt;/span&gt;&lt;span class="p"&gt;)},&lt;/span&gt;
                &lt;span class="na"&gt;job&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;graphql&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;GraphQLString&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
            &lt;span class="p"&gt;},&lt;/span&gt;
            &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="nf"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;parent&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;args&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;user&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;User&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
                    &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;args&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                    &lt;span class="na"&gt;age&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;args&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;age&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                    &lt;span class="na"&gt;job&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;args&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;job&lt;/span&gt;
                &lt;span class="p"&gt;});&lt;/span&gt;
                &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;newUser&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;save&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
                &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;newUser&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
            &lt;span class="p"&gt;}&lt;/span&gt;
 &lt;span class="p"&gt;})&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You pass data you need to create a user to &lt;code&gt;args&lt;/code&gt;. Then you create a new user in &lt;code&gt;resolve&lt;/code&gt; and update it using Mongoose. As simple as that you can create a user through interfaces. &lt;/p&gt;

&lt;p&gt;Now you can create more methods like : fetch singleUser, updateUser, deleteUser, createHobby, createPost,... Anything really. After this you can check my github code link below to see if you are right or wrong. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/Tris-909/Graph-QL" rel="noopener noreferrer"&gt;Github Code Base&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;At this point you should be able to : &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Create a Type and define it in RootQuery &lt;/li&gt;
&lt;li&gt;Create methods in Mutation to change your data in your databases&lt;/li&gt;
&lt;li&gt;Fetching and Mutating all the fields in databases successfully through your local-host.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3xrcumzt0eg5wpw703vr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3xrcumzt0eg5wpw703vr.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Be able to fetch infinity fields by jumping between two types in graphql like this : 
&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftql83f2n00la63xzip3z.png" alt="Alt Text"&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;From what you learn from this tutorial. You can start building a server of any application you want as long as you know how your data will look like. If you don't like to build anything at least you can understand how GraphQL works in certain ways. &lt;/p&gt;

&lt;p&gt;--peace--&lt;/p&gt;

</description>
      <category>tutorial</category>
      <category>graphql</category>
      <category>node</category>
    </item>
    <item>
      <title>How I land my first software engineer job as a self-taught developer ?</title>
      <dc:creator>Tran Minh Tri</dc:creator>
      <pubDate>Wed, 17 Mar 2021 03:29:51 +0000</pubDate>
      <link>https://dev.to/tris909/finally-i-have-landed-the-job-as-a-self-taught-developer-3knb</link>
      <guid>https://dev.to/tris909/finally-i-have-landed-the-job-as-a-self-taught-developer-3knb</guid>
      <description>&lt;p&gt;After 1 year and 2 months, I have landed my first job as a developer by just sitting at home and learning how to code on my own.&lt;/p&gt;

&lt;p&gt;Hi everyone, I am Tri Tran - a self-taught developer. Today I will share how I did it, some tips to help you land your first job as a FullStack developer without a degree or any relevant experience. &lt;/p&gt;

&lt;h1&gt;
  
  
  Background Story :
&lt;/h1&gt;

&lt;p&gt;So back then, I am 19 years old. I moved to Australia in 2019 and lived in a small town called Bowen where there are no dev jobs / no University and Colleges. Basically no nothing. &lt;/p&gt;

&lt;p&gt;Cause my temporary visa only allows me to work and study but doesn't allow me to get a loan for university or college and I am 19 years old. It pushes me into a situation where I can't do anything and the only job I can do is McDonald's for a living and I did. &lt;/p&gt;

&lt;p&gt;At this point in my life, I feel really messed up. Everything is wrong and I have this hopeless feeling where I don't know what to do or even how to do it. That moment when you realize there little to nothing you can do to change your life, you realize to achieve what normal people here in Australia achieve like going to university and get a degree to get a basic job. It will cost you 5-6 years and possibly a 70-80k in-depth tuition fee.&lt;/p&gt;

&lt;p&gt;I see myself in the worst state of my life : &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Being broke ( I can't even have money to re-locate even if I land the developer job ). Now you may blame me for not going to work but Bowen is so small that the only place that you can apply for is McDonald's (Literally) and I did go to work there but they don't even allow you to work full-time even if I want to simply because they need a person to fill in the gap.&lt;/li&gt;
&lt;/ul&gt;



&lt;ul&gt;
&lt;li&gt;No background or a degree: I can't afford it in any way. Trying to teach yourself at home and compete with people who have a degree and maybe commercial experience is harder than anything else.&lt;/li&gt;
&lt;/ul&gt;



&lt;ul&gt;
&lt;li&gt;No Industry Experience. &lt;/li&gt;
&lt;/ul&gt;



&lt;ul&gt;
&lt;li&gt;Living in a rural area where there are no dev jobs. There are many jobs that required you to go to the office. If you live outside of the city where the office is based, you won't even be considered at all.&lt;/li&gt;
&lt;/ul&gt;



&lt;ul&gt;
&lt;li&gt;Doing all of this stuff in the second language. &lt;/li&gt;
&lt;/ul&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi1.wp.com%2Fwww.mindfulnessmuse.com%2Fwp-content%2Fuploads%2F2011%2F07%2F3-Reasons-People-Choose-to-Depress.jpg%3Fw%3D640%26ssl%3D1" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi1.wp.com%2Fwww.mindfulnessmuse.com%2Fwp-content%2Fuploads%2F2011%2F07%2F3-Reasons-People-Choose-to-Depress.jpg%3Fw%3D640%26ssl%3D1" alt="Depress"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now all of these are crazy hard for me to getting the job but I haven't talked about my personal problems in life. &lt;/p&gt;

&lt;p&gt;Believe me, I don't want to tell you how bad the situation is just to turn myself to become a hero of some kind. I am depressed and I have people who are ready to blame me for that. What I am trying to highlight here is that I believe you too can become a Software Developer if you are not in a situation as bad as me. &lt;/p&gt;

&lt;p&gt;So at this point, I decided to step up my game and this is where the journey starts. &lt;/p&gt;

&lt;p&gt;I studied like crazy. Doing everything I could to get ahead of myself. Failed hundred of times.&lt;/p&gt;

&lt;p&gt;After 400+ applications, 10+ interviews, and endless hours of learning how to code. I have landed the job as a FullStack Developer and set myself to the first step of success in life. &lt;/p&gt;

&lt;p&gt;The interview was nearly 3 hours. I have 2 separated ZOOM interviews with the Head of Engineering of the company and Lead Developer and everything went well. Originally, the CEO is looking for someone who has mid-senior experience. But after the interview, they like me so much that open a junior job exclusively for me and it turns out to be the happiest day of my life.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwww.becomingminimalist.com%2Fwp-content%2Fuploads%2F2019%2F09%2Fhow-to-be-happy.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwww.becomingminimalist.com%2Fwp-content%2Fuploads%2F2019%2F09%2Fhow-to-be-happy.jpg" alt="Happy"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  My advice to help you land your first job as a developer
&lt;/h1&gt;

&lt;p&gt;So I will share with everybody things that will definitely help you on your journey regardless of your situation : &lt;/p&gt;

&lt;h2&gt;
  
  
  Being disciplined:
&lt;/h2&gt;

&lt;p&gt;You have to put down at least &lt;strong&gt;7-8 hours EVERY SINGLE DAY&lt;/strong&gt;. Now a lot of people may have a degree, they may have a network to help them land their first job but a lot of folks out there have nothing and it's okay. This is why you need that time to work on yourself to separate yourself from anyone else.&lt;/p&gt;

&lt;h2&gt;
  
  
  Knowing what you need to know and find a good resource:
&lt;/h2&gt;

&lt;p&gt;Before deciding on what to learn. &lt;strong&gt;Looking into what jobs you want to apply for and take note that what skills keep popping up&lt;/strong&gt; all the time. Then go to Udemy just buy the best course related to that skills and start studying. That is as simple as that. You don't need to follow any road map whatsoever don't confuse yourself when you first starting out because these days we just have too many technologies. &lt;/p&gt;

&lt;h2&gt;
  
  
  Applying for jobs in the early state:
&lt;/h2&gt;

&lt;p&gt;Job hunting is tired and even worse for someone who trying to land their first job as a developer. Originally, If you are someone who is kinda normal right? no degree - no exp - no nothing. &lt;strong&gt;You want to put yourself out there as soon as possible&lt;/strong&gt;. You may fail and that is okay, that is where you learn from and know where you need to improve. You may never know what you may achieve if you never do it. &lt;/p&gt;

&lt;h2&gt;
  
  
  Understand the market and know your situation :
&lt;/h2&gt;

&lt;p&gt;This sounds harsh but hears me out. I see a lot of people are rushing way too fast. They are spending a lot so they are in debt of college or university. They even pay more for Bootcamp and then feel desperate when they don't see the result after 3-6 months. In reality, that should be how it is. People coming from all backgrounds and there are people with many privileges: people can go to university their family pays for it, people live in the biggest city where all the jobs around, people have been coding since they are 14 and there are so many more. &lt;strong&gt;Don't compare yourself to others, compare yourself to you yesterday. Give yourself time to fail and learn&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;The current job market is &lt;strong&gt;SATURATED&lt;/strong&gt; with junior developer like you and me. Literally, I have the ZOOM interview with one of the companies I have applied for, and one day I open my Gmail to see that job has more than 100 applications for a single platform. And you will see this job on so many platforms. So there will be a few hundred people for a single job and this is real. So even if you fail, you should know that it is okay and usually that is should how it is. &lt;/p&gt;

&lt;h2&gt;
  
  
  Having skills but also make yourself stand out:
&lt;/h2&gt;

&lt;p&gt;If you don't have a Github account full of contributions.&lt;br&gt;
If you don't have a beautiful portfolio.&lt;br&gt;
If you don't have a resume that has all the skills listed in the job requirements.&lt;br&gt;
If you don't build a personal project that unique and big and aligned with the company tech stacks.&lt;/p&gt;

&lt;p&gt;Most likely you will fail and never get a callback even if you have a degree. This field is competitive as hell and Coding Bootcamps are rising like fungus. To be able to make yourself stands out as a junior developer. Knowing the skills is not enough. You have to have all the things above. &lt;/p&gt;

&lt;h2&gt;
  
  
  Never Give Up.
&lt;/h2&gt;

&lt;p&gt;This is the most important thing. &lt;strong&gt;You will fail hard&lt;/strong&gt;, you will want to give up on coding. It will happen. The thing is how quickly can you come back to the game. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;People around you don't believe in you? &lt;br&gt;
It's okay. You can believe in yourself. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Your situation is dire? &lt;br&gt;
It's okay. Work harder.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;No matters what you are doing just don't give up. Eventually, you will be able to do it. It is the mindset that helps you grow. Knowing that it's okay as long as you try and believe in yourself.&lt;/p&gt;

&lt;h3&gt;
  
  
  My Portfolio and Resume that helps me to land my job :
&lt;/h3&gt;

&lt;p&gt;Enough for advice, I know you guys need to see a real resume and real portfolio that helps me land my first job. That would be so much better than just words. So here it is :&lt;/p&gt;

&lt;p&gt;This is my portfolio link : &lt;a href="https://tranminhtri.com/" rel="noopener noreferrer"&gt;Tri Tran&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is my resume : &lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F02tmo479xonjwwh7dmz2.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F02tmo479xonjwwh7dmz2.PNG" alt="MyResume"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Alright guys, Thank you for reading. I just want to write my first blog and share my story on how I land my first job. Also give out some advice for someone who is trying to land one. That's it. &lt;/p&gt;

&lt;p&gt;--Peace--&lt;/p&gt;

</description>
      <category>career</category>
      <category>selftaught</category>
      <category>junior</category>
    </item>
  </channel>
</rss>
