Yiğit Rüzgar
12/10/2020, 10:41 AMRyan
12/10/2020, 10:45 AMcreateDraft2
mutation? It seems that findUnique
cannot get the argument in where
.Yiğit Rüzgar
12/10/2020, 10:50 AMYiğit Rüzgar
12/10/2020, 10:53 AMYiğit Rüzgar
12/10/2020, 10:55 AMYiğit Rüzgar
12/10/2020, 10:55 AMYiğit Rüzgar
12/10/2020, 10:57 AMYiğit Rüzgar
12/10/2020, 10:58 AMYiğit Rüzgar
12/10/2020, 11:00 AMprisma.yonetim.findUnique()
invocation:\n\n{\n where: {\n? numara?: Int\n },\n select: {\n gorevlipersonel: true\n }\n}\n\nArgument where of type GorevlendirmelerWhereUniqueInput needs at least one argument. Available args are listed in green.\n\nNote: Lines with ? are optional.\n",
"locations": [
{
"line": 2,
"column": 3
}
],
"path": [
"createDraft2"
],
"extensions": {
"code": "INTERNAL_SERVER_ERROR",
"exception": {
"clientVersion": "2.12.1",
"stacktrace": [
"Error: ",
"Invalid prisma.yonetim.findUnique()
invocation:",
"",
"{",
" where: {",
"? numara?: Int",
" },",
" select: {",
" gorevlipersonel: true",
" }",
"}",
"",
"Argument where of type GorevlendirmelerWhereUniqueInput needs at least one argument. Available args are listed in green.",
"",
"Note: Lines with ? are optional.",
"",
" at Document.validate (/var/www/vhosts/developer3.xyz/next.developer3.xyz/next-auth/node_modules/@prisma/client/runtime/index.js7741319)",
" at NewPrismaClient._executeRequest (/var/www/vhosts/developer3.xyz/next.developer3.xyz/next-auth/node_modules/@prisma/client/runtime/index.js7906517)",
" at /var/www/vhosts/developer3.xyz/next.developer3.xyz/next-auth/node_modules/@prisma/client/runtime/index.js7900252",
" at AsyncResource.runInAsyncScope (async_hooks.js1869)",
" at NewPrismaClient._request (/var/www/vhosts/developer3.xyz/next.developer3.xyz/next-auth/node_modules/@prisma/client/runtime/index.js7900225)",
" at Object.then (/var/www/vhosts/developer3.xyz/next.developer3.xyz/next-auth/node_modules/@prisma/client/runtime/index.js7911939)",
" at processTicksAndRejections (internal/process/task_queues.js975)"
]
}
}
}
],
"data": null
}Ryan
12/10/2020, 11:04 AMctx.userId
available? Because in your query you are passing it via a variable:
gorevlipersonel: { connect: { numara: $xxx } }
And in the resolver you are using ctx.userId
gorevliPersonel: { connect: { numara: ctx.userId } }
Ryan
12/10/2020, 11:05 AMconnect
and checking if it works. If it does, it means there could be an issue that the userId
is not defined in the context.Yiğit Rüzgar
12/10/2020, 11:05 AMYiğit Rüzgar
12/10/2020, 11:06 AMRyan
12/10/2020, 11:08 AMRyan
12/10/2020, 11:16 AMschema.prisma
doesn’t contain all the models that you have specified here. Could you add them to the repo so that I can reproduce?Yiğit Rüzgar
12/10/2020, 11:52 AMYiğit Rüzgar
12/10/2020, 12:00 PMRyan
12/10/2020, 12:00 PMYiğit Rüzgar
12/10/2020, 12:10 PMRyan
12/10/2020, 12:36 PMrules.ts
file.
I'll check what's the issue in the rule of createDraft2
Yiğit Rüzgar
12/10/2020, 12:36 PMRyan
12/10/2020, 12:50 PMisGorevlendirmelerOwner: rule({ cache: 'contextual' })(
async (_parent, { numara }, ctx: Context) => {
try {
const gorevli = await ctx.prisma.gorevlendirmeler
.findUnique({
where: {
numara,
},
})
.gorevlipersonel()
console.log('bayrak2')
return ctx?.userId === gorevli?.numara
} catch (e) {
return e
}
}
),
There’s no such variable as numara
in the args.Yiğit Rüzgar
12/10/2020, 12:55 PMRyan
12/10/2020, 12:58 PMargs
are you passed in createDraft2
like the data
.
createDraft2(
data: {
surec_numara: 2
gorev_numara: 2
ana_gorev_numara: 4
ana_gorev: "6"
baslik: "assda"
tarih: "12/12/2020"
saat: "14:55:00"
termin_dk: 2
termin_gun: 2
termin_saat: 6
eklenme_tarihi: "12/12/2020"
eklenme_saati: "14:14:14"
aktif: "1"
bitirilmesi_gereken_tarih: "12/12/2020"
bitirilmesi_gereken_saat: "14:14:12"
bitirme_tarihi: "12/12/2020"
bitirme_saati: "16:16:16"
bitirme_notu: "asd"
ekleyen_numara: 6
opsiyonel: "6"
gorevlipersonel: { connect: { numara: $xxx } }
}
) {
baslik
}
}
Here the data
is the args. that you have passed.Yiğit Rüzgar
12/10/2020, 12:59 PMRyan
12/10/2020, 1:01 PMYiğit Rüzgar
12/10/2020, 1:03 PMRyan
12/10/2020, 1:05 PMisGorevlendirmelerOwner: rule({ cache: 'contextual' })(
async (_parent, _args, ctx: Context) => {
try {
const gorevli = await ctx.prisma.yonetim.findUnique({
where: {
numara: ctx.userId,
},
})
console.log('bayrak2')
return ctx?.userId === gorevli?.numara
} catch (e) {
return e
}
}
),
Yiğit Rüzgar
12/10/2020, 1:47 PMYiğit Rüzgar
12/10/2020, 2:15 PMRyan
12/10/2020, 2:26 PMrules.ts
Yiğit Rüzgar
12/10/2020, 4:48 PMRyan
12/11/2020, 5:34 AMdate.toISOString()
Yiğit Rüzgar
12/11/2020, 2:07 PM