{"id":20253682,"url":"https://github.com/graphile/demo","last_synced_at":"2026-03-05T18:34:23.436Z","repository":{"id":88402959,"uuid":"184646740","full_name":"graphile/demo","owner":"graphile","description":"This is a simple demo project that Benjie uses during presentations.","archived":false,"fork":false,"pushed_at":"2019-05-07T08:42:11.000Z","size":21,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-03T17:12:48.729Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"PLpgSQL","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/graphile.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-05-02T20:25:34.000Z","updated_at":"2019-05-07T08:42:12.000Z","dependencies_parsed_at":null,"dependency_job_id":"c5a2b4d3-5ef8-467c-a765-78102e325f5c","html_url":"https://github.com/graphile/demo","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/graphile/demo","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/graphile%2Fdemo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/graphile%2Fdemo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/graphile%2Fdemo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/graphile%2Fdemo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/graphile","download_url":"https://codeload.github.com/graphile/demo/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/graphile%2Fdemo/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30142735,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-05T16:58:46.102Z","status":"ssl_error","status_checked_at":"2026-03-05T16:58:45.706Z","response_time":93,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-14T10:26:57.101Z","updated_at":"2026-03-05T18:34:23.420Z","avatar_url":"https://github.com/graphile.png","language":"PLpgSQL","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PostGraphile simple example\n\nThis is a simple demo project that I ([@benjie](https://twitter.com/benjie))\nuse during some presentations. It is not intended to be a full example of how\nto use PostGraphile; better places to look are [the\ndocs](https://www.graphile.org/postgraphile/), or the [bootstrap-react-apollo\nrepo](https://github.com/graphile/bootstrap-react-apollo).\n\n## Setup:\n\nFirst we need to install all the dependencies with `yarn`. (If you don't have\nyarn installed, you can install it with `npm install -g yarn`.)\n\nThen we need to create a `graphile_example` repo, an unprivileged `graphql`\ndatabase role, and load `schema.sql` into this `graphile_example` repo.  All of\nthis is handled for us by the `yarn setup` command.\n\nFinally we run `postgraphile` in watch mode.\n\n```\nyarn\nyarn setup\n./node_modules/.bin/postgraphile --watch\n```\n\n## The demo\n\nCopy and paste chunks from `demo.sql` into the database as you go. To open a\nconnection to the database, run:\n\n```\npsql graphile_example\n```\n\n## Jump to the end\n\nIf you prefer to load everything up front rather than step-by-step, you can\ninstall everything in the demo with this one command:\n\n```\npsql -Xv ON_ERROR_STOP=1 -f demo.sql graphile_example\n```\n\n## Smoke and mirrors\n\nSettings are loaded from `.postgraphilerc.js` to avoid having to write too many\nCLI flags. The various options that we used are documented in that file.\n\nThe `current_user_id()` function just returns the static number `1`. In a real app\nyou'd replace this with something like:\n\n```sql\ncreate or replace function current_user_id() returns int as $$\n  select nullif(current_setting('jwt.claims.user_id', true), '')::int;\n$$ language sql stable;\n```\n\n(Note that `jwt.claims.user_id` is only an example, you can substitute\nauthentication with whatever you like.)\n\nIf you're concerned your database connection string could ever be leaked,\nyou might go with something a bit more paranoid, such as:\n\n```sql\ncreate or replace function current_user_id() returns int as $$\n  select user_id\n  from app_private.sessions\n  where secret = nullif(current_setting('jwt.claims.session_secret', true), '')::uuid;\n$$ language sql stable;\n```\n\nTo read more, see [our Row Level Security\ninfosheet](https://learn.graphile.org/docs/PostgreSQL_Row_Level_Security_Infosheet.pdf),\nour [JWT security guide](https://www.graphile.org/postgraphile/security/), or\nthe [passport.js implementation in the bootstrap\nrepo](https://github.com/graphile/bootstrap-react-apollo/blob/65ce5333a3213c3abf48fd3bd5ec412f9484485c/server/middleware/installPostGraphile.js#L152-L188).\n\n## Cleanup:\n\nTo delete the database and the user, run:\n\n```\nyarn cleanup\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgraphile%2Fdemo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgraphile%2Fdemo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgraphile%2Fdemo/lists"}