doug-martin / nestjs-query

Easy CRUD for GraphQL.
https://doug-martin.github.io/nestjs-query
MIT License
820 stars 142 forks source link

[QUESTION] Create record and relation with related entity with single mutation (Many to Many) #1509

Open pratiksyngenta opened 2 years ago

pratiksyngenta commented 2 years ago

Setup:

NestJs TypeOrm Nestjs-Query PostgreSQL

I understand, when specifying a @OffsetConnection relation a couple of endpoints will automatically be generated. In this example the following are generated. ie. => addSubTasksToTodoItem - A mutation to add SubTasks to a TodoItem

How can I create record and relation with related entity with single mutation (Many to Many relationship)?

I was thinking of using hooks, but I think all of the hooks are all @ Before[operation] so it would not help [as id would be generated after insert which we need to create relation entry]

hghammoud commented 2 years ago

I recently created a post before seeing this one that asks the same question #1514. I hope @doug-martin can shed some light on this.