Created
November 30, 2016 22:05
-
-
Save holmesal/e9e658ac7f0d0d526a852cccbbe4d6fd to your computer and use it in GitHub Desktop.
This file contains hidden or 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
var UserType = new GraphQLObjectType({ | |
name: 'User', | |
description: 'A venerable Chorus user', | |
isTypeOf: (obj, info) => obj instanceof db.User, | |
interfaces: [nodeDefinitions.nodeInterface], | |
fields: () => ({ | |
id: globalIdField('User'), | |
// no decorator here - this is public | |
username: { | |
type: GraphQLString, | |
description: 'A username.', | |
resolve: user => user.get('username') | |
}, | |
@requireAuth | |
viewerIsFollowing: { | |
type: GraphQLBoolean, | |
description: 'Whether you are following this user', | |
resolve: async (user, args, { user: viewer }) => { | |
const isFollowing = await viewer.isFollowing(user); | |
return isFollowing ? true : false; | |
} | |
} | |
@requireSameAuthUser | |
email: { | |
type: GraphQLString, | |
description: 'An email address on the World Wide Web.', | |
resolve: user => user.get('email') | |
} | |
}) | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment