-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multi-argument custom query invalidation doesn't seem to work #915
Comments
Ok by logging the generated indices, I can see what's going on. Here are some:
Non-string values seem to be cast to strings before generating the keys. Edit: Issue seems to come from here: graphql-live-query/packages/in-memory-live-query-store/src/InMemoryLiveQueryStore.ts Lines 91 to 109 in 17f5710
This doesn't seem right. |
What behavior would you consider instead? If the type would implement a |
@n1ru4l Well since the base scalars are JSON-ish, you could use |
Why couldn't your id type implement a toString method? class ID extends YourId {
toString() {
return this.toHexString()
}
} Relying on JSON.stringify is not safe and would require using something as https://www.npmjs.com/package/json-stable-stringify I do not recommend using complex types for indices. I think it is safe to say that indices should only be set on values that can easily be serialized to a string. |
You would still have the hard-coded double quotes, which can bring weird indices collision. For example imagine a nullable query argument of type |
I see your point, in that case, I think adding @strblr Would you like to create a PR with some tests and an implementation? |
In a project, I have lists of entities called "hypotheses" that need to be refreshed via live queries. These lists are fetched using the following query:
Hypotheses are tied to specific "laws" (identified by integers). The second argument
law
can benull
which returns all hypotheses regardless of their laws.I'm trying to invalidate based on a custom index that looks like this:
Here is the document I use on the frontend:
Now when creating an hypothesis with a
createHypothesis
mutation (resolver is successfully called), the following invalidation doesn't work:(
project._id.toHexString()
has the correct value)Any idea of what's going on? Thank you.
The text was updated successfully, but these errors were encountered: