Update readme.

This commit is contained in:
James Harton 2018-04-08 16:24:13 +12:00
parent c20d4b453e
commit 3b8eede7d1

View file

@ -1,26 +1,10 @@
# More extra for experts
# All done.
Our existing subscription only triggers if someone else uses the `importPerson`
mutation to trigger the subscription event - what if we want to let clients know
whenever a row is added to our `people` table? Maybe it's added by another
service, or something.
I hope you've enjoyed our little trip around GraphQL.
In this branch we're using Postgres triggers and stored procedures to send
notifications whenever a row is added to the `people` table and we're using
`Postgrex.Notifications` to subscribe to them. A substantian portion of the
code for this example comes from [this hackernoon post](https://hackernoon.com/get-notified-of-user-signups-and-plan-changes-automatically-using-postgres-phoenix-pubsub-e67d061b04bc).
All code for this talk is available at [gitlab.com/jimsy/graphql-lightning-talk](https://gitlab.com/jimsy/graphql-lightning-talk).
Things to look at:
I'm `@jamesotron` on the [AU/NZ Elixir
Slack](http://aunz-elixir.herokuapp.com/). Feel free to ask me questions there.
* `priv/repo/migrations/20180408032823_broadcast_people_table_changes.exs`
* `lib/faces/gallery/event_listener.ex`
[Demo](http://localhost:4000)
Let's try manually inserting a row (via `psql faces_dev`):
```sql
INSERT INTO "people" ("username", "name", "location", "avatar_url", "inserted_at", "updated_at")
VALUES ('pupper', 'pupper', 'the bath', 'https://media.giphy.com/media/3o6Zt9ved5rCuidNlK/giphy.gif', NOW(), NOW());
```
Next, move on to `step-7`.
## Any questions?