Skip to content
Hackernews clone using apollo, react and hasura-graphQl
JavaScript HTML CSS
Branch: master
Clone or download
Latest commit 302c2e7 Aug 30, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
public implemented submit, user profile Aug 16, 2019
src deploy Aug 30, 2019
.gitignore Initial commit from Create React App Aug 1, 2019
README.md Update README.md Aug 30, 2019
package-lock.json deploy Aug 30, 2019
package.json deploy Aug 30, 2019

README.md

HackerNews Clone using React, Apollo-React-Client and Hasura GraphQl Engine

Live Demo
This application demonstrates consuming GraphQl Api provided by Hasura GraphQL Engine using a react app. Uses react-apollo GraphQL client to make requests to the api. Users can create account using Auth0 JWT authentication which is then verified by Hasura. React-router is used to provide SPA experience.

Authenticated users can:

  • Create new posts
  • Upvote posts
  • Realtime updates when other users upvote a post or create a new one (updating apollo cache).

Installation

Installing and running on local system require:

  • Setting up Hasura Server (deployed on Heroku), and creating required tables
  • Setting up Auth0
  • See this guide for Auth0 JWT Integration with Hasura
  • Clone or download this repo, install the required packages and run npm start

npm packages:

You will need the following npm packages:

Creating tables

Following tables required to be created:

type Post {
id - integer, primary key
description - text
url - text
created_at - timestamp with time zone
user_id - text
}

type Users {
name - text 
last_seen - timestamp with time zone
id - text, primary key
}

type Point {
id - integer, primary key
user_id - text
post_id - integer
}

Post.user_id and Users.id have object relationship. Point.post_id and Post.id have array relationship. Permissions should be given accordingly.

User Authentication

See Setting up Auth0 with react and this guide for Auth0 JWT Integration with Hasura. Here we are using Auth0 Universal Login.

Realtime updates

Using apollo cache and react state, we can give realtime updates for upvotes and new posts. Apollo refetchQueries function updates apollo cache with refetched data.

You can’t perform that action at this time.