{"id":16193608,"url":"https://github.com/pyramation/graphile-column-select-grants-example","last_synced_at":"2025-04-07T15:19:57.913Z","repository":{"id":66351046,"uuid":"298141092","full_name":"pyramation/graphile-column-select-grants-example","owner":"pyramation","description":null,"archived":false,"fork":false,"pushed_at":"2020-09-24T16:53:16.000Z","size":19,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-13T02:03:51.638Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pyramation.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2020-09-24T01:48:55.000Z","updated_at":"2020-09-29T13:49:36.000Z","dependencies_parsed_at":"2023-02-24T18:00:52.378Z","dependency_job_id":null,"html_url":"https://github.com/pyramation/graphile-column-select-grants-example","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pyramation%2Fgraphile-column-select-grants-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pyramation%2Fgraphile-column-select-grants-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pyramation%2Fgraphile-column-select-grants-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pyramation%2Fgraphile-column-select-grants-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pyramation","download_url":"https://codeload.github.com/pyramation/graphile-column-select-grants-example/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247675597,"owners_count":20977378,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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-10-10T08:15:46.462Z","updated_at":"2025-04-07T15:19:57.891Z","avatar_url":"https://github.com/pyramation.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# graphile-mutation-example\n\nexample for \nhttps://github.com/pyramation/graphile-column-privileges-mutations\n\n## seed db\n\n```sh\ncreatedb mutation_example\npsql mutation_example \u003c roles.sql\npsql mutation_example \u003c user.sql\npsql mutation_example \u003c schema.sql\n```\n\n## run server\n\n```sh\nyarn \u0026\u0026 yarn run app_user\n```\n\n## open exporer\n\nopen http://localhost:5678/graphiql\n\nExample of creating a user\n\n```gql\nmutation CreateUserMutation {\n  createUser(\n    input: {\n      user: {\n        email: \"pyramation@example.com\"\n        username: \"pyramation\"\n        password:\"password\"\n      }\n    }\n  ) {\n    user {\n      id\n      username\n      email \n    }\n  }\n}\n```\n\nwhich returns happily\n\n```json\n{\n  \"data\": {\n    \"createUser\": {\n      \"user\": {\n        \"id\": 5,\n        \"username\": \"pyramation\",\n        \"email\": \"pyramation@example.com\"\n      }\n    }\n  }\n}\n```\n\nNow querying a field that you are not able to\n\n```gql\nmutation CreateUserMutation {\n  createUser(\n    input: {\n      user: {\n        email: \"pyramation@example.com\"\n        username: \"pyramation\"\n        password:\"password\"\n      }\n    }\n  ) {\n    user {\n      id\n      username\n      email \n      password\n    }\n  }\n}\n```\n\nand you get a permission denied error\n\n```json\n{\n  \"errors\": [\n    {\n      \"message\": \"permission denied for table users\",\n      \"locations\": [\n        {\n          \"line\": 2,\n          \"column\": 3\n        }\n      ],\n      \"path\": [\n        \"createUser\"\n      ]\n    }\n  ],\n  \"data\": {\n    \"createUser\": null\n  }\n}\n```\n\n## notes\n\nYou must run as the `app_user` in order for the privileges to work, otherwise you ultimately end up running as the postgres user or the owner of the table who by default has privileges, and hence will bypass the column grants.\n\n```sh\nyarn run app_user\n```\n\nIf you want, for some reason to use an admin user, we've included this for testing purposes:\n\n```sh\nyarn run admin_user\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpyramation%2Fgraphile-column-select-grants-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpyramation%2Fgraphile-column-select-grants-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpyramation%2Fgraphile-column-select-grants-example/lists"}