Skip to content

Commit 7efdf43

Browse files
authored
Tags fixes (#212)
1 parent b27171d commit 7efdf43

5 files changed

Lines changed: 13 additions & 1 deletion

File tree

src/generated/schema.gql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -901,6 +901,7 @@ input TicketCreateInput {
901901
requiresApproval: Boolean
902902
startDateTime: DateTime!
903903
status: TicketTemplateStatus
904+
tags: [String!]
904905

905906
"""
906907
If provided, quantity must not be passed. This is for things like online events where there is no limit to the amount of tickets that can be sold.

src/generated/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -922,6 +922,7 @@ export type TicketCreateInput = {
922922
requiresApproval?: InputMaybe<Scalars["Boolean"]["input"]>;
923923
startDateTime: Scalars["DateTime"]["input"];
924924
status?: InputMaybe<TicketTemplateStatus>;
925+
tags?: InputMaybe<Array<Scalars["String"]["input"]>>;
925926
/** If provided, quantity must not be passed. This is for things like online events where there is no limit to the amount of tickets that can be sold. */
926927
unlimitedTickets: Scalars["Boolean"]["input"];
927928
visibility?: InputMaybe<TicketTemplateVisibility>;

src/schema/ticket/mutations.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ const TicketCreateInput = builder.inputType("TicketCreateInput", {
4040
name: t.string({
4141
required: true,
4242
}),
43+
tags: t.field({
44+
type: ["String"],
45+
required: false,
46+
}),
4347
description: t.string({
4448
required: false,
4549
}),
@@ -227,6 +231,9 @@ builder.mutationField("createTicket", (t) =>
227231
eventId: input.eventId,
228232
isUnlimited: input.unlimitedTickets,
229233
isFree: input.isFree,
234+
tags: [
235+
...new Set(input.tags?.map((tag) => tag.trim().toLowerCase())),
236+
],
230237
});
231238
const insertedTickets = await trx
232239
.insert(ticketsSchema)

src/schema/ticket/ticketsFetcher.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@ const getSearchTicketQuery = (
5151
}
5252

5353
if (tags && tags.length > 0) {
54-
wheres.push(arrayContains(ticketsSchema.tags, tags));
54+
const cleanedTags = tags.map((tag) => tag.trim().toLowerCase());
55+
56+
wheres.push(arrayContains(ticketsSchema.tags, cleanedTags));
5557
}
5658

5759
if (eventIds && eventIds.length > 0) {

src/schema/ticket/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ export const TicketLoadable = builder.loadableObject(TicketRef, {
9999
description: "Whether or not the ticket is free",
100100
nullable: false,
101101
}),
102+
tags: t.exposeStringList("tags"),
102103
isUnlimited: t.exposeBoolean("isUnlimited", {
103104
description:
104105
"Whether or not the ticket has an unlimited quantity. This is reserved for things loike online events.",

0 commit comments

Comments
 (0)