Graphql + MongoDB : updating a deep nested object [Partial Update the object]

99 views Asked by At

I have a huge database with 1000s of records. There are different types of "Groups" and each child object(group assignments) has different levels of nesting, (refer to the code below)

mutation UpdateGroup($input: GroupUpdateInput!) {
  updateGroup(input: $input) {
    id
    isActive
    ChildA{
      nameA
      ChildB{
        id
      }
    }
  }
}

As you can see when I want to update just one nested object. It becomes really hard to manage and keep track of what is being modified. What is a good solution to approach this issue. I know this question is difficult to explain but please let me know if I can make something more clear in the comments. I will try to produce a working sample but it could take time because the codebase is very huge

  "input": {
    "id": "6231107602d54a291d29",
    "name": {
      "language": "en-US",
      "text": "Test Update Group"
    },
    "isActive": true,
    "code": "127",
    "benefit": {
      "provider": "Group Provider1",
      "benefitOptions": [
        {
          "id":"6234b20e6a941cdcbd72",
          "name": [
            {
              "language": "en-US",
              "text": "Benefit Option 1"
            }
          ],
          "assignedProfileIds": ["6231101d02d54d297c6c","6231101e02d54a297c6d"]
        }
      ]
    }
  }
}
0

There are 0 answers