How can I resolve keys on a type?

Say for example I have the standard Meteor User document and I want to a GraphQL key of emails to return a list of strings. How would I do this with the GraphQL Schema syntax?


type User {
  _id: String
  emails: [String]
  username: String

type Query {
  user(id: String!): User

and the resolvers:

    async user(root, args, context) {
      return await Meteor.users.findOne(;

I realize I could manipulate the query result to conform to the shape of the GraphQL type but with the older syntax you could do this:

const UserType = new GraphQLObjectType({
  name: 'User',
  fields: {
    emails: {
      type: // list of Strings
      resolve(parentValue, args, request) {
        return => e.address)

But I can’t figure out how to do it with the newer schema syntax. I’ve tried adding a resolver to Query but the schema is looking for a type :thinking:

You can add a resolver to the User type, like so:

1 Like

Ahhh simple. Thanks!

1 Like