-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
API for client-side field/argument resoluton #431
Comments
@johanobergman Thanks for posting! This is one example of a larger pattern of use-cases where certain argument values may describe a strict subset of data that has already been fetched. In these cases there is an opportunity to allow clients to inject some amount of custom behavior and potentially "resolve" calls locally. Some challenges include determining an appropriate API and managing access to the Relay store (so that applications can inspect what data has been fetched). I'm going to mark this as an enhancement so it stays on our radar. |
I wonder if it would be possible for you to implement this using connections and cursors? |
@nickretallack The OP is using connections and cursors. The issue here is that Relay treats field arguments as opaque values and can't automatically optimize for the fact that the results for some argument values may be strict subsets of the result of already cached argument values. E.g. the items for March 1 - April 1 don't need to be fetched from the server if Jan 1 - Dec 31 are already fetched. |
I have another question. What if I add a new edge to a connection with arguments like the ones above? I might have had multiple fetches with different dates as arguments. Can I somehow tell |
I meant if you made the startDate be a cursor value instead of an argument. Not sure what you'd do with the endDate though, or how relay could be smarter about handling it. Just putting forward a more generic way of modeling the problem. |
@johanobergman - Would you mind posting this second question to Stack Overflow? Doing so keeps the issues here targeted around bugs and enhancements, while Stack Overflow provides an experience tailored for general Q&A and a wider audience to help get your question answered faster. Thank you! |
This reminds me a lot of a related issue of being able to have something like "typed nodes", where e.g. if I am fetching |
Some brief notes about how I'd approach this architecturally (in the new core #1369):
|
I'm sorry this issue has sat here for so long. In an attempt to clean up our issue queue we're closing some aging or unclear-action issues. Also, while this issue applies to Relay Classic, our team is trying to focus on Relay Modern going forward. If this is something you'd like to see happen, then we'd be happy to review a pull request. If this issue is still important to you, please feel free to reopen it with an update. |
Use case: I have a calendar with events, for which I have a query with two arguments,
startDate
andendDate
.Sometimes, I have to expand or narrow the range, or completely change it, all based on user input. But everytime Relay sees a pair of arguments it hasn't seen before, it goes over the network to fetch the data.
If the arguments
(startDate: 2015-01-01, endDate: 2015-03-01)
are changed to(startDate: 2015-02-01, endDate: 2015-02-20)
, ideally no fetch would be needed. It would be great if we had an API that could teach Relay how to handle the arguments on a case by case basis. I thought about this myself for a while and came up with the following API (forgive me for being pretty ignorant of Relay's internals).I'd love to see something like this get implemented, and I'm sure it covers many use cases.
The text was updated successfully, but these errors were encountered: