-
Notifications
You must be signed in to change notification settings - Fork 168
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
removing by nonexisting ID deletes the last "record" #66
Comments
From what I'm seeing, the remove mutation deletes the last record regardless of whether the ID exists or not. |
I'm using version 2.1.3 from npm. If I start it with this data file:
then I run this mutation in GraphiQL:
I get this response:
Then I query for all orders again, and 12347 (the last one) is missing. 12345 (the one I told it to delete) is still there. |
The id attributes in your data files must be integers @pjweisberg @robertbbb — Unfortunately, if you create something using mutation (not initial data) and then attempt to remove it your response will be:
Interesting that only — it's a bug 😞 |
Interesting. Still a bug, but I guess that reduces the "how did anyone ever miss this?" factor. IDs still come out as strings in the query responses, which I why I didn't think of changing to integers. In the real world IDs will frequently be UUIDs (or at least alphanumeric), but in my current project I can get away with assuming they're integers. |
I completely agree. And so does Graphql:
I was going through the code and found this— see comment in the remove resolver: https://github.com/marmelab/json-graphql-server/blob/master/src/resolver/Mutation/remove.js So it seems the author is aware already. And it actually seems that the issue maybe on create. |
And there's the "remove last element" but, too. Not found, so indexOfEntity is -1, and that's what happens when you pass -1 into Array.splice(). That, at least, is easy to fix. |
PJ Weisberg's recent merge in fixed the problem of arbitrarily deleting the last item when no such item ID was found. There is still a problem with not being able to delete IDs specified as strings, but we found that a small change to src/resolver/Mutation/remove.js fixed that bug: export default (entityData = []) => (_, { id }) => {
}; |
I still have this problem :( Removing existing or non-existing elements causes mentioned behavior and it is very problematic for me |
Hi,
It seems that the remove Mutation, if it receives a nonexisting ID, will still remove something (at random?)
Otherwise thanks for a great tool.
The text was updated successfully, but these errors were encountered: