mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-09-26 13:17:15 -05:00
get user by either discord id or custom url
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { PrismaClient } from "@prisma/client";
|
||||
|
||||
const prisma = new PrismaClient();
|
||||
const prisma = new PrismaClient({log: ["query"]});
|
||||
|
||||
export interface Context {
|
||||
prisma: PrismaClient;
|
||||
|
||||
@@ -18,10 +18,20 @@ export const Query = queryType({
|
||||
args: {
|
||||
identifier: stringArg({required: true})
|
||||
},
|
||||
resolve: (_root, {identifier}, ctx) => ctx.prisma.user.findOne({
|
||||
resolve: (_root, {identifier}, ctx) => ctx.prisma.user.findFirst({
|
||||
where: {
|
||||
discordId: identifier
|
||||
}
|
||||
// this is ok because the values are mutually exclusive: customUrlPath can't contain only numbers etc.
|
||||
OR: [
|
||||
{
|
||||
discordId: identifier
|
||||
},
|
||||
{
|
||||
profile: {
|
||||
customUrlPath: identifier.toLowerCase()
|
||||
}
|
||||
},
|
||||
]
|
||||
},
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user