Created
June 8, 2018 15:48
-
-
Save daniele-zurico/65c393a1cee0ce8b3adc17fb6336ec8f 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 { userController } from "../controllers/controllers"; | |
| import { AuthenticationError } from "apollo-server"; | |
| const userResolver = { | |
| Query: { | |
| posts(root: any, args: any, context: any) { | |
| return userController.posts(); | |
| }, | |
| users(root: any, args: any, context: any) { | |
| console.log(context); | |
| if (!context.authorized){ | |
| console.error('User not authorized'); | |
| throw new AuthenticationError("you must be logged in"); | |
| } | |
| return userController.users(root, args.user); | |
| }, | |
| validateUser(root: any, args: any) { | |
| return userController.findOrCreateUser(args.idToken); | |
| } | |
| } | |
| }; | |
| export default userResolver; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment