React-apollo: useMutation Tuple signature inconsistent with built-in hooks

Created on 27 Jun 2019  路  6Comments  路  Source: apollographql/react-apollo

To help reduce potential confusion, would it make more sense for the MutationTuple to be ordered [ MutationResult, MutationFunction ] and remain consistent with all of the built-in hooks? I've been following this pattern in custom hooks, as it always ensures that the value at index 0 is the value to bind against.

confirmed

Most helpful comment

@hwillson Would you consider bringing back the previous version? The reason is that in many cases, the mutation result is not needed, e.g. I mostly use mutations with a form library where the loading and error state is stored. Please look at the following comments:

All 6 comments

Hmm - great point @stephengfriend. We modeled the useMutation API off of the react-apollo-hooks changes proposed in https://github.com/trojanowski/react-apollo-hooks/pull/135. People seemed to like the idea of that approach, but I agree with your reasoning. I'll bounce this idea around with the team, and post back shortly. Thanks!

Okay, we want to do this. This is a breaking change which in theory should be okay since we're still in beta, but the cutover will be annoying for people. We'll try to mitigate that somehow. Thanks!

That's great news. I'm very excited for this to land in react-apollo and appreciate the willingness to consider it. 馃挴

@hwillson Would you consider bringing back the previous version? The reason is that in many cases, the mutation result is not needed, e.g. I mostly use mutations with a form library where the loading and error state is stored. Please look at the following comments:

Thanks @trojanowski - that is definitely a compelling argument. Okay, there's a good chance we'll switch back on this. I'll digest this a bit more, and post back shortly. Thanks again!

Original ordering is better. Like lots of comments said, we don't need mutation result in most of cases. Please consider to revert it.

Was this page helpful?
0 / 5 - 0 ratings