-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathresolvers.js
38 lines (34 loc) · 936 Bytes
/
resolvers.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
'use strict';
const log = require('./lib/log');
const Author = require('./models/types/Author');
const Book = require('./models/types/Book');
const Review = require('./models/types/Review');
const resolvers = {
Query: {
author: log('author', (_, args) => {
return Author.get(args);
}),
authors: log('authors', (_, args) => {
return Author.getAll(args);
}),
books: log('books', (_, args) => {
return Book.getAll();
})
},
Author: {
books: log('author books', (author) => {
return Book.getBooksByAuthor(author);
})
},
Book: {
reviews: log('book reviews', (book) => {
return Review.getReviewsByBook(book);
})
},
Mutation: {
createBook: log('create book', (_, args) => {
return Book.createBook(args);
})
}
};
module.exports = resolvers;