Last active
April 12, 2018 07:30
-
-
Save wojciech-bilicki/a99e5186e835164f92fa222321e8de0e to your computer and use it in GitHub Desktop.
with Mutations
This file contains 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 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