-
Notifications
You must be signed in to change notification settings - Fork 462
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
RFC: Make passing of additional variables for optimistic updates explicit #3291
Comments
Sorry for coming back to this a little late. I don't think I see the intention here and the full solution as even feasible.
Anyway, I'll move on for a bit to the actual proposal; I don't think the reasoning here is necessarily justified for two reasons. Firstly, it assumes that user-controlled data is a concern for API design in Graphcache, i.e.:
Secondly, this assumes that the user has no additional knowledge at the call site, which isn't correct. In my opinion, bindings are a basically a boundary — we can think of them as crossing a UI framework to GraphQL. So, To summarise, I don't think this RFC crosses the threshold of fulfilling a need that is, as of now, unfulfilled. To address the ergonomic reasoning here, and talk about the API design, I'll come back to it being an escape hatch. In theory, given an optimistic update, the cache often contains enough information to create a sufficient optimistic shape without extra variables. This was further addressed by #3264 and #2616 The latter PR lies some time back but allows nested optimistic functions, which allows for more handling of nested optimistic fields without passing in extra data. The former, more importantly, now allows optimistic results to be almost fully partial. I'm open to more discussion here of course, but for now I'll close this RFC. I think without some signs of this being a bigger problem (and the escape hatch not becoming a typed part of mutations anyway), I think it's best to collect more cases and samples for this before considering any further change |
Summary
It is currently possible to pass in additional variables for optimistic updates, however at the point they are supplied, I believe this is quite confusing. Currently the extra args are mixed in with the args intended to be passed to the mutation:
I think this is opaque to somebody looking at the function call as there is no differentiation between mutation args and extra data.
Proposed Solution
Accept the extra data as an explicit
extraData
additional key on theoperationContext
, or as a key on a third-arg config object if you feel it doesn't belong there.The text was updated successfully, but these errors were encountered: