{"action":"created","issue":{"url":"https://api.github.com/repos/webonyx/graphql-php/issues/299","repository_url":"https://api.github.com/repos/webonyx/graphql-php","labels_url":"https://api.github.com/repos/webonyx/graphql-php/issues/299/labels{/name}","comments_url":"https://api.github.com/repos/webonyx/graphql-php/issues/299/comments","events_url":"https://api.github.com/repos/webonyx/graphql-php/issues/299/events","html_url":"https://github.com/webonyx/graphql-php/issues/299","id":337551436,"node_id":"MDU6SXNzdWUzMzc1NTE0MzY=","number":299,"title":"Feature Request: Directive Visitors / Resolvers","user":{"login":"zimzat","id":3887134,"node_id":"MDQ6VXNlcjM4ODcxMzQ=","avatar_url":"https://avatars1.githubusercontent.com/u/3887134?v=4","gravatar_id":"","url":"https://api.github.com/users/zimzat","html_url":"https://github.com/zimzat","followers_url":"https://api.github.com/users/zimzat/followers","following_url":"https://api.github.com/users/zimzat/following{/other_user}","gists_url":"https://api.github.com/users/zimzat/gists{/gist_id}","starred_url":"https://api.github.com/users/zimzat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zimzat/subscriptions","organizations_url":"https://api.github.com/users/zimzat/orgs","repos_url":"https://api.github.com/users/zimzat/repos","events_url":"https://api.github.com/users/zimzat/events{/privacy}","received_events_url":"https://api.github.com/users/zimzat/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":9,"created_at":"2018-07-02T14:51:44Z","updated_at":"2018-11-02T18:54:28Z","closed_at":"2018-07-07T15:13:26Z","author_association":"NONE","body":"There's currently a lack of examples showing how to check for directives in resolvers for each location, whether the Schema or Query type. There doesn't seem to be any way to hook into schema directives, such as during the build step, and query directives seem to require manually implementing into each defaultResolver/fieldResolver/resolve function with no way to easily chain functionality or creating a global resolver to intercept every other resolver first, which seems a bit cumbersome. Am I missing something?\r\n\r\nIt would be nice to have a way to implement directives as visitors, promises, or other helpers. Implementing `@skip`, `@include`, and `@deprecated` in this way would be a good first step and provide a guide for implementing custom directives.\r\n\r\nFor reference the [Apollo Server Directive](https://www.apollographql.com/docs/graphql-tools/schema-directives.html) implementation uses visitors and chaining resolver promises.\r\n\r\nIf a schema visitor during the build process and query resolve chain for the execution process sounds reasonable then I could put some time into implementing those (e.g. like Apollo), but if you have another idea on how to implement those or don't feel like it should be part of the library I'm open to alternates.\r\n\r\nFor my current usage I'm trying to implement a Query / Mutation directive to set the account context to be used for that execution. I've considered putting in the URL (which would have to be done for multiple graph endpoints, public/admin/employee for every account, but might be arguably easier for the client), adding an argument to every relevant field / object, putting it in filter parameters (which could get messy / disconnected for child/sibling filters), or a secondary request Header (this might be the way I end up going until I can get a better way to handle it with directives).\r\n\r\nI'd also like to consider using schema directives for excluding/including specific objects definitions or fields based on the endpoint used (merging public/admin/employee type language files), but currently that's not an option."},"comment":{"url":"https://api.github.com/repos/webonyx/graphql-php/issues/comments/435475625","html_url":"https://github.com/webonyx/graphql-php/issues/299#issuecomment-435475625","issue_url":"https://api.github.com/repos/webonyx/graphql-php/issues/299","id":435475625,"node_id":"MDEyOklzc3VlQ29tbWVudDQzNTQ3NTYyNQ==","user":{"login":"vladar","id":115628,"node_id":"MDQ6VXNlcjExNTYyOA==","avatar_url":"https://avatars2.githubusercontent.com/u/115628?v=4","gravatar_id":"","url":"https://api.github.com/users/vladar","html_url":"https://github.com/vladar","followers_url":"https://api.github.com/users/vladar/followers","following_url":"https://api.github.com/users/vladar/following{/other_user}","gists_url":"https://api.github.com/users/vladar/gists{/gist_id}","starred_url":"https://api.github.com/users/vladar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vladar/subscriptions","organizations_url":"https://api.github.com/users/vladar/orgs","repos_url":"https://api.github.com/users/vladar/repos","events_url":"https://api.github.com/users/vladar/events{/privacy}","received_events_url":"https://api.github.com/users/vladar/received_events","type":"User","site_admin":false},"created_at":"2018-11-02T18:54:28Z","updated_at":"2018-11-02T18:54:28Z","author_association":"MEMBER","body":"Looks like documentation was deleted [here](https://github.com/webonyx/graphql-php/commit/d6add77540d3133fe4829da6fc863c5cd48efbe2#diff-a974210aacfab92dce8d065764dee530). I missed this, but will restore it as soon as I have a moment. Or you can send a PR to restore it.\r\n\r\nAs for other options - you can try wrapping `typeLoader` and enhance all type's fields on load. This is still  not ideal, but can work."}}
{"actor":{"display_login":"vladar"}}