Skip to content

Instantly share code, notes, and snippets.

@RyanCCollins
Created February 18, 2017 18:44
Show Gist options
  • Select an option

  • Save RyanCCollins/d2cdd603da42acaac4205203ba6a0d9a to your computer and use it in GitHub Desktop.

Select an option

Save RyanCCollins/d2cdd603da42acaac4205203ba6a0d9a to your computer and use it in GitHub Desktop.
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