Skip to content

Commit 27b461f

Browse files
authored
PublicUserTicketRef: "userName" -> "user.name", "userUsername" -> "user.username" (#254)
1 parent 88d36af commit 27b461f

1 file changed

Lines changed: 19 additions & 1 deletion

File tree

src/schema/userTickets/types.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ builder.objectType(PublicUserTicketRef, {
130130
return user.imageUrl;
131131
},
132132
}),
133-
userName: t.field({
133+
userUsername: t.field({
134134
type: "String",
135135
nullable: true,
136136
resolve: async (root, arg, context) => {
@@ -148,6 +148,24 @@ builder.objectType(PublicUserTicketRef, {
148148
return user.username;
149149
},
150150
}),
151+
userName: t.field({
152+
type: "String",
153+
nullable: true,
154+
resolve: async (root, arg, context) => {
155+
if (!root.userId) {
156+
return null;
157+
}
158+
159+
const loader = UserLoadable.getDataloader(context);
160+
const user = await loader.load(root.userId);
161+
162+
if (!user) {
163+
return null;
164+
}
165+
166+
return user.name;
167+
},
168+
}),
151169
ticket: t.field({
152170
type: TicketLoadable,
153171
resolve: (root) => root.ticketTemplateId,

0 commit comments

Comments
 (0)