author BounceCode, Inc.
 *  packageDocumentation import { Resolver , Query , Mutation , Ctx , Arg , Int } from 'type-graphql' ; import { UserEntity } from '../entities/User.entity' ; import { UserObject } from '../objects/User.object' ; import { UserCreateInput } from '../inputs/UserCreate.input' ; import { UserUpdateInput } from '../inputs/UserUpdate.input' ; import { UserWhereInput } from '../inputs/UserWhere.input' ; import { Context } from '../../../express' ; author BounceCode, Inc.
  @ Resolver ( ) export class UserResolver { author BounceCode, Inc.
      @ Query ( ( ) => UserObject ) async me ( @ Ctx ( ) ctx ) { try { return await UserEntity . findOne ( { where : { id : ctx . user . id , } , } ) ; } catch ( e ) { console . log ( e ) ; } } author BounceCode, Inc.
      @ Query ( ( ) => UserObject ) async user ( @ Arg ( 'where' ) where ) { try { return await UserEntity . findOne ( { where , } ) ; } catch ( e ) { console . log ( e ) ; } } author BounceCode, Inc.
      @ Query ( ( ) => [ UserObject ] ) async users ( @ Arg ( 'where' , { nullable : true } ) where , @ Arg ( 'skip' , ( ) => Int ) skip , @ Arg ( 'take' , ( ) => Int ) take ) { try { return await UserEntity . find ( { where , skip , take , } ) ; } catch ( e ) { console . log ( e ) ; } } author BounceCode, Inc.
      @ Mutation ( ( ) => UserObject ) async createUser ( @ Arg ( 'data' ) data ) { try { return await UserEntity . create ( data ) . save ( ) ; } catch ( e ) { console . log ( e ) ; } } author BounceCode, Inc.
      @ Mutation ( ( ) => UserObject ) async updateUser ( @ Arg ( 'where' ) where , @ Arg ( 'data' ) data ) { try { return await UserEntity . update ( where , data ) ; } catch ( e ) { console . log ( e ) ; } } author BounceCode, Inc.
      @ Mutation ( ( ) => Boolean ) async deleteUser ( @ Arg ( 'where' ) where ) { try { return await UserEntity . delete ( where ) ; } catch ( e ) { console . log ( e ) ; } } }