I have a sql table looking like this:
| ID | Product | User | Status | CreatedDate |
|---|---|---|---|---|
| 1 | Cheese | John | New | 2022-02-07 |
| 2 | Milk | Steve | Pending | 2022-06-12 |
| 3 | Juice | Steve | New | 2022-06-10 |
| 4 | Beer | Lloyd | Finished | 2021-12-01 |
| 5 | Apples | Luis | Finished | 2022-05-10 |
| 6 | Oranges | John | Pending | 2022-05-10 |
| 7 | Carrots | John | New | 2022-06-23 |
| 8 | Cookies | Fred | Canceled | 2021-11-07 |
| 9 | Jelly | Luis | Pending | 2021-05-30 |
On web page, I am showing this table in pages, by 3 item:
Page 1:
| ID | Product | User | Status | CreatedDate |
|---|---|---|---|---|
| 1 | Cheese | John | New | 2022-02-07 |
| 2 | Milk | Steve | Pending | 2022-06-12 |
| 3 | Juice | Steve | New | 2022-06-10 |
Page 2:
| ID | Product | User | Status | CreatedDate |
|---|---|---|---|---|
| 4 | Beer | Lloyd | Finished | 2021-12-01 |
| 5 | Apples | Luis | Finished | 2022-05-10 |
| 6 | Oranges | John | Pending | 2022-05-10 |
etc.
Now, using odata query, I can filter this table using such query:
/odata/products?$filter=Status eq 'New'
or
/odata/products?$filter=CreatedDate eq '2022-05-10'
I am creating such filters dynamically.
Now, for filtered or unfiltered results I would like to retrieve distinct list of, for example, Users or Statuses:
- to get distinct list of Users for status 'New' I am sending for example this odata query:
/odata/products?$apply=filter(Status eq 'New')/groupby((User)) - to get distinct list of Statuses for selected User I am sending for example this odata query:
/odata/products?$apply=filter(User eq 'Steve')/groupby((Status))
How can I achieve something similar using graphql, especially with HotChocolate?
Receiving filtered results are simple - just create a query with filtering and paging. But what about retrieving distinct values from filtered dataset? Such a query must not use paging - we should get distinct values from all pages, not just from page 2 for instance.