Skip to content
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

fix(GRAPHQL): fix empty remove in update mutation patch, that remove all the data for nodes in filter. #7563

Merged
merged 4 commits into from
Mar 15, 2021

Conversation

JatinDev543
Copy link
Contributor

@JatinDev543 JatinDev543 commented Mar 15, 2021

We have this behavior of update mutation where we are deleting all the data for nodes that are selected in the filter when we give empty remove {} in the update patch.
For example in the below case , we delete everything for node with id 0x123


mutation updateAuthor($patch: UpdateAuthorInput!) {
      updateAuthor(input: $patch) {
        author {
          id
        }
      }
    }

variables:

{
    "patch": {
      "filter": {
        "id": ["0x123"]
      },
      "remove": {}
    }
}

This can be more dangeours if we apply filter also empty like below, in that case it will delete every node of type Author.

{
    "patch": {
      "filter": {
        "id": ["0x123"]
      },
      "remove": {}
    }

We are now changing this behaviour , such that empty remove{}, doesn't have any effect.


This change is Reviewable

@JatinDev543 JatinDev543 requested a review from pawanrawal as a code owner March 15, 2021 06:16
@github-actions github-actions bot added the area/graphql Issues related to GraphQL support on Dgraph. label Mar 15, 2021
graphql/resolve/update_mutation_test.yaml Outdated Show resolved Hide resolved
graphql/resolve/mutation_rewriter.go Show resolved Hide resolved
graphql/resolve/mutation_rewriter.go Show resolved Hide resolved
graphql/resolve/mutation_rewriter.go Show resolved Hide resolved
@JatinDev543 JatinDev543 merged commit 6937427 into release/v21.03 Mar 15, 2021
@JatinDev543 JatinDev543 deleted the jatin/GRAPHQL-957 branch March 15, 2021 08:35
aman-bansal pushed a commit that referenced this pull request Mar 16, 2021
…all the data for nodes in filter. (#7563)

We have this behavior of update mutation where we are deleting all the data for nodes that are selected in the filter when we give empty remove {} in the update patch.
For example in the below case , we delete everything for node with id 0x123


mutation updateAuthor($patch: UpdateAuthorInput!) {
      updateAuthor(input: $patch) {
        author {
          id
        }
      }
    }
variables:

{
    "patch": {
      "filter": {
        "id": ["0x123"]
      },
      "remove": {}
    }
}
This can be more dangeours if we apply filter also empty like below, in that case it will delete every node of type Author.

{
    "patch": {
      "filter": {
        "id": ["0x123"]
      },
      "remove": {}
    }
We are now changing this behaviour , such that empty remove{}, doesn't have any effect.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/graphql Issues related to GraphQL support on Dgraph.
Development

Successfully merging this pull request may close these issues.

2 participants