Graphql Subscription query type
This is currently just a PoC.
The main challenge was to find a way to check for the changes in an efficient way. Using 2 requests per query depths, we limit the performance impact.
NOTE:
The time complexity is O(n) where n is the depth of the query, not the number of elements.
The number of elements does theoretically have an impact, but it's neglectable compared to the IO impact on time.
A code refactoring should be done as many features were added "on the spot".
Issues and limitations
Non specific change
A new result is sent whenever an object is changed even though it didn't impact the result (e.g. we changed field A but we don't use it in the query).
This part can be done by computing and checking hashes based only on the requested fields.
Computed fields
We cannot detect changes on computed, non stored, fields as they don't change the write_date field. This limitation applies to all Odoo, there is nothing we can do except manually monitor it which could be disastrous in terms of performance.
Worker Pool Starvation => Server Crash (?)
All implementation will systematically keep the worker open which could lead to "worker pool starvation": all workers are used, therefore Odoo cannot receive any other request.
I still need to confirm exactly the behavior but it's hard to imagine a stable solution for it.
I also need to experiment if this is still an issue with the latest version of Odoo, it's possible that now workers are able to take an unlimited number of requests.