graphile / graphile/crystal

PostGraphile live query on totalCount ignores decrements

Open
#1,241 1 comment 2 reactions 0 assignees View on GitHub
🌿 live-queries
Dominant language
TypeScript
Stars
12.9k
Forks
625
Avg merge
5h 23m
Merged PRs (30d)
24

Description

I'm submitting a ...

* [x] bug report
* [ ] feature request
* [ ] question

PostGraphile version: 4.5.0

i raised this problem in stack overflow as well:
https://stackoverflow.com/questions/60435894/postgraphile-subscription-on-totalcount-with-filter-ignores-decrements?noredirect=1#comment106934239_60435894

**Current behavior:**
The totalCount increases whenever I INSERT or UPDATE a Product so it complies to the condition. However, it never decreases when I DELETE or UPDATE a Product to no longer comply to the condition. The problem occurs both in my application and in GraphiQL.

I use postgraphile-plugin-connection-filter for the filter but removing it did not change the issue.

```
subscription getTotalNewProducts {
orderProducts(
condition: {state: "NEW"},
filter: {scheduledDate: {greaterThanOrEqualTo: "2020-02-27", lessThan: "2020-02-28"}})
{
totalCount
}
}
```

**Expected behavior:**
A workaround is adding nodes to my result. When I add nodes with some arbitrary property, the subscription behaves correctly. Like so:
```
subscription getTotalNewProducts {
orderProducts(
condition: {state: "NEW"},
filter: {scheduledDate: {greaterThanOrEqualTo: "2020-02-27", lessThan: "2020-02-28"}})
{
totalCount
nodes {
productId
}
}
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.