Advertisement
Guest User

Untitled

a guest
Oct 7th, 2017
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. 'use strict';
  2.  
  3. const {
  4. GraphQLObjectType,
  5. GraphQLString,
  6. GraphQLNonNull,
  7. GraphQLBoolean,
  8. } = require('graphql');
  9.  
  10. const { UserType } = require('./user');
  11.  
  12. const AuthenticationMutations = {
  13. registerUser: {
  14. type: UserType,
  15. args: {
  16. username: {
  17. type: new GraphQLNonNull(GraphQLString)
  18. },
  19. email: {
  20. type: new GraphQLNonNull(GraphQLString)
  21. },
  22. password: {
  23. type: new GraphQLNonNull(GraphQLString)
  24. },
  25. name: {
  26. type: GraphQLString
  27. }
  28. },
  29. async resolve(_, args, { db }) {
  30. try {
  31. const user = await db.user.create(args);
  32. return user;
  33. } catch (error) {
  34. throw new Error(error);
  35. }
  36. }
  37. }
  38. };
  39.  
  40. module.exports = {
  41. AuthenticationMutations
  42. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement