Skip to content

Instantly share code, notes, and snippets.

@fernandodof
Last active March 2, 2020 08:17
Show Gist options
  • Save fernandodof/d7a5f87e7e44bc624332e54e48805cea to your computer and use it in GitHub Desktop.
Save fernandodof/d7a5f87e7e44bc624332e54e48805cea to your computer and use it in GitHub Desktop.
const db = require('./database');
const Query = {
users: () => db.users.list(),
user: (root, { id }) => db.users.get(id),
tweets: (root, { userId, last }) => {
const tweets = db.tweets.list().filter(tweet => tweet.userId === userId);
return last ? tweets.slice(-last) : tweets;
}
};
module.exports = { Query };
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment