Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to manually update Relay store without querying server?

Tags:

relayjs

Let's say I have some data that I obtained through a non-graphql endpoint for example from third party server (firebase).

How do I put the data into the local relay store? Is there an easy way to add / edit / overwrite data to relay store directly without going through query or mutation?

like image 253
Joon Avatar asked Oct 19 '22 05:10

Joon


1 Answers

A non public RelayStoreData field is accessible from the Relay.Store instance and it gives you direct access to the records contained in the store. I haven't done anything with this myself but you could try modifying the cache directly like this:

RelayStore._storeData._cachedStore._records[recordId][fieldName]=newValue

like image 69
Igorsvee Avatar answered Jan 04 '23 06:01

Igorsvee