Skip to content

Instantly share code, notes, and snippets.

@daniele-zurico
Created June 8, 2018 15:48
Show Gist options
  • Select an option

  • Save daniele-zurico/65c393a1cee0ce8b3adc17fb6336ec8f to your computer and use it in GitHub Desktop.

Select an option

Save daniele-zurico/65c393a1cee0ce8b3adc17fb6336ec8f to your computer and use it in GitHub Desktop.
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