Guest User

Untitled

a guest
Feb 17th, 2019
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. const { GraphQLObjectType, GraphQLString } = require('graphql');
  2. const gadgetGraphQLType = require('./gadgetType');
  3. const Gadget = require('./../models/gadget');
  4.  
  5. const Mutation = new GraphQLObjectType({
  6. name: 'Mutation',
  7. fields: {
  8. addGadget: {
  9. type: gadgetGraphQLType,
  10. args: {
  11. name: { type: GraphQLString },
  12. release_date: { type: GraphQLString },
  13. by_company: { type: GraphQLString },
  14. price: { type: GraphQLString }
  15. },
  16. resolve(parent, args) {
  17. const newGadget = new Gadget({
  18. name: args.name,
  19. release_date: args.release_date,
  20. by_company: args.by_company,
  21. price: args.price,
  22. })
  23.  
  24. return newGadget.save();
  25. }
  26. }
  27.  
  28. }
  29. })
  30.  
  31. module.exports = Mutation;
Add Comment
Please, Sign In to add comment