Hi everyone, Iet's say I have an example with type...
# orm-help
h
Hi everyone, Iet's say I have an example with type User and Group that are related to each other. Is there a way to create a new User and connect to Group in the same mutation? Right now, I have two separate queries: 1) Create User 2) Connect the two nodes
s
Sure! You can call a mutation and then do any calls you want in it that might be related to User, Group, getting that random temperature from an external API, cooking brownies, whatever! Whatever you are doing, that's the business of the resolver and as long as your input types and output types match what you define in the schema, you should be good.
h
Hm.. I don't need any business logic, just execute the mutations in sequence in one
mutation {}
If I do : mutation { one: createUser() two: connectUserToGroup() } will it run synchronously?
s
I’m saying run both functions in the single resolver. Resolvers should be made to call other independent functions that do different tasks. This helps with automated testing and reducing code duplication.
To answer your question, make them asyc await if you need them sequential
h
Thank you for explanation! I'll try it out
👍 1