Last active
March 13, 2019 06:34
-
-
Save coco98/9d82133e4d760c1d8c8466e9c13bf094 to your computer and use it in GitHub Desktop.
single mutation to update relationships
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Without query variables | |
mutation updateChildren { | |
delete_children(where: {parent_id: {_eq: 1}}) { | |
affected_rows | |
} | |
insert_children(objects: [{name: "child1", parent_id: 1}, {name: "child2", parent_id: 1}]) { | |
affected_rows | |
} | |
} | |
####################################################### | |
#With query variables | |
mutation updateChildrenWithQueryVars ($parentId: Int!, $newChildren: [insert_children_input!]!) { | |
delete_children(where: {parent_id: {_eq: $parentId}}) { | |
affected_rows | |
} | |
insert_children(objects: $newChildren) { | |
affected_rows | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment