{"action":"created","issue":{"url":"https://api.github.com/repos/RisingStack/graffiti-mongoose/issues/64","labels_url":"https://api.github.com/repos/RisingStack/graffiti-mongoose/issues/64/labels{/name}","comments_url":"https://api.github.com/repos/RisingStack/graffiti-mongoose/issues/64/comments","events_url":"https://api.github.com/repos/RisingStack/graffiti-mongoose/issues/64/events","html_url":"https://github.com/RisingStack/graffiti-mongoose/issues/64","id":118343795,"number":64,"title":"Extending grafitti schema","user":{"login":"zuhair-naqvi","id":262722,"avatar_url":"https://avatars.githubusercontent.com/u/262722?v=3","gravatar_id":"","url":"https://api.github.com/users/zuhair-naqvi","html_url":"https://github.com/zuhair-naqvi","followers_url":"https://api.github.com/users/zuhair-naqvi/followers","following_url":"https://api.github.com/users/zuhair-naqvi/following{/other_user}","gists_url":"https://api.github.com/users/zuhair-naqvi/gists{/gist_id}","starred_url":"https://api.github.com/users/zuhair-naqvi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zuhair-naqvi/subscriptions","organizations_url":"https://api.github.com/users/zuhair-naqvi/orgs","repos_url":"https://api.github.com/users/zuhair-naqvi/repos","events_url":"https://api.github.com/users/zuhair-naqvi/events{/privacy}","received_events_url":"https://api.github.com/users/zuhair-naqvi/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-11-23T09:22:20Z","updated_at":"2015-11-23T14:19:32Z","closed_at":null,"body":"getSchema returns a GraphQLSchema object based on MongooseModels, how do I go about adding my own types to this schema?\r\n\r\nConsider the use case:\r\nI have a `Post` object with `getLikedFriends` method, which looks up all `Post.likes` references and queries `Users` collection to check if any of the `User.friends` references for the loggedIn user match with `Post.likes`\r\n\r\nSo instead of creating a new Mongoose model and re-implementing the logic inside my pre-existing `getLikedFriends` method, I'd like to just add this as a new type to the GraphQL schema and let the resolve function call `Post.getLikedFriends(ctx.loggedInUser)`\r\n\r\nThis is something I can easily do using vanilla GraphQL but not sure how to augment the schema returned by graffiti :/"},"comment":{"url":"https://api.github.com/repos/RisingStack/graffiti-mongoose/issues/comments/158944269","html_url":"https://github.com/RisingStack/graffiti-mongoose/issues/64#issuecomment-158944269","issue_url":"https://api.github.com/repos/RisingStack/graffiti-mongoose/issues/64","id":158944269,"user":{"login":"marcoreat","id":15048404,"avatar_url":"https://avatars.githubusercontent.com/u/15048404?v=3","gravatar_id":"","url":"https://api.github.com/users/marcoreat","html_url":"https://github.com/marcoreat","followers_url":"https://api.github.com/users/marcoreat/followers","following_url":"https://api.github.com/users/marcoreat/following{/other_user}","gists_url":"https://api.github.com/users/marcoreat/gists{/gist_id}","starred_url":"https://api.github.com/users/marcoreat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marcoreat/subscriptions","organizations_url":"https://api.github.com/users/marcoreat/orgs","repos_url":"https://api.github.com/users/marcoreat/repos","events_url":"https://api.github.com/users/marcoreat/events{/privacy}","received_events_url":"https://api.github.com/users/marcoreat/received_events","type":"User","site_admin":false},"created_at":"2015-11-23T14:19:32Z","updated_at":"2015-11-23T14:19:32Z","body":"+1 for providing a way to extend the default set of queries (and hopefully mutations too).\r\n\r\nI also like the idea to add a new config step so that not everything is exposed by default. This is the most common use case anyway: I believe most people would want to expose only a subset of their queries and mutations. I know that it's possible to hide fields or restrict access with hooks, but it's messier and more verbose. Having a dedicated step for that seems to be the cleanest approach."}}