update example apps for uniform deployment (#1105)

This commit is contained in:
Shahidh K Muhammed 2018-11-26 18:27:52 +05:30 committed by GitHub
parent 8df23ad6c9
commit ad2c911301
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
63 changed files with 582 additions and 83 deletions

View File

@ -1,23 +1,14 @@
FROM node:carbon
FROM node:carbon as builder
ENV NODE_ENV=PRODUCTION
ENV REACT_APP_CALLBACK_URL=https://react-apollo-todo-demo.hasura.app/callback
# Create app directory
WORKDIR /app
# Install app dependencies
RUN npm -g install serve
# A wildcard is used to ensure both package.json AND package-lock.json are copied
COPY package*.json ./
RUN npm install
# Bundle app source
COPY package.json ./
RUN npm install --production
COPY . .
#Build react/vue/angular bundle static files
RUN npm run build
EXPOSE 8080
# serve dist folder on port 8080
CMD ["serve", "-s", "build", "-p", "8080"]
FROM node:8-alpine
RUN npm -g install serve
WORKDIR /app
COPY --from=builder /app/build .
CMD ["serve", "-s", "-p", "8080"]

View File

@ -0,0 +1,16 @@
## Todo GraphQL Migrations
Update config.yaml to point to the right graphql-engine endpoint with/without access_key.
Run the following commands:
```
$ hasura migrate apply
```
This will apply the migrations.
```
$ hasura metadata apply
```
This will apply the graphql-engine metadata.

View File

@ -0,0 +1 @@
endpoint: http://localhost:8080

View File

@ -0,0 +1,167 @@
--
-- PostgreSQL database dump
--
-- Dumped from database version 10.5 (Debian 10.5-1.pgdg90+1)
-- Dumped by pg_dump version 10.1
-- Started on 2018-10-08 16:36:23 IST
SET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SET check_function_bodies = false;
SET client_min_messages = warning;
SET row_security = off;
SET search_path = public, pg_catalog;
SET default_tablespace = '';
SET default_with_oids = false;
--
-- TOC entry 213 (class 1259 OID 24585)
-- Name: users; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE users (
id integer NOT NULL,
name text,
auth0_id text NOT NULL,
created_at timestamp with time zone DEFAULT now() NOT NULL,
last_seen timestamp with time zone DEFAULT now() NOT NULL
);
--
-- TOC entry 214 (class 1259 OID 24593)
-- Name: online_users; Type: VIEW; Schema: public; Owner: -
--
CREATE VIEW online_users AS
SELECT users.name,
users.last_seen
FROM users
WHERE (users.last_seen >= (now() - '00:00:30'::interval));
--
-- TOC entry 212 (class 1259 OID 24576)
-- Name: todos; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE todos (
id integer NOT NULL,
text text NOT NULL,
is_completed boolean DEFAULT false NOT NULL,
created_at timestamp with time zone DEFAULT now() NOT NULL,
updated_at timestamp with time zone,
is_public boolean DEFAULT false NOT NULL,
user_id text NOT NULL
);
--
-- TOC entry 215 (class 1259 OID 24597)
-- Name: todos_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE todos_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- TOC entry 2981 (class 0 OID 0)
-- Dependencies: 215
-- Name: todos_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE todos_id_seq OWNED BY todos.id;
--
-- TOC entry 216 (class 1259 OID 24599)
-- Name: users_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE users_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- TOC entry 2982 (class 0 OID 0)
-- Dependencies: 216
-- Name: users_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE users_id_seq OWNED BY users.id;
--
-- TOC entry 2839 (class 2604 OID 24612)
-- Name: todos id; Type: DEFAULT; Schema: public; Owner: -
--
ALTER TABLE ONLY todos ALTER COLUMN id SET DEFAULT nextval('todos_id_seq'::regclass);
--
-- TOC entry 2842 (class 2604 OID 24613)
-- Name: users id; Type: DEFAULT; Schema: public; Owner: -
--
ALTER TABLE ONLY users ALTER COLUMN id SET DEFAULT nextval('users_id_seq'::regclass);
--
-- TOC entry 2844 (class 2606 OID 24604)
-- Name: todos todos_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY todos
ADD CONSTRAINT todos_pkey PRIMARY KEY (id);
--
-- TOC entry 2846 (class 2606 OID 24606)
-- Name: users users_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY users
ADD CONSTRAINT users_pkey PRIMARY KEY (auth0_id);
--
-- TOC entry 2847 (class 2606 OID 24607)
-- Name: todos todos_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY todos
ADD CONSTRAINT todos_user_id_fkey FOREIGN KEY (user_id) REFERENCES users(auth0_id);
--
-- TOC entry 2980 (class 0 OID 0)
-- Dependencies: 4
-- Name: public; Type: ACL; Schema: -; Owner: -
--
-- Completed on 2018-10-08 16:36:25 IST
--
-- PostgreSQL database dump complete
--

View File

@ -0,0 +1,129 @@
- type: replace_metadata
args:
query_templates: []
tables:
- array_relationships:
- comment: null
name: todos
using:
foreign_key_constraint_on:
column: user_id
table: todos
delete_permissions:
- comment: null
permission:
filter:
auth0_id:
_eq: X-HASURA-USER-ID
role: user
event_triggers: []
insert_permissions:
- comment: null
permission:
allow_upsert: true
check:
auth0_id:
_eq: X-HASURA-USER-ID
role: user
object_relationships: []
select_permissions:
- comment: null
permission:
columns:
- name
- created_at
- last_seen
- auth0_id
- id
filter: {}
role: user
table: users
update_permissions:
- comment: null
permission:
columns:
- id
- name
- auth0_id
- created_at
- last_seen
filter:
auth0_id:
_eq: X-HASURA-USER-ID
role: user
- array_relationships: []
delete_permissions:
- comment: null
permission:
filter:
$or:
- is_public:
_eq: "true"
- user_id:
_eq: X-HASURA-USER-ID
role: user
event_triggers: []
insert_permissions:
- comment: null
permission:
allow_upsert: true
check:
$or:
- is_public:
_eq: "true"
- user_id:
_eq: X-HASURA-USER-ID
role: user
object_relationships:
- comment: null
name: user
using:
foreign_key_constraint_on: user_id
select_permissions:
- comment: null
permission:
columns:
- id
- text
- is_completed
- created_at
- updated_at
- is_public
- user_id
filter:
$or:
- is_public:
_eq: "true"
- user_id:
_eq: X-HASURA-USER-ID
role: user
table: todos
update_permissions:
- comment: null
permission:
columns:
- is_completed
- text
- updated_at
filter:
$or:
- is_public:
_eq: "true"
- user_id:
_eq: X-HASURA-USER-ID
role: user
- array_relationships: []
delete_permissions: []
event_triggers: []
insert_permissions: []
object_relationships: []
select_permissions:
- comment: null
permission:
columns:
- name
- last_seen
filter: {}
role: user
table: online_users
update_permissions: []

View File

@ -24,17 +24,17 @@
"react-dom": "^16.5.1",
"react-router": "^4.3.1",
"react-router-dom": "^4.3.1",
"react-scripts": "^1.1.5",
"subscriptions-transport-ws": "^0.9.15"
},
"devDependencies": {
"cypress": "^3.1.0",
"husky": "^1.0.0-rc.15",
"lint-staged": "^7.3.0",
"prettier": "1.14.3",
"react-scripts": "^1.1.5"
"prettier": "1.14.3"
},
"scripts": {
"start": "REACT_APP_CALLBACK_URL=http://localhost:3000/callback react-scripts start",
"start": "react-scripts start",
"build": "react-scripts build",
"test": "cypress run --spec 'cypress/integration/**/**/test.js'",
"cypress": "cypress open",

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

View File

@ -9,7 +9,7 @@
homescreen on Android. See https://developers.google.com/web/fundamentals/engage-and-retain/web-app-manifest/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json">
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.png">
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<link href="https://afeld.github.io/emoji-css/emoji.css" rel="stylesheet">
<link href="https://use.fontawesome.com/releases/v5.0.7/css/all.css" rel="stylesheet" crossorigin="anonymous">
@ -22,7 +22,16 @@
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>React Apollo Todo App</title>
<title>React Apollo Todo App | Powered by Hasura</title>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-129818961-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-129818961-1');
</script>
</head>
<body>
<noscript>

View File

@ -105,7 +105,7 @@ class App extends Component {
<div className="footerWrapper">
<span>
<a
href="https://react-apollo-todo-demo.hasura.app/console"
href="/console"
target="_blank"
rel="noopener noreferrer"
>

View File

@ -45,7 +45,6 @@ export const makeMainRoutes = () => {
}
/>
<Route
exact
path="/callback"
render={props => {
handleAuthentication(props);

View File

@ -1,7 +1,11 @@
export const GRAPHQL_URL =
"https://react-apollo-todo-demo.hasura.app/v1alpha1/graphql";
export const REALTIME_GRAPHQL_URL =
"wss://react-apollo-todo-demo.hasura.app/v1alpha1/graphql";
const HASURA_GRAPHQL_ENGINE_HOSTNAME = window.location.host;
const scheme = (proto) => {
return window.location.protocol === 'https:' ? `${proto}s` : proto;
}
export const GRAPHQL_URL = `${scheme('http')}://${HASURA_GRAPHQL_ENGINE_HOSTNAME}/v1alpha1/graphql`;
export const REALTIME_GRAPHQL_URL = `${scheme('ws')}://${HASURA_GRAPHQL_ENGINE_HOSTNAME}/v1alpha1/graphql`;
export const authClientId = "Fl-hdc6xdYIkok9ynbcL6zoUZPAIdOZN";
export const authDomain = "hasura-react-apollo-todo.auth0.com";
export const callbackUrl = process.env.REACT_APP_CALLBACK_URL;
export const callbackUrl = `${scheme('http')}://${HASURA_GRAPHQL_ENGINE_HOSTNAME}/callback`;

View File

@ -0,0 +1,14 @@
FROM node:carbon as builder
ENV NODE_ENV=PRODUCTION
WORKDIR /app
COPY package.json ./
RUN npm install
COPY . .
RUN npm run build
FROM node:8-alpine
RUN npm -g install serve
WORKDIR /app
COPY --from=builder /app/build .
CMD ["serve", "-s", "-p", "8080"]

View File

@ -0,0 +1 @@
script

View File

@ -0,0 +1 @@
endpoint: https://hasura-realtime-group-chat.herokuapp.com

View File

@ -0,0 +1,3 @@
- args:
sql: DROP TABLE public."user"
type: run_sql

View File

@ -0,0 +1,9 @@
- args:
sql: CREATE TABLE public."user"("id" serial NOT NULL, "username" text NOT NULL
UNIQUE, "last_typed" timestamptz , "last_seen" timestamptz , PRIMARY KEY ("id")
); COMMENT ON TABLE public."user" IS 'This table stores user data'
type: run_sql
- args:
name: user
schema: public
type: add_existing_table_or_view

View File

@ -0,0 +1,3 @@
- args:
sql: DROP TABLE public."message"
type: run_sql

View File

@ -0,0 +1,9 @@
- args:
sql: CREATE TABLE public."message"("id" serial NOT NULL, "username" text NOT NULL,
"text" text NOT NULL, "timestamp" timestamptz NOT NULL DEFAULT now(), PRIMARY
KEY ("id") );
type: run_sql
- args:
name: message
schema: public
type: add_existing_table_or_view

View File

@ -0,0 +1,3 @@
- args:
sql: ALTER TABLE public."message" DROP CONSTRAINT "message_username_fkey"
type: run_sql

View File

@ -0,0 +1,4 @@
- args:
sql: ALTER TABLE public."message" ADD FOREIGN KEY ("username") REFERENCES public."user"
("username")
type: run_sql

View File

@ -0,0 +1,11 @@
- args:
cascade: false
sql: |-
create view "user_online" as
select * from "user"
where "last_typed" > now() - interval '10 seconds';
type: run_sql
- args:
name: user_online
schema: public
type: add_existing_table_or_view

View File

@ -0,0 +1,11 @@
- args:
cascade: false
sql: |-
create view "user_typing" as
select * from "user"
where "last_typed" > now() - interval '4 seconds';
type: run_sql
- args:
name: user_typing
schema: public
type: add_existing_table_or_view

View File

@ -0,0 +1,6 @@
- args:
cascade: false
sql: "CREATE OR REPLACE VIEW public.\"user_online\" AS \n SELECT \"user\".id,\n
\ \"user\".username,\n \"user\".last_typed,\n \"user\".last_seen\n FROM
\"user\"\n WHERE (\"user\".last_seen > (now() - '00:00:10'::interval));"
type: run_sql

View File

@ -0,0 +1,6 @@
- args:
cascade: false
sql: "CREATE OR REPLACE VIEW public.\"user_typing\" AS \n SELECT \"user\".id,\n
\ \"user\".username,\n \"user\".last_typed,\n \"user\".last_seen\n FROM
\"user\"\n WHERE (\"user\".last_typed > (now() - '00:00:02'::interval));"
type: run_sql

View File

@ -1,5 +1,5 @@
{
"name": "react-graphql-boilerplate",
"name": "realtime-group-chat",
"version": "0.1.0",
"private": true,
"dependencies": {

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

View File

@ -9,7 +9,7 @@
homescreen on Android. See https://developers.google.com/web/fundamentals/engage-and-retain/web-app-manifest/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json">
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.png">
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
@ -19,7 +19,16 @@
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>Realtime group chat</title>
<title>Realtime group chat | Powered by Hasura</title>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-129818961-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-129818961-1');
</script>
</head>
<body>
<noscript>

View File

@ -1,11 +1,11 @@
{
"short_name": "React App",
"name": "Create React App Sample",
"short_name": "Realtime Group Chat",
"name": "Realtime Group Chat Powered by Hasura",
"icons": [
{
"src": "favicon.ico",
"src": "favicon.png",
"sizes": "64x64 32x32 24x24 16x16",
"type": "image/x-icon"
"type": "image/x-png"
}
],
"start_url": "./index.html",

View File

@ -100,7 +100,7 @@ class Chat extends React.Component {
<div className="hasura-logo">
<img src="https://graphql-engine-cdn.hasura.io/img/powered_by_hasura_black.svg" onClick={() => window.open("https://hasura.io")} alt="Powered by Hasura"/>
&nbsp; | &nbsp;
<a href="https://hasura-realtime-group-chat.herokuapp.com/console" target="_blank" rel="noopener noreferrer">
<a href="/console" target="_blank" rel="noopener noreferrer">
Backend
</a>
&nbsp; | &nbsp;

View File

@ -10,13 +10,18 @@ import { InMemoryCache } from 'apollo-cache-inmemory';
import { split } from 'apollo-link';
import { getMainDefinition } from 'apollo-utilities';
const GRAPHQL_ENDPOINT = "https://hasura-realtime-group-chat.herokuapp.com/v1alpha1/graphql";
const scheme = (proto) => {
return window.location.protocol === 'https:' ? `${proto}s` : proto;
}
const HASURA_GRAPHQL_ENGINE_HOSTNAME = window.location.host;
export const GRAPHQL_ENDPOINT = `${scheme('http')}://${HASURA_GRAPHQL_ENGINE_HOSTNAME}/v1alpha1/graphql`;
export const WEBSOCKET_ENDPOINT = `${scheme('ws')}://${HASURA_GRAPHQL_ENGINE_HOSTNAME}/v1alpha1/graphql`;
// Make WebSocketLink with appropriate url
const mkWsLink = (uri) => {
const splitUri = uri.split('//');
const subClient = new SubscriptionClient(
'wss://' + splitUri[1],
WEBSOCKET_ENDPOINT,
{ reconnect: true }
);
return new WebSocketLink(subClient);

View File

@ -0,0 +1,14 @@
FROM node:carbon as builder
ENV NODE_ENV=PRODUCTION
WORKDIR /app
COPY package.json ./
RUN npm install --production
COPY . .
RUN npm run build
FROM node:8-alpine
RUN npm -g install serve
WORKDIR /app
COPY --from=builder /app/build .
CMD ["serve", "-p", "8080"]

View File

@ -2,7 +2,6 @@
"name": "realtime-location-app",
"version": "0.1.0",
"private": true,
"homepage": "https://hasura.github.io/realtime-location-app",
"dependencies": {
"apollo-boost": "^0.1.14",
"apollo-cache-inmemory": "^1.2.8",

View File

@ -20,6 +20,15 @@
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>Realtime location app | Hasura</title>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-129818961-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-129818961-1');
</script>
</head>
<body>
<noscript>

View File

@ -48,4 +48,5 @@
.hasura-logo img {
height: 30px;
margin-bottom: 12px;
}

View File

@ -150,19 +150,19 @@ class Vehicle extends Component { constructor() {
<footer className="Vehicle-footer displayFlex">
<div className="container hasura-logo">
<a href="https://hasura.io" target="_blank" rel="noopener noreferrer">
<img src={ hasuraImg } alt="hasura logo" />
<img alt="hasura logo" src="https://graphql-engine-cdn.hasura.io/img/powered_by_hasura_black_200px.png" />
</a>
&nbsp; | &nbsp;
<a href="https://realtime-backend.herokuapp.com/console/data/schema/public" target="_blank" rel="noopener noreferrer">
Database
<a href="/console" target="_blank" rel="noopener noreferrer">
Backend
</a>
&nbsp; | &nbsp;
<a href="https://github.com/hasura/realtime-location-app" target="_blank" rel="noopener noreferrer">
<a href="https://github.com/hasura/graphql-engine/tree/master/community/examples/realtime-location-tracking" target="_blank" rel="noopener noreferrer">
Source
</a>
<div className="footer-small-text">
<span>
(The database resets every 30 minutes)
(The database resets every 24 hours)
</span>
</div>
</div>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 19 KiB

View File

@ -2,10 +2,14 @@
const GOOGLE_API_KEY = process.env.NODE_ENV==='production'? process.env.REACT_APP_GOOGLE_API_KEY : '';
const HASURA_GRAPHQL_URL = 'realtime-backend.herokuapp.com/v1alpha1/graphql';
const HASURA_GRAPHQL_ENGINE_HOSTNAME = window.location.host;
const wsurl = `wss://${ HASURA_GRAPHQL_URL }`;
const httpurl = `https://${ HASURA_GRAPHQL_URL }`;
const scheme = (proto) => {
return window.location.protocol === 'https:' ? `${proto}s` : proto;
}
const wsurl = `${scheme('ws')}://${HASURA_GRAPHQL_ENGINE_HOSTNAME}/v1alpha1/graphql`;
const httpurl = `${scheme('http')}://${HASURA_GRAPHQL_ENGINE_HOSTNAME}/v1alpha1/graphql`;
const HASURA_LOCATION = {
lat: 12.93958,

View File

@ -0,0 +1 @@
node_modules

View File

@ -0,0 +1,14 @@
FROM node:carbon as builder
ENV NODE_ENV=PRODUCTION
WORKDIR /app
COPY package.json ./
RUN npm install --production
COPY . .
RUN npm run build
FROM node:8-alpine
RUN npm -g install serve
WORKDIR /app
COPY --from=builder /app/build .
CMD ["serve", "-p", "8080"]

View File

@ -10,7 +10,6 @@ SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SELECT pg_catalog.set_config('search_path', '', false);
SET check_function_bodies = false;
SET client_min_messages = warning;
SET row_security = off;

View File

@ -10,7 +10,6 @@ SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SELECT pg_catalog.set_config('search_path', '', false);
SET check_function_bodies = false;
SET client_min_messages = warning;
SET row_security = off;
@ -19,18 +18,18 @@ SET row_security = off;
-- Data for Name: poll; Type: TABLE DATA; Schema: public; Owner: -
--
INSERT INTO public.poll (id, created_at, created_by, question) VALUES ('98277113-a7a2-428c-9c8b-0fe7a91bf42c', '2018-08-16 12:35:44.202376+00', NULL, 'Who''ll win the Men''s Singles Championship at US Open 2018?');
INSERT INTO public.poll (id, created_at, created_by, question) VALUES ('98277113-a7a2-428c-9c8b-0fe7a91bf42c', '2018-08-16 12:35:44.202376+00', NULL, 'What''s your favourite frontend framework?');
--
-- Data for Name: option; Type: TABLE DATA; Schema: public; Owner: -
--
INSERT INTO public.option (id, poll_id, text) VALUES ('c44f6201-8095-421c-bfcd-b9eb8713ca84', '98277113-a7a2-428c-9c8b-0fe7a91bf42c', 'Roger Federer');
INSERT INTO public.option (id, poll_id, text) VALUES ('88b78394-cdab-4b5c-a59a-0ed90c4848cf', '98277113-a7a2-428c-9c8b-0fe7a91bf42c', 'Rafael Nadal');
INSERT INTO public.option (id, poll_id, text) VALUES ('1c6477bc-fb30-4eb8-b7a2-c6855da8a4f1', '98277113-a7a2-428c-9c8b-0fe7a91bf42c', 'Juan Martín del Potro');
INSERT INTO public.option (id, poll_id, text) VALUES ('10710f03-3124-42ac-a9bd-eb8d4661657f', '98277113-a7a2-428c-9c8b-0fe7a91bf42c', 'Novak Djokovic');
INSERT INTO public.option (id, poll_id, text) VALUES ('3d10e209-e906-4849-92cd-88bdd18f5b63', '98277113-a7a2-428c-9c8b-0fe7a91bf42c', 'Alexander Zverev');
INSERT INTO public.option (id, poll_id, text) VALUES ('c44f6201-8095-421c-bfcd-b9eb8713ca84', '98277113-a7a2-428c-9c8b-0fe7a91bf42c', 'React');
INSERT INTO public.option (id, poll_id, text) VALUES ('88b78394-cdab-4b5c-a59a-0ed90c4848cf', '98277113-a7a2-428c-9c8b-0fe7a91bf42c', 'Vue');
INSERT INTO public.option (id, poll_id, text) VALUES ('1c6477bc-fb30-4eb8-b7a2-c6855da8a4f1', '98277113-a7a2-428c-9c8b-0fe7a91bf42c', 'Angular');
INSERT INTO public.option (id, poll_id, text) VALUES ('10710f03-3124-42ac-a9bd-eb8d4661657f', '98277113-a7a2-428c-9c8b-0fe7a91bf42c', 'Ember');
INSERT INTO public.option (id, poll_id, text) VALUES ('3d10e209-e906-4849-92cd-88bdd18f5b63', '98277113-a7a2-428c-9c8b-0fe7a91bf42c', 'vanilla-js.com');
--

View File

@ -1,6 +1,5 @@
{
"name": "hasura-realtime-poll",
"homepage": "https://shahidhk.github.io/hasura-realtime-poll",
"version": "0.1.0",
"private": true,
"dependencies": {

View File

@ -22,6 +22,15 @@
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<title>Realtime Poll | Powered by Hasura GraphQL Engine</title>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-129818961-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-129818961-1');
</script>
</head>
<body>
<noscript>

View File

@ -106,3 +106,7 @@ pre
display: block;
}
}
.hasura-logo img {
margin-bottom: 12px;
}

View File

@ -5,7 +5,6 @@ import { ApolloProvider } from 'react-apollo';
import client, {HASURA_GRAPHQL_ENGINE_HOSTNAME} from './apollo';
import Poll from './Poll';
import { getUserId } from './session';
import hasura_logo from './img/hasura_logo_200.png';
import { GraphQL } from './GraphQL';
class App extends Component {
@ -21,7 +20,6 @@ class App extends Component {
}
render() {
const consoleURL = `https://${HASURA_GRAPHQL_ENGINE_HOSTNAME}/console/data/schema/public`;
if (this.state.loading) return <p>Loading...</p>;
return (
<ApolloProvider client={client}>
@ -42,11 +40,11 @@ class App extends Component {
<footer className="App-footer displayFlex">
<div className="container hasura-logo">
<a href="https://hasura.io" target="_blank" rel="noopener noreferrer">
<img alt="hasura logo" src={hasura_logo} />
<img className="hasura-logo" alt="hasura logo" src="https://graphql-engine-cdn.hasura.io/img/powered_by_hasura_black_200px.png" />
</a>
&nbsp; | &nbsp;
<a href={consoleURL} target="_blank">
Database
<a href="/console" target="_blank">
Backend
</a>
&nbsp; | &nbsp;
<a href="https://github.com/hasura/graphql-engine/tree/master/community/examples/realtime-poll" target="_blank" rel="noopener noreferrer">

View File

@ -9,10 +9,14 @@ import { getMainDefinition } from 'apollo-utilities';
import { InMemoryCache } from 'apollo-cache-inmemory';
export const HASURA_GRAPHQL_ENGINE_HOSTNAME = 'hasura-realtime-poll.herokuapp.com';
export const HASURA_GRAPHQL_ENGINE_HOSTNAME = window.location.host;
const wsurl = `wss://${HASURA_GRAPHQL_ENGINE_HOSTNAME}/v1alpha1/graphql`;
const httpurl = `https://${HASURA_GRAPHQL_ENGINE_HOSTNAME}/v1alpha1/graphql`;
const scheme = (proto) => {
return window.location.protocol === 'https:' ? `${proto}s` : proto;
}
const wsurl = `${scheme('ws')}://${HASURA_GRAPHQL_ENGINE_HOSTNAME}/v1alpha1/graphql`;
const httpurl = `${scheme('http')}://${HASURA_GRAPHQL_ENGINE_HOSTNAME}/v1alpha1/graphql`;
const wsLink = new WebSocketLink({
uri: wsurl,

View File

@ -0,0 +1,3 @@
FROM nginx:alpine
COPY *.png *.html *.css *.js /usr/share/nginx/html/

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

View File

@ -10,7 +10,6 @@ SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SELECT pg_catalog.set_config('search_path', '', false);
SET check_function_bodies = false;
SET client_min_messages = warning;
SET row_security = off;

View File

@ -10,7 +10,6 @@ SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SELECT pg_catalog.set_config('search_path', '', false);
SET check_function_bodies = false;
SET client_min_messages = warning;
SET row_security = off;

View File

@ -125,3 +125,8 @@ img.algolia_image {
.algolia_search_attribution {
font-size: 0.8em;
}
.hasura-logo img {
height: 30px;
margin-bottom: 12px;
}

View File

@ -16,6 +16,15 @@
<link rel="shortcut icon" type="image/png" href="favicon.png"/>
<title>ETL demo using Hasura GraphQL Engine Event Triggers</title>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-129818961-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-129818961-1');
</script>
</head>
<body class="main">
@ -69,7 +78,7 @@
<div id="pagination"></div>
</main>
<div class="pt-2">
<a href="https://github.com/shahidhk/hasura-serverless-etl#architecture" target="_blank">
<a href="https://github.com/hasura/graphql-engine/tree/master/community/examples/serverless-etl#architecture" target="_blank">
<img class="col-6 img-fluid" src="arch.png" />
</a>
</div>
@ -82,17 +91,17 @@
<div class="main-content">
<div class="hasura-logo">
<a href="https://hasura.io" target="_blank">
Powered by <img src="hasura_logo.png" />
<img class="hasura-logo" alt="hasura logo" src="https://graphql-engine-cdn.hasura.io/img/powered_by_hasura_white_200px.png" />
</a>
&nbsp; | &nbsp;
<a href="#" target="_blank" id="hge-console-link">
Database
<a href="/console" target="_blank" id="hge-console-link">
Backend
</a>
&nbsp; | &nbsp;
<a href="https://github.com/shahidhk/hasura-serverless-etl" target="_blank">
<a href="https://github.com/hasura/graphql-engine/tree/master/community/examples/serverless-etl" target="_blank">
Source
</a>
<!-- <div class="footer-small-text"><span>(The database resets every 30 minutes)</span></div> -->
<div class="footer-small-text"><span>(The database resets every 24 hours)</span></div>
</div>
</div>
</footer>

View File

@ -5,7 +5,7 @@ if (!("Notification" in window)) {
const screens = ['#loading-screen', '#input-screen', '#search-screen'];
// Replace with HGE_URL
const HGE_URL = 'https://hasura-serverless-etl.herokuapp.com/v1alpha1/graphql';
const HGE_URL = '/v1alpha1/graphql';
function showScreen(name) {
for (screen of screens) {

View File

@ -0,0 +1,3 @@
FROM nginx:alpine
COPY *.png *.html *.css *.js *.json /usr/share/nginx/html/

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

View File

@ -10,7 +10,6 @@ SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SELECT pg_catalog.set_config('search_path', '', false);
SET check_function_bodies = false;
SET client_min_messages = warning;
SET row_security = off;

View File

@ -96,4 +96,6 @@ div .error {
to {left: 100%;}
}
.hasura-logo img {
margin-bottom: 12px;
}

View File

@ -13,6 +13,16 @@
<link rel="shortcut icon" type="image/png" href="favicon.png"/>
<title>Push Notifications using Hasura GraphQL Engine Event Triggers</title>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-129818961-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-129818961-1');
</script>
</head>
<body class="main">
@ -77,17 +87,17 @@
<div class="main-content">
<div class="hasura-logo">
<a href="https://hasura.io" target="_blank">
Powered by <img src="hasura_logo.png" />
<img class="hasura-logo" alt="hasura logo" src="https://graphql-engine-cdn.hasura.io/img/powered_by_hasura_white_200px.png" />
</a>
&nbsp; | &nbsp;
<a href="#" target="_blank" id="hge-console-link">
Database
<a href="/console" target="_blank" id="hge-console-link">
Backend
</a>
&nbsp; | &nbsp;
<a href="https://github.com/shahidhk/hasura-web-push-notifs" target="_blank">
<a href="https://github.com/hasura/graphql-engine/tree/master/community/examples/serverless-push" target="_blank">
Source
</a>
<div class="footer-small-text"><span>(The database resets every 30 minutes)</span></div>
<div class="footer-small-text"><span>(The database resets every 24 hours)</span></div>
</div>
</div>
</footer>

View File

@ -5,8 +5,9 @@ if (!("Notification" in window)) {
const messaging = firebase.messaging();
const screens = ['#loading-screen', '#permission-screen', '#input-screen', '#waiting-screen'];
// Replace with HGE_URL
const HGE_URL = 'https://hasura-serverless-push.herokuapp.com/v1alpha1/graphql';
const HGE_URL = '/v1alpha1/graphql';
function showScreen(name) {
for (screen of screens) {