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

Mutation with variable declaration and with no variable JSON attached deletes all table records #2785

Closed
matjazrak opened this issue Aug 27, 2019 · 3 comments

Comments

@matjazrak
Copy link

Hello,
I have a cost table defined (Hasura v1.0.0-beta.4) with two fields:

id: Integer
description: Text

If I run the mutation on cost table with variable ID declaration:

mutation ($ID: Int) {
delete_cost(where: {id: {_eq: $ID}}) {
returning {
id
}
}
}

and no variable JSON is attached, the mutation deletes ALL RECORDS in the table cost.
It should not delete any records.

@leoalves
Copy link

leoalves commented Aug 27, 2019

Hi @matjazrak,

There is an open issue for this same case.
#704

Meanwhile, you can make the id mandatory in your mutation. This will return an error if no variable is passed.

mutation ($ID: Int!) {
  delete_cost(where: {id: {_eq: $ID}}) {
    returning {
      id
    }
  }
}

@matjazrak
Copy link
Author

Hi @leoalves,

thank you for your feedback. I agree with the others: the {} should be treated as NULL and not as %. (I’m comming from T-SQL world :)).

Kind regards, Matjaz

@marionschleifer
Copy link
Contributor

I'm closing this in favour of #704.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants