I'm trying to give a type to the members of below function.
args
is an object with a data
property of type UserCreateInput
So, from this:
createUser(parent: any, args: any, context: any) {
return context.prisma.createUser(args.data)
}
I wrote this:
createUser(parent: any, args: {data: UserCreateInput}, context: any) {
return context.prisma.createUser(args.data)
}
I'm not sure how to replace 'xxx' in createUser(parent: any, xxx, context: any)
so I can simply return return context.prisma.createUser(data)
You can use the object de-structuring syntax:
createUser(parent: any, { data }: { data: UserCreateInput }, context: any) {
return context.prisma.createUser(data)
}
Unfortunately it is required you write data
twice. There is a proposal to fix this but there are issues around this.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With