import { composeWithJson } from 'graphql-compose-json' ; import { ContactID , AccountID , WorkScheduleID } from 'app/schema/types/Scalars' ; import { UserRoleEnum } from 'app/schema/types/Enums' ; import { getRelationAccountId } from 'app/schema/relations/account' ; import { getRelationWorkScheduleId } from 'app/schema/relations/workSchedule' ; import { getRelationTasksByAuthorId , getRelationTasksByResponsibleId , } from 'app/schema/relations/task' ; import { getRelationUserScheduleExclusionByUserId } from 'app/schema/relations/userScheduleExclusion' ; import { getRelationApprovalsByApproverUserId , getRelationApprovalsByPendingApproverUserId , } from 'app/schema/relations/approval' ; const restApiResponse = { id : ContactID . NonNull , firstName : 'Pavel' , lastName : 'Chertorogov' , type : 'Person' , profiles : [ { accountId : AccountID , email : 'pavel.chertorogov@gmail.com' , role : UserRoleEnum , external : false , admin : false , owner : true , } , ] , avatarUrl : 'https://www.wrike.com/avatars//77/A8/Box_ffe57373_80-67_v1.png' , timezone : 'US/Pacific' , locale : 'en' , deleted : false , me : true , myTeam : false , title : 'IT' , companyName : 'Test' , phone : '+77777' , location : 'ALA' , workScheduleId : WorkScheduleID , } ; export const UserTC = composeWithJson ( 'User' , restApiResponse ) ; if ( ! process . env . DISABLE_RELATIONS ) { UserTC . addNestedFields ( { 'profiles.account' : ( ) => getRelationAccountId ( 'accountId' ) , workSchedule : ( ) => getRelationWorkScheduleId ( 'workScheduleId' ) , } ) ; } if ( ! process . env . DISABLE_BACK_RELATIONS ) { UserTC . addFields ( { tasksAuthored : ( ) => getRelationTasksByAuthorId ( 'id' ) , tasksResponsible : ( ) => getRelationTasksByResponsibleId ( 'id' ) , scheduleExclusions : ( ) => getRelationUserScheduleExclusionByUserId ( 'id' ) , approvals : ( ) => getRelationApprovalsByApproverUserId ( 'id' ) , approvalsPending : ( ) => getRelationApprovalsByPendingApproverUserId ( 'id' ) , } ) ; }