Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jelorivera08/0becf53746a93aedb612a1c3309d9539 to your computer and use it in GitHub Desktop.
Save jelorivera08/0becf53746a93aedb612a1c3309d9539 to your computer and use it in GitHub Desktop.
/* eslint-disable no-unused-vars */
const { noteType } = require('../nodeTypes');
const {
GraphQLString,
GraphQLBoolean,
GraphQLInt,
GraphQLID
} = require('graphql');
const NoteService = require('../../services/NoteService');
const CreateNoteMutation = {
type: noteType,
args: {
content: { type: GraphQLString }
},
resolve: async (_, { content }) => {
const noteService = new NoteService();
const newNote = await noteService.createNote({ content });
return newNote;
}
};
const DeleteNoteMutation = {
type: GraphQLID,
args: {
_id: { type: GraphQLID }
},
resolve: async (_, { _id }) => {
const noteService = new NoteService();
const res = await noteService.deleteNote(_id);
if (res.ok) {
return _id;
}
}
};
const UpdateNoteMutation = {
type: noteType,
args: {
_id: { type: GraphQLID },
content: { type: GraphQLString }
},
resolve: async (_, { _id, content }) => {
const noteService = new NoteService();
const updatedNote = await noteService.updateNote(_id, { content });
return updatedNote;
}
};
module.exports = { CreateNoteMutation, UpdateNoteMutation, DeleteNoteMutation };
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment