-
-
Notifications
You must be signed in to change notification settings - Fork 438
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dealing with attributes on the pivot table of a BelongsToMany relation #691
Comments
For future-reference, here is an excerpt from the discussion of #692: When you think about what the In terms of your concrete example, you should be able to update a medication like this: mutation {
updateMedication(input: {
id: 1
name: "Lysergicream"
# That would be a HasMany relationship from Mediation to the pivot model
medicationUser: {
update: [{
dose_mg: 11
# This is a belongsTo relationship from your pivot model to User
user: {
connect: 1
}
}]
}
}) {
id
name
# Will return a list, as this is a HasMany relationship
medicationUser {
dose_mg
# A single BelongsTo
user {
id
name
}
}
}
} I think we should add a section about how to deal with pivot attributes to the docs. Queries are affected too and should be considered. |
Thanks. Meanwhile I made my custom fork to work around this, but it seems it's finally time to update to this release! |
@spawnia |
You can use the following channels to ask support questions: This repository and the issue tracker are used to advance the development of Lighthouse. |
Situation
I'm trying to implement @update on a belongsToMany relationship. The pivot table also has columns I want to update, like this:
my example schema:
Problem
I get an SQL error that laravel can't find the columns (of course, they don't exist because they are on the pivot table) on the related table to update.
I debugged it down to the
executeUpdate
function inMutationExecutor.php
, where the pivot property is still inside$remaining
and gets treated as a normal property on the related Model instead of the special case of being pivot columns.Expected
pivot columns should be updated,
Workarounds
there was a workaround suggested:
by @spawnia in this issue thread #549
The text was updated successfully, but these errors were encountered: