I wanted to propose the addition of an optional parameter in commitMutation shared with the network interface, in order to allow add extra information during the execution of the mutation.
This parameter will be very useful in offline contexts, but I think it is also useful for other use cases.
Can鈥檛 you use updater?
No, because that function is not used by the network.
perhaps an example makes it clearer:
as is
const source = this._network.execute (
operation.node.params,
operation.variables,
{force: true},
uploadables,
);
to be
const source = this._network.execute (
operation.node.params,
operation.variables,
{force: true},
uploadables,
extra
);
This is what what CacheConfig (the third {force:true} arg in your example) is intended for. There's an optional metadata property that can be any object w whatever info you need.
Great news, my problem is solved :) maybe it could be useful to add this property in commitMutation too:
commitMutation(environment, {
mutation,
variables: {
input,
},
extra
})
and to modify RelayModernEnvironment to use it as you suggested:
{force: true, metadata: extra }
what do you think?
Yeah, totally reasonable to add CacheConfig as an optional arg to those methods. For executeMutation it鈥檚 a bit awkward though bc force:false doesn鈥檛 make sense.
Perhaps it is sufficient to create a subtype with a different name :)
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
Yeah, totally reasonable to add CacheConfig as an optional arg to those methods. For executeMutation it鈥檚 a bit awkward though bc force:false doesn鈥檛 make sense.