Apollo Newbie Question re: Resolvers?


#1

I’m working on learning Apollo. I’m looking at the resolvers in the Apollo Meteor Starter kit, and I see this:

export const resolvers = {
  Query: {
    async user(root, args, context) {
      // Only return the current user, for security
      if (context.userId === args.id) {
        return await Meteor.users.findOne(context.userId);
      }
    },
  },
  User: {
    emails: ({emails}) => emails,
    randomString: () => Random.id(),
  }
}

I’m trying to figure out how this works.

  • What is the difference between Query: and User:?

  • What is the difference between async user() and User:{}?

Thanks very much in advance to all for any info!


#2

I found the excellent Kadira tutorial on GraphQL.