2019-01-17 13:27:28 +03:00
|
|
|
# hasura-realtime-poll
|
|
|
|
|
|
|
|
A demo application to showcase real-time capabilities of [Hasura GraphQL
|
|
|
|
Engine](https://github.com/hasura/graphql-engine).
|
|
|
|
|
2019-06-14 12:07:00 +03:00
|
|
|
[![Edit realtime-poll](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/github/hasura/graphql-engine/tree/master/community/sample-apps/realtime-poll?fontsize=14)
|
|
|
|
|
2019-01-17 13:27:28 +03:00
|
|
|
The Realtime Poll application is built using React and is powered by Hasura
|
|
|
|
GraphQL Engine over Postgres. It has an interface for users to cast vote on a
|
|
|
|
poll and the results are updated in the on-screen bar chart, in real-time.
|
|
|
|
|
|
|
|
The application makes use of Hasura GraphQL Engine's real-time capabilities
|
|
|
|
using `subscription`. There is no backend code involved. The application is
|
|
|
|
hosted on GitHub pages and the Postgres+GraphQL Engine is running on Postgres.
|
|
|
|
|
|
|
|
- Checkout the [live app](https://realtime-poll.demo.hasura.app/).
|
|
|
|
- Explore the backend using [Hasura
|
2021-03-02 11:31:35 +03:00
|
|
|
Console](https://realtime-poll.hasura.app/console).
|
2019-01-17 13:27:28 +03:00
|
|
|
|
|
|
|
# Running the app yourself
|
|
|
|
|
2021-03-02 11:31:35 +03:00
|
|
|
- Deploy GraphQL Engine on Hasura Cloud and setup PostgreSQL via Heroku:
|
2019-01-17 13:27:28 +03:00
|
|
|
|
2021-03-02 11:31:35 +03:00
|
|
|
[![Deploy to Hasura Cloud](https://graphql-engine-cdn.hasura.io/img/deploy_to_hasura.png)](https://cloud.hasura.io/)
|
|
|
|
- Get the Hasura app URL (say `realtime-poll.hasura.app`)
|
2019-01-17 13:27:28 +03:00
|
|
|
- Clone this repo:
|
|
|
|
```bash
|
|
|
|
git clone https://github.com/hasura/graphql-engine
|
2019-08-14 10:05:44 +03:00
|
|
|
cd graphql-engine/community/sample-apps/realtime-poll
|
2019-01-17 13:27:28 +03:00
|
|
|
```
|
2021-03-01 21:50:24 +03:00
|
|
|
- [Install Hasura CLI](https://hasura.io/docs/latest/graphql/core/hasura-cli/install-hasura-cli.html)
|
2019-01-17 13:27:28 +03:00
|
|
|
- Goto `hasura/` and edit `config.yaml`:
|
|
|
|
```yaml
|
2021-03-02 11:31:35 +03:00
|
|
|
endpoint: https://realtime-poll.hasura.app
|
2019-01-17 13:27:28 +03:00
|
|
|
```
|
|
|
|
- Apply the migrations:
|
|
|
|
```bash
|
|
|
|
hasura migrate apply
|
|
|
|
```
|
|
|
|
- Edit `HASURA_GRAPHQL_ENGINE_HOSTNAME` in `src/apollo.js` and set it to the
|
2021-03-02 11:31:35 +03:00
|
|
|
Hasura app URL:
|
2019-01-17 13:27:28 +03:00
|
|
|
```js
|
2021-03-02 11:31:35 +03:00
|
|
|
export const HASURA_GRAPHQL_ENGINE_HOSTNAME = 'realtime-poll.hasura.app';
|
2019-01-17 13:27:28 +03:00
|
|
|
```
|
|
|
|
- Run the app (go the root of repo):
|
|
|
|
```bash
|
|
|
|
npm install
|
|
|
|
npm start
|
|
|
|
```
|