After reading the API docs about nested mutation (...
# orm-help
s
After reading the API docs about nested mutation (https://www.prisma.io/docs/reference/prisma-api/mutations-ol0yuoz6go#nested-mutations), i'm a little lost on how I could write resolvers for nested mutation in the application layer... Does anyone have learning resource(s) for this ? 🤔
n
are you familiar with writing resolvers for "simpler" mutations using
prisma-binding
already? 🙂
s
I would say I understand the basics, that
prisma-binding
pass the generated schema from
prisma.graphql
to the context argument of each resolver functions.
n
ok 🙂 you can see one possible way of writing a nested mutation in your own resolver here: https://github.com/graphql-boilerplates/node-graphql-server/blob/master/advanced/src/resolvers/Mutation/post.js#L4-L19
s
Than you nilan for this example 👍. Seems pretty forward when it comes to
connect
to schema's Types, but when you need to
create
or
update
multiple nodes, what the
args
should look like ? Can we pass array to arguments of a mutation ?
n
the JS spread operator will come in handy in this case 🙂
😎 1
s
Oh yes you're right. It seems essential for this. Do you know if I can do something like this in my schema definition ?
Copy code
type Mutation {
 newUser(name: String!, posts: [Post!]!): User!
}
It throws me an error
must be Input Type but got: [Post!]!.
n
you cannot 🙂 please look into the generated
prisma.graphql
file for the
createUser
mutation and use the input type used there
🦜 1
🤩 1
you need to import that type into your schema file as well
s
Ooooh okay ! Now I get it. Awesome🔥 Thank you so much nilan for your time 🙂
🏃‍♂️ 1
🙌 1