Skip to content

This project is a code along for the Wes Bos Advanced React course (frontend).

Notifications You must be signed in to change notification settings

sjm-practice/sick-fits-frontend

Repository files navigation

Advanced-React

Coding along with Wes Bos' Advanced React Tutorial.

Tech Stack

  • Front end framework: React, Next.js (ssr, routing), Styled Components
  • Front end GraphQL client: React Apollo, Apollo Client
  • Back end GraphQL Server: GraphQL Yoga (express, apollo-server)
  • Back end GraphQL Database: Prisma

Notes

  • Video 14 - Items Creation and Prisma Yoga Flow, is a good reference for setting up new data items (graphql and database)
    • datamodel.graphql: file we create / maintain to define data model for prisma db
      • run deploy after making any changes
    • prisma.graphql: a file generated by prisma, is retrieved by the post deploy hook when datamodel.graphql is deployed to prisma (see package.json deploy script)
      • describes the prisma API for this data
    • schema.graphql: file we create / maintain to define the public facing API
  • GraphQL workflow
    • create mutation or query in schema.graphql
    • create the resolver in Mutation.js or Query.js
    • define gql mutation or query in component
  • using cookie to store logged in user (JWT - json web token) instead of local storage, because that better supports SSR
  • in Signup component, Form component method is set to post, which prevents the password from showing up in the url in error conditions (default method is get, which would)
  • Apollo - Optimistic Response: Apollo provides an optimistic response feature, which allows the developer to provide an expected response from the server mutation
    • this causes the update method to be called twice. once immediately, using the value in optimisticResponse for payload. then called a second time, when the actual server response is received (which uses the actual payload value)

Cool Packages / Components

  • Downshift
  • Stripe / StripeCheckout
  • lodash debounce
  • format-dns -does date formatting, similar to moment.js plus some other stuff (treeshaking?)

Deployment Notes

  • Three things to deploy
    • Primsa Server [Mysql]
    • Yoga Server [node backend: Mutation & Query Resolvers]
    • React App [node / next.js, frontend]

Deployment Steps

  • set up prisma server first
    • start at app.prisma.io (add server)
      • takes you through steps and logging in to Heroku
      • choose Postgres for DB
    • once set up, then deploy prisma to heroku using deploy:heroku script
  • set up yoga server (this is our node backend)
  • TROUBLESHOOTING
    • ran in to a cors issue (between heroku front end and back end)
      • make sure the FRONTEND_URL config setting does not have the '/' on the end

Course Topics

Introduction and Setup

  1. Editor Setup and Starter Files Installation
  2. Sick Fits and the Tech Stack Behind It
  3. An Intro to Next.js, Tooling and Routing
  4. Custom _app.js Layout

CSS and Styled Components

  1. An Intro to Styled Components
  2. Themes and Layout with Styled Components
  3. Global Styling and Typography with Styled Components
  4. Visualizing Route Changes
  5. Fixing Styled Components Flicker on Server Render

Server Side GraphQL

  1. An intro to GraphQL
  2. Getting Setup with Prisma
  3. Getting our GraphQL Yoga Server Running
  4. Our first Query and Mutation
  5. Items Creation and Prisma Yoga Flow

Client Side GraphQL

  1. Setting Up Apollo Client with React
  2. React Meets GraphQL
  3. Creating Items with Mutations
  4. Uploading Images
  5. Updating Items with Queries and Mutations
  6. Deleting Items
  7. Displaying Single Items
  8. Pagination
  9. Pagination and Cache Invalidation

Accounts, Authentication and Permissions

  1. User Signup and Permission Flow
  2. User Signup in React
  3. Currently Logged In User with Middleware and Render Props
  4. Sign in Form and Custom Error Handling
  5. Sign Out Button
  6. Backend Password Reset Flow
  7. Frontend Password Reset Flow
  8. Sending Email
  9. Data Relationships
  10. Creating a Gated Sign In Component
  11. Permissions Management
  12. Updating Permissions in Local State
  13. Updating Permissions on the Server
  14. Locking Down DeleteItem Permissions

Shopping Cart

  1. Creating our cart in React
  2. Apollo Local State Queries and Mutations
  3. Server Side Add To Cart
  4. Displaying Cart Items and Totals
  5. Removing Cart Items
  6. Optimistic Response && Cache Updates with Apollo
  7. Animating our Cart Count Component
  8. Dealing with Deleted Items in CartItems

Advanced UI and Code Quality

  1. Cleaning Up This Render Prop Mess
  2. Search Dropdown Autocomplete
  3. Autocomplete with Downshift

Credit Card Checkout

  1. Credit Card Processing with Stripe Checkout
  2. Charging Cards on the Server Side
  3. Saving Orders to the Database
  4. Displaying Single Orders
  5. Orders Page

Testing

  1. Testing with Jest and Enzyme Introduction
  2. Unit Testing 101
  3. Mocking 101
  4. First Tests and Shallow Rendering
  5. Snapshot Testing
  6. Testing and Mocking Apollo Queries
  7. More Apollo Query Testing
  8. Testing Pagination
  9. Testing Mutations
  10. More Apollo Client Mutation Testing
  11. Testing our Cart
  12. Testing Order Components

Deployment

  1. Deploying a Prisma Server to Heroku
  2. Deploying Yoga Server to Heroku or Now
  3. Deploying Frontend to Heroku and Now

About

This project is a code along for the Wes Bos Advanced React course (frontend).

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published