Nested Mutation with Pivot model #2618
Unanswered
rafapaulin
asked this question in
Q&A
Replies: 1 comment 4 replies
-
You can split |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hey guys. So, I am posting this on the discussions, since I am not exactly sure if this is a bug (which seems so) or if it is just something that I am missing.
Consider the following schema:
...and the following Eloquent Models:
I am running the following mutation:
The expected result would be:
1- Customer and supplier connected through the pivot table
customer_suplier
2-
notes
added to pivot data oncustomer_suplier
3- A
Contact
created (upserted)4- The new
Contact
associated with thecustomer_supplier
relationship (id added tocontact_id
column oncustomer_supplier
pivot table)With the schema/models and the mutation I described above, I got 1 and 2 working, but 3 and 4 does not happen, and I am not being able to figure out why.
(Just as a side note: I have another "double-nested" mutation that uses that
ContactBelongsTo
input, which works. customer > users > create > contact > upsert)It seems that for some reason nested mutations does not get through Pivot models (
Illuminate\Database\Eloquent\Relations\Pivot
), even though the correct relationship is set.(btw, query that relationship works as intended)
Beta Was this translation helpful? Give feedback.
All reactions