Skip to content

Instantly share code, notes, and snippets.

@duytai
Last active June 2, 2017 06:53
Show Gist options
  • Save duytai/a7eedcbc7e04ef7c0bd708ab11a72139 to your computer and use it in GitHub Desktop.
Save duytai/a7eedcbc7e04ef7c0bd708ab11a72139 to your computer and use it in GitHub Desktop.
// graphql definition for User
type User implements Node {
_id: ID
name: String
friends: [User]
}
// implement
import { Users} from '/imports/models'
class Node {
constructor(node) {
_.extend(this, node)
}
}
class User extends Node {
friends() {
const users = Users.find({ _id: { $in: this.friendIds } }).fetch();
return users.map(user => new UserNode(user));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment