Last active
October 8, 2017 16:57
-
-
Save rubycut/aa61fc87784f70068b6af9faeec76da6 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
import {Cluster} from './cluster.js' | |
const graphqlFields = require('graphql-fields'); | |
import * as _ from 'lodash' | |
const resolvers = { | |
Query: { | |
customer(root, args, context,info) { | |
var requested_fields = Object.keys(graphqlFields(info)) | |
var c = Cluster.findForUser(context,args.id) | |
if(_.includes(requested_fields, 'contacts')) { | |
c = c.populate('contacts') | |
} | |
return c.then((data) => { | |
return [ data ] | |
}).catch(error => { | |
console.log(error) | |
}); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment