bobbyt
11/16/2017, 10:53 PMPost
type with a Tag
field with a many-to-many relationship. When I run a mutation to update a `Post`'s tags, there are 2 Graphcool-generated parameters I can include:
• tags: array new tags to create and associate with this Post
(i.e., [{"name: "newTag1", "name": "newTag2"}]
)
• tagsIds: an array of `id`s of existing `Tag`s to be associated with the Post
(i.e., ["aabbccddeeffgg", "hhiijjkkllmmnn"]
)
If I only include tags
or tagsIds
in the mutation, it works as expected. However, if I pass both parameters, only the new `Tag`s will be created an associated - the other existing Tag
ids I pass are not associated.
This combined method is mentioned here, but does not seem to be functioning as expected: https://www.graph.cool/forum/t/how-do-i-add-an-array-of-objects-to-a-mutation-in-apollo-react/365/6
Combined
You can also use tags and tagsIds in the same mutation, this would connect the new Tutorial node to all the tags in tagsIds and connect it to the new tags in tags. This is what you want to do if you want to only allow tags with a unique text, so for a new Tutorial, there will likely be some tags that already exists, and some that need to be created.Thanks in advance for any guidance.