Last active
June 2, 2017 06:53
-
-
Save duytai/a7eedcbc7e04ef7c0bd708ab11a72139 to your computer and use it in GitHub Desktop.
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
// 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