-
-
Notifications
You must be signed in to change notification settings - Fork 457
Description
Describe the bug
When I want to both sync existing relations and create a new relation on a BelongsToMany
or MorphsToMany
relationship, the order of the fields in the input type influences if the relation is actually stored or not. For example, if create
comes before sync
in the input type, the relation is created but sync is executed after the create, thus removing the relation with the newly created one. Once the sync
key is moved before the create
key, the sync happens before the create, thus making sure all relations are still set.
Expected behavior
When syncing and creating both in one mutation, the created entity should be linked, not only the synced. There should not be a dependancy on the order of the fields in the schema to get this to work.
Schema
This input does sync and store, but does not keep the relation of the stored tag
input UpdateTagRelation {
create: [StoreTag!]
connect: [Int!]
sync: [Int!]
disconnect: [Int!]
}
This input does sync and store, and keeps the relation of the stored tag.
input UpdateTagRelation {
sync: [Int!]
create: [StoreTag!]
connect: [Int!]
disconnect: [Int!]
}
Environment
Lighthouse Version: dev-master
Laravel Version: 5.8
PHP Version: 7.2