How to manually update Relay store without querying server?

时间:2016-07-11 21:48:25

标签: 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?

2 个答案:

答案 0 :(得分:3)

可以从Relay.Store实例访问非公开RelayStoreData字段,它可让您直接访问商店中包含的记录。我自己没有做过任何事情,但你可以尝试直接修改缓存:

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

答案 1 :(得分:0)

我会在没有服务器的情况下使用relay,在本地定义graphql架构并从graphql架构中执行API请求,就像查询架构中的数据库一样。

https://github.com/relay-tools/relay-local-schema