{"action":"created","issue":{"url":"https://api.github.com/repos/maticzav/graphql-shield/issues/60","repository_url":"https://api.github.com/repos/maticzav/graphql-shield","labels_url":"https://api.github.com/repos/maticzav/graphql-shield/issues/60/labels{/name}","comments_url":"https://api.github.com/repos/maticzav/graphql-shield/issues/60/comments","events_url":"https://api.github.com/repos/maticzav/graphql-shield/issues/60/events","html_url":"https://github.com/maticzav/graphql-shield/issues/60","id":333047002,"node_id":"MDU6SXNzdWUzMzMwNDcwMDI=","number":60,"title":"Custom errors for rules and global fallback","user":{"login":"kolybasov","id":3891873,"node_id":"MDQ6VXNlcjM4OTE4NzM=","avatar_url":"https://avatars0.githubusercontent.com/u/3891873?v=4","gravatar_id":"","url":"https://api.github.com/users/kolybasov","html_url":"https://github.com/kolybasov","followers_url":"https://api.github.com/users/kolybasov/followers","following_url":"https://api.github.com/users/kolybasov/following{/other_user}","gists_url":"https://api.github.com/users/kolybasov/gists{/gist_id}","starred_url":"https://api.github.com/users/kolybasov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kolybasov/subscriptions","organizations_url":"https://api.github.com/users/kolybasov/orgs","repos_url":"https://api.github.com/users/kolybasov/repos","events_url":"https://api.github.com/users/kolybasov/events{/privacy}","received_events_url":"https://api.github.com/users/kolybasov/received_events","type":"User","site_admin":false},"labels":[{"id":834267978,"node_id":"MDU6TGFiZWw4MzQyNjc5Nzg=","url":"https://api.github.com/repos/maticzav/graphql-shield/labels/enhancement","name":"enhancement","color":"a2eeef","default":true}],"state":"open","locked":false,"assignee":{"login":"maticzav","id":3924224,"node_id":"MDQ6VXNlcjM5MjQyMjQ=","avatar_url":"https://avatars2.githubusercontent.com/u/3924224?v=4","gravatar_id":"","url":"https://api.github.com/users/maticzav","html_url":"https://github.com/maticzav","followers_url":"https://api.github.com/users/maticzav/followers","following_url":"https://api.github.com/users/maticzav/following{/other_user}","gists_url":"https://api.github.com/users/maticzav/gists{/gist_id}","starred_url":"https://api.github.com/users/maticzav/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maticzav/subscriptions","organizations_url":"https://api.github.com/users/maticzav/orgs","repos_url":"https://api.github.com/users/maticzav/repos","events_url":"https://api.github.com/users/maticzav/events{/privacy}","received_events_url":"https://api.github.com/users/maticzav/received_events","type":"User","site_admin":false},"assignees":[{"login":"maticzav","id":3924224,"node_id":"MDQ6VXNlcjM5MjQyMjQ=","avatar_url":"https://avatars2.githubusercontent.com/u/3924224?v=4","gravatar_id":"","url":"https://api.github.com/users/maticzav","html_url":"https://github.com/maticzav","followers_url":"https://api.github.com/users/maticzav/followers","following_url":"https://api.github.com/users/maticzav/following{/other_user}","gists_url":"https://api.github.com/users/maticzav/gists{/gist_id}","starred_url":"https://api.github.com/users/maticzav/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maticzav/subscriptions","organizations_url":"https://api.github.com/users/maticzav/orgs","repos_url":"https://api.github.com/users/maticzav/repos","events_url":"https://api.github.com/users/maticzav/events{/privacy}","received_events_url":"https://api.github.com/users/maticzav/received_events","type":"User","site_admin":false}],"milestone":null,"comments":8,"created_at":"2018-06-17T08:50:33Z","updated_at":"2018-08-14T07:02:39Z","closed_at":null,"author_association":"NONE","body":"Hi @maticzav! First of all thanks for the awesome library!\r\n\r\nI have few questions/suggestions about CustomErrors:\r\n\r\n1. Is there a way to specify CustomError that will be returned from shield in case if permissions checks are failed?\r\n\r\nExample:\r\nI have isAuthenticated rule\r\n```js\r\nexport default rule()((parent, args, { user }) => Boolean(user));\r\n```\r\nI want to return my custom 401 error like this\r\n\r\n```js\r\nimport { SevenBoom } from 'graphql-apollo-errors';\r\n\r\nrule(null, { \r\n  customError: SevenBoom.unauthorized('You are not authenticated')\r\n})((parent, args, { user }) => Boolean(user))\r\n```\r\n\r\n2. Is there a way to specify global CustomError instead of https://github.com/maticzav/graphql-shield/blob/master/src/index.ts#L234 which will be used in case if there is no rule specific error?\r\n\r\nExample:\r\n\r\n```js\r\nimport { SevenBoom } from 'graphql-apollo-errors';\r\n\r\nshield({ /* Rules… */ }, {\r\n  customError: SevenBoom.forbidden('You are not allowed to do this action.')\r\n})\r\n```\r\n\r\nI can implement this and looks like it is not a breaking change.\r\n\r\nJust want to clarify if there is no way to do this in current version of the library?\r\n\r\nLet me know if you have any questions. Thanks!"},"comment":{"url":"https://api.github.com/repos/maticzav/graphql-shield/issues/comments/412774821","html_url":"https://github.com/maticzav/graphql-shield/issues/60#issuecomment-412774821","issue_url":"https://api.github.com/repos/maticzav/graphql-shield/issues/60","id":412774821,"node_id":"MDEyOklzc3VlQ29tbWVudDQxMjc3NDgyMQ==","user":{"login":"maticzav","id":3924224,"node_id":"MDQ6VXNlcjM5MjQyMjQ=","avatar_url":"https://avatars2.githubusercontent.com/u/3924224?v=4","gravatar_id":"","url":"https://api.github.com/users/maticzav","html_url":"https://github.com/maticzav","followers_url":"https://api.github.com/users/maticzav/followers","following_url":"https://api.github.com/users/maticzav/following{/other_user}","gists_url":"https://api.github.com/users/maticzav/gists{/gist_id}","starred_url":"https://api.github.com/users/maticzav/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maticzav/subscriptions","organizations_url":"https://api.github.com/users/maticzav/orgs","repos_url":"https://api.github.com/users/maticzav/repos","events_url":"https://api.github.com/users/maticzav/events{/privacy}","received_events_url":"https://api.github.com/users/maticzav/received_events","type":"User","site_admin":false},"created_at":"2018-08-14T07:02:39Z","updated_at":"2018-08-14T07:02:39Z","author_association":"OWNER","body":"Hey @kolybasov, I need some help. Could you give me your opinion on this; In a hypothetical situation, a user has defined a rule with a custom error. Unfortunately, they weren't precise and made a mistake in their resolver (not rule). Should the rule return `customMessage` or `fallback` by default? "}}
{"actor":{"display_login":"maticzav"}}