mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-07-19 00:57:55 -05:00
get user by either discord id or custom url
This commit is contained in:
parent
f7f56a084d
commit
f794aebfa9
|
|
@ -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()
|
||||
}
|
||||
},
|
||||
]
|
||||
},
|
||||
})
|
||||
})
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user