Is it possible to use prisma types in query / mutation args? #768
-
Is it possible to use prisma types in query / mutation args? I get the following error:
schema.objectType({
name: 'Post',
definition(t) {
t.model.id()
t.model.title()
t.model.body()
t.model.author()
},
}) t.field("getPost", {
type: "Post",
nullable: true,
args: {
post: "Post",
},
resolve: async (parent, { post }, ctx) => post,
}); |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Oh got it, needed to be an input type |
Beta Was this translation helpful? Give feedback.
-
@ryanking1809 Ideas on how to go about mapping a schema-based input type to a mutation input arg? It doesn't accept the input type unless I add the "crud" mutation as well (which I don't want). t.field('updateProfile', {
type: 'Profile',
args: {
// How do I use the input type ProfileUpdateInput here?
update: schema.arg({ type: 'ProfileUpdateInput' }),
},
resolve: async (_parent, { update }, ctx: MyContext) => {
// Remove null values
const prunedUpdate = omitBy(update, isNull);
// Update profile
return ctx.db.profile.update({
where: { userId: ctx.user?.id },
data: prunedUpdate,
});
},
}); It throws // I don't want to add this
t.crud.updateOneProfile(); |
Beta Was this translation helpful? Give feedback.
Oh got it, needed to be an input type
PostWhereUniqueInput