Disable variables serialization cache
We're trying to upload file thru useMutation and pass File to mutation argument.
But because of variable serialization via WeakMap GC cannot clear cache.
How can we disable this cache for variables serialization?
WeakMap is by definition allow garbage collection and is prune to lost anytime, what exactly is the problem you are observing?
We have crash of the browser on the devices with small amount of memory
It should be possible to have a core client configuration to globally disable serialization cache, but doing it per query/mutation is impossible.
But at the same time, the cache should be garbage collected with WeakMap, this is might be unexpected behavior from the js engine.
On the other hand, the serialization is being weakly cached because the client logic requires very frequent serialization of variables and data, and disabling it might mean slower performance, but I can see the requirement of gqty being run in devices with very low memory where having the serialized version of "every" object is already too much extra memory usage
But at the same time, the cache should be garbage collected with WeakMap, this is might be unexpected behavior from the js engine.
After further investigation, I came to the conclusion that the problem is not in WeakMap, but in stringsHash in the module SelectionManager.ts https://github.com/gqty-dev/gqty/blob/cbb3e583acc77d7e87c874559c8c674ca6effec5/packages/gqty/src/Selection/SelectionManager.ts#L122-L132.
After further investigation, I came to the conclusion that the problem is not in WeakMap, but in
stringsHashin the moduleSelectionManager.tshttps://github.com/gqty-dev/gqty/blob/cbb3e583acc77d7e87c874559c8c674ca6effec5/packages/gqty/src/Selection/SelectionManager.ts#L122-L132.
Interesting, thank you for taking the time for it, the issue here is that gqty needs to keep track of the serialized version of the variables to be able to know what unique alias corresponds to a specific query, one alternative would be to hash the variables into a short version, but that would be a lot slower 😢