GithubHelp home page GithubHelp logo

custom-error-pages-graphql's Introduction

Building custom error pages in React with Hasura GraphQL engine

This application is a part of a tutorial on how to handle errors in GraphQl-react applications. Check out the tutorial here. This application demonstrates error handling and implementing custom error pages in a react app using hasura graphQL engine. Uses react-apollo GraphQL client to make requests to the api. Apollo-link-error library is used for error handling.

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.

Error handling

Uses apollo-link-error library, to implement top-level and component-level error handling, with custom error pages, and custom logic at compoenent level to show error notifications.

custom-error-pages-graphql's People

Contributors

abhi40308 avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.