diff --git a/api/paidAction/inviteGift.js b/api/paidAction/inviteGift.js
index 0cc52cae..c96f5c92 100644
--- a/api/paidAction/inviteGift.js
+++ b/api/paidAction/inviteGift.js
@@ -21,7 +21,7 @@ export async function perform ({ id, userId }, { me, cost, tx }) {
where: { id, userId: me.id, revoked: false }
})
- if (invite.giftedCount >= invite.limit) {
+ if (invite.limit && invite.giftedCount >= invite.limit) {
throw new Error('invite limit reached')
}
@@ -45,7 +45,7 @@ export async function perform ({ id, userId }, { me, cost, tx }) {
})
return await tx.invite.update({
- where: { id, userId: me.id, giftedCount: { lt: invite.limit }, revoked: false },
+ where: { id, userId: me.id, revoked: false, ...(invite.limit ? { giftedCount: { lt: invite.limit } } : {}) },
data: {
giftedCount: {
increment: 1
diff --git a/api/typeDefs/invite.js b/api/typeDefs/invite.js
index 038447d8..dc7e0857 100644
--- a/api/typeDefs/invite.js
+++ b/api/typeDefs/invite.js
@@ -7,7 +7,7 @@ export default gql`
}
extend type Mutation {
- createInvite(id: String, gift: Int!, limit: Int, description: String): Invite
+ createInvite(id: String, gift: Int!, limit: Int!, description: String): Invite
revokeInvite(id: ID!): Invite
}
diff --git a/pages/invites/index.js b/pages/invites/index.js
index 7692c9d2..fbccd528 100644
--- a/pages/invites/index.js
+++ b/pages/invites/index.js
@@ -19,7 +19,7 @@ function InviteForm () {
const [createInvite] = useMutation(
gql`
${INVITE_FIELDS}
- mutation createInvite($id: String, $gift: Int!, $limit: Int, $description: String) {
+ mutation createInvite($id: String, $gift: Int!, $limit: Int!, $description: String) {
createInvite(id: $id, gift: $gift, limit: $limit, description: $description) {
...InviteFields
}
@@ -57,7 +57,7 @@ function InviteForm () {
variables: {
id: id || undefined,
gift: Number(gift),
- limit: limit ? Number(limit) : limit,
+ limit: Number(limit),
description: description || undefined
}
})
@@ -72,7 +72,7 @@ function InviteForm () {
required
/>
invitee limit optional>}
+ label='invitee limit'
name='limit'
/>