import UserService from '../../application/user/userService' ; import { UserCreateData } from '../../application/user/declarations' ; import { Dictionary } from '../../domain/declarations' ; import { ResolverContext } from '../declarations' ; import transform from './transform' ; export default ( userService ) => { return { resolvers : { Mutation : { createUser : async ( _source , { userData } , _context ) => { return transform ( await userService . createUser ( userData , '/graphql' ) ) ; } , } , Query : { getUsers : async ( _source , _params , _context ) => { return ( await userService . getAll ( ) ) . map ( ( user ) => transform ( user ) ) ; } , } , } , typeDef : `
      type User {
        _id: String
        createdAt: String,
        email: String!
        updatedAt: String
        username: String
      }
      input UserDataInput {
        email: String!
        username: String
      }
      extend type Query {
        getUsers: [User]
      }
      extend type Mutation {
        createUser(userData: UserDataInput!): User
      }
    ` , } ; } ;