Created
June 12, 2018 18:44
-
-
Save daniele-zurico/efdb6c090ae8bf9073352f8424b5af86 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { postController } from "../controllers/controllers"; | |
| import { pubsub } from "../server"; | |
| const POST_ADDED = 'POST_ADDED'; | |
| const postResolver = { | |
| Subscription: { | |
| postAdded: { | |
| subscribe: () => pubsub.asyncIterator([POST_ADDED]) | |
| } | |
| }, | |
| Query: { | |
| posts(root: any, args: any, context: any) { | |
| return postController.posts(); | |
| } | |
| }, | |
| Mutation: { | |
| addPost(root: any, args: any, context: any) { | |
| pubsub.publish(POST_ADDED, { postAdded: args }); | |
| return postController.addPost(args); | |
| } | |
| } | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment