-
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
Ideas for making LiveQueryStore more powerful #14
Comments
Hey @marcus-sa, thanks for your comment and showing interest 😊
Do you mean traversing and gathering the information about the schema?
I would like to not rely on a compiler on client-side to it accessible for more people.
I would love it if you could experiment with gathering resource identifiers or even better come up with a solution that works better than the current I also just opened a PR for supporting fragments in the current implementation: #82 Maybe it could be possible to abstract the method for gathering the resource identifiers into an API so different use-cases can use different ways of gathering the resource identifiers? Does that make sense? |
I got too excited #94 |
Resource identifier collection is now implemented as part of #94 |
I wrote an article about the functionality https://dev.to/n1ru4l/collecting-graphql-live-query-resource-identifier-with-graphql-tools-5fm5 |
Thanks for this great toolset! Suggestion Following packages:
Are each including functions targetting both client and server. It's resulting to adding useless functions/code on the client and the server. My suggestion is to split each of those packages in two: one to "generate patches" and the other one to "apply patches". For example, I don't need the applyPatch function (because my client is not written in JS - see bellow question) but I'm compelled to import it server side. Question I'm trying to port the client part of "graphql-live-query-patch" into Dart - because I've got a Flutter client. EDIT: sorry for the stupid question, I just realized that AsyncIterableIterator is not mappable :/ |
This can be solved by doing modular imports, bundling, and dead-code elimination. I don't plan to split the logic into a client and server package. Repeater.js is used because it is too easy ending up with memory leaks while fiddling with AsyncGenerators/AsyncIterables. There been a few memory leak within this library before, all related to that. |
As you wish, but I think you miss my point by answering with modular imports/bundling solutions. |
The approach of calling
liveQueryStore.triggerUpdate("Query.users")
might not scale that well. It could return different results for different users. It does not address the unique field argument combinations.Resource-Based Updates
If a user with id
fgahex
changes we ideally only want to update queries that select the given user.Object types that have an id field could be automatically collected during query execution (and updated during re-execution).
Query
Execution result:
Will result in the following entry for the selected resources of that query:
User.fgahex
.An update for all the live queries that select the given user could be scheduled via
liveQueryStore.triggerUpdate("User.fgahex")
.Things to figure out:
What is the best way of collecting resources?
This would require sth. like a middleware for each resolver that gathers the ids and attaches them to the result (as extensions?) that the liveQueryStore can pick up (maybe this?).
Another solution would be to push this to the user so he has to register it manually, by calling some function that is passed along the context object?
The information could also be extracted from the query response. However, that would have the implications that it needs at least the
id
extracted for each record (or evenid
+__typename
for GraphQL servers that do not expose unique ids across object types). Since most client-side frameworks encourage using unique ids for identifying Objects anyways that shouldn't be that big of a limitation. An additional drawback would be that the whole result tree must be traversed.Pros:
triggerUpdate
for the previous resource).Cons:
id
property.The text was updated successfully, but these errors were encountered: