-
-
Notifications
You must be signed in to change notification settings - Fork 15
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
error executing mutations offline without the network parameter #15
Comments
Hi @lawrenz1337, Thank you, |
The funny thing is that there are no errors. The data is being stored in the localStorage and afterwards it just doesnt do anytning. And I am pretty sure that I don't have any fetch policies |
If no recovery policy is selected, relay uses network_only. Among the added features I have provided "fetchPolicy CACHE_FIRST (which is version 1.0.0 I will change to STORE_OR_NETWORK)" This policy allows you to take advantage of the local cache and avoid invoking the network. Furthermore, when the application is offline, the library will automatically use the STORE_ONLY policy. |
In this repository I created the version relay-hooks respecting as much as possible the indications of what will be the official version. In the next version I integrate the logic of the query renderer (useQuery) also in this repository. Here you can find more information: relay-hooks issue 5 Please ask for any questions. |
@morrys so basically what you are saying if I change fetchPolicy to CACHE_FIRST it will hydrate the store and work properly? |
I say that the store is always rehydrated, but this is evident with the CACHE_FIRST policy because the execution of the query is avoided. If you use network_only and the application is online, the store is not used (as it should be). Did I explain myself well? :) |
Ok, so do I need to define a refetchContainer for each query i need to be refetched and pass |
It's enough import {QueryRenderer} from 'react-relay-offline';
<QueryRenderer
environment={environment}
dataFrom="CACHE_FIRST"
... |
Sorry but it still doesn't work :( Data that i send offline never reaches the server... Maybe I could write the steps I did and we can pinpoint the problem there?
After those steps nothing gets sent to the server. I still think that this is cause by |
Don't worry, I realized that you had problems in restoring the store ... can you try adding these offline options and tell me the outputs on the console after you have done step 4 again?
Thanks |
Maybe you found an error :)
thanks :) |
@morrys Yep, it fixed it! Thanks a lot! but why is that parameter optional? and what does it do exactly because I couldn't find any docs about it |
@lawrenz1337, this is what I wrote in README.md (I'm working on better documentation through docusaurus)
It is optional because by default it uses the same network set in the environment. I advise you, at the beginning, to always use these options offline in order to be able to debug what is happening in the offline store :) Thank you for reporting, please ask or open other issues for any information. Lorenzo |
@morrys The thing that confused me the most was that it didn't throw any exceptions to the console and I didn't see any errors until you gave me that debugging code. Thanks for the help :) Mikhail |
I add a note in the project to think of a better error report or a utility to log :) It is thanks to the contribution of those who use this library that you get to have a better result :) |
@lawrenz1337, with the version 0.8.1 of react-relay-offline the network parameter is optional again :) Let me know if you can confirm it too :) thanks again Lorenzo |
@morrys Thanks for that but I will wait to update to 0.8.1 :) Probably will update next week. Cheers |
Meanwhile I close the issue, if you find other problems we reopen it :) |
Hello!
I use Create-react-app for the application and thus I use
import graphql from "babel-plugin-relay/macro";
because I don't have a customizable.babelrc
. The library seems to work one way. It stores everything into the localStorage but when the connection is back it just doesn't do anythingThe text was updated successfully, but these errors were encountered: