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?
Example:
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(args.id);
},
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 parentValue.emails.map(e => 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