It's sometimes unbelievable how many bugs you find when doing
refactoring. This time there was some apparent confusion about
`commentsCount` and `commentedCount`. The counters on the post card were
never showing the correct number.
I think the validation for categories was too complex and the graphql
query 'PostEmotionsByCurrentUser' was erroneously allowed for
unauthenticated users.
- if there are no ids, we shouldn't add an empty array since it adds unneccessarily to our auto-generated post query and affects greatly performance. see issue #1390
@mattwr18 I prefer (I believe it's even best practice) that a delete
mutation should return the deleted object. If you run the delete
mutation again, it should return `null` because there is no object like
that anymore. That way the client knows if a delete mutation has changed
any state in the database.
Also I fixed another bug in the resolver. If your graphql mutation looks
like this:
```gql
mutation {
RemovePostEmotions(to:{ id:"p15"}, data:{emotion: angry}) {
from {
id
name
}
to {
id
title
}
emotion
}
}
```
Then you get errors because your resolver does not return the name for
the user or the title for the post anymore. Just use spread operator...
and it's fixed.
- use UNWIND instead of iterating over categories(cypher magic)
- do not return nested categories on post creation as it's expensive and we don't use
- refactor backend test
- component tests for CategoriesSelect