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
[DOCS] Docs should state that persistCache should be awaited #62
Comments
Also since
Is there a better way to deal with the async propagation of EDIT: Actually there's a good solution in the docs |
Yes. Docs are not clear about it. |
Hey, I just opened #97 to clarify the matter, and to make it clear at first glance. Feel free to edit/comment! |
Goinig to make minor edit and merge. Thanks |
@adrienharnay how are you |
No, this is pseudo-code. Though you can wrap the code in a function and call it.
|
@adrienharnay but this won't block other JS files from being read, so effectively it does not block queries from running. Is the assumption that there won't be a race condition between this file being read and another file that will run a query? Also, it doesn't address how to |
Updated my gist to showcase that what you want is possible.
|
I think if we talking react we probably looking for something that will not hold render but provide some nice I think good example will just have |
Btw.. I really love this discussion, because it made me realized that I was doing react wrong for long time. Getting examples correct is really important. |
If your intention was that the context of the Even in your updated gist, it seems there's nothing that prevents a separate file from calling More generally, where I'm going with all this is: prior to using this library, I've seen examples that encapsulate creation of the Apollo instance in a separate JS file, and since there is no asynchronous function call constraint, it can create and export the client easily:
Then in the
IMHO, since this library adds an asynchronous function call as part of the client setup, I think it would make sense to use the approach shown in the RN example as the general example, so it emphasizes how to address the need to block before anything calls the client before the How does that sound? I'd be glad to do a PR to update the docs. |
Here's an example of a HOC that could handle this, using React hooks:
It doesn't show a |
@twelve17 This code is exactly what I had before I realized I needed to asynchronously load polyfills before my app could start, so I put all my async tasks in |
We now support synchronous API. Docs were updated |
We still can provide docs for awaiting. Another element is to create separate react package later when monorepo will be done |
Docs fixed |
Hey,
It is not clear in the documentation that
persistCache
is async and should be awaited.Removing
await
breaks persistence, because the first queries will resolve before the cache is persisted, and won't resolve again when it is.Could you please confirm that this is by design (or maybe something else is causing this and I'm wrong), and tell me if I should open a PR to clarify this in the docs?
Thanks!
The text was updated successfully, but these errors were encountered: