Skip to content

Instantly share code, notes, and snippets.

@wojciech-bilicki
Last active April 12, 2018 07:30
Show Gist options
  • Save wojciech-bilicki/a99e5186e835164f92fa222321e8de0e to your computer and use it in GitHub Desktop.
Save wojciech-bilicki/a99e5186e835164f92fa222321e8de0e to your computer and use it in GitHub Desktop.
with Mutations
import mongoose from 'mongoose'
import authorModel from './models/author'
const resolvers = {
Query: {
authors: () => {
return authors
},
author: (root, args) => {
const id = args.id;
return authors.find(author => author.id === id);
}
},
Mutation: {
addAuthor: (root, {name, age, Books}) => {
const author = new authorModel({name, age, Books})
return author.save()
}
}
}
export default resolvers;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment