Save invite to team

This commit is contained in:
Barry Low committed 2018-09-27 23:14:02 -07:00
1 parent 1359f606fe
commit a53a3a8cb5
5 files changed
+20 -3

No files matched your search

+1 -1
View File
@@ -59,7 +59,7 @@ type TeamMembers {
team: Team @relation (name: "TeamMembers", onDelete: SET_NULL)
role: Role @default(value: MEMBER)
status: [TeamMemberStatus!]!
email: String
email: String @unique
createdAt: DateTime!
updatedAt: DateTime!
}
+2 -1
View File
@@ -1,5 +1,5 @@
# source: http://localhost:4466
# timestamp: Thu Sep 27 2018 08:38:09 GMT-0700 (Pacific Daylight Time)
# timestamp: Thu Sep 27 2018 22:50:26 GMT-0700 (Pacific Daylight Time)
type AggregateFBStatus {
count: Int!
@@ -1731,6 +1731,7 @@ input TeamMembersWhereInput {
input TeamMembersWhereUniqueInput {
id: ID
email: String
}
enum TeamOrderByInput {
@@ -21,10 +21,16 @@ const TEAMS_CONNECTIONS_FRAGMENT = gql`{
}
members {
role
email
member {
alias
authId
}
status {
status
reason
createdAt
}
}
}
}
+6 -1
View File
@@ -13,17 +13,22 @@ const TEAMS_FRAGMENT = gql`{
createdAt
profile {
avatar
banner
description
motto
updatedAt
}
members {
role
email
member {
alias
authId
}
status {
status
reason
createdAt
}
}
}`
+5
View File
@@ -214,6 +214,11 @@ const resolvers = {
},
async sendMemberInviteSG(parent, { email, teamId }, ctx, info) {
const team = await ctx.db.query.team({ where: { id: teamId } }, TEAMS_FRAGMENT)
const addMember = await ctx.db.mutation.upsertTeamMembers({
where:{email: email},
create:{role:'MEMBER', email:email, team: {connect: {id: teamId}}, status:{create:{status: 'INVITED', reason: `Invited by ${team.members[0].member.alias}`}}},
update:{role: 'MEMBER', email: email, team: {connect: {id: teamId}}, status:{create:{status: 'INVITED', reason: `Invite resent by ${team.members[0].member.alias}`}}}},
`{ id }`)
const sendInvite = await sendTeamMemberInvite(email, team)
return sendInvite
}