We are attempting to add local data to the store because we keep a local schema that allows us to have client only fields. We have been using commitLocalUpdate calls whenever we wanted to change some client only fields. We came across a case where we want to update a bunch of data, and not just a field at a time. When using the store API from something like commitLocalUpdate I would like to have the ability to set a query response to the store with the same ease of creating an optimisticResponse
My first thought was that I could just do a regular mutation and intercept it in the network layer. This seems hacky.
Next, I thought, okay, how about giving commitLocalUpdate the same interface as normal mutations. This seems like forcing a square peg in a round hole.
Now I'm thinking, maybe there should be some kind of bulk insert API for the store. It would make the imperative store API so much more accessible to us mortals.
I would love to talk this through and would be happy to provide a pull request. I know how important encouraging the right usage of the framework is, so I would be happy to discuss the implications of this also.
I'm curious to hear what kind of local data you have that's so big to put into the store? This is certainly a field I think we haven't explored enough yet. Maybe Relay could even cover some redux style use cases!
If you use true local schema extensions that are parsed by the Relay compiler, we currently can't do this easily.
The Relay compiler generates 2 types of generated files:
I use graphql's little known extend schema functionality to add my local stuff. Then I use something I wrote called graphql-mask to filter out local data from queries.
I'm not sure how most people do client only data, but for me I like to keep it all in relay.
@brysgo do u have a repo example with these ideas?
I'd be happy to throw one together to show how I'm doing local data.
Alright, just threw this togeather really quick so don't judge. Basically, it is an example of how I am using client schema extensions instead of something like redux so that my front end data can all operate through one model.
@brysgo it looks this repo is private yet
Here it is https://github.com/brysgo/relay-example @sibelius
Sorry for the broken link. Thanks @hisapy for the assist.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Most helpful comment
@brysgo do u have a repo example with these ideas?