Created
February 18, 2017 18:44
-
-
Save RyanCCollins/d2cdd603da42acaac4205203ba6a0d9a 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 { | |
| GraphQLNonNull, | |
| GraphQLBoolean, | |
| } from 'graphql'; | |
| import types from '../../types'; | |
| import CommentModel from '../../../db/models/comment'; | |
| export default { | |
| type: GraphQLBoolean, | |
| args: { | |
| data: { | |
| type: new GraphQLNonNull(types.commentInputType), | |
| }, | |
| }, | |
| async resolve(_, args, __) { | |
| const model = new CommentModel(args.data); | |
| const newComment = await model.save(); | |
| if (!newComment) { | |
| throw new Error('Error saving comment'); | |
| } | |
| return true; | |
| }, | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment