Skip to content
This repository has been archived by the owner on Apr 13, 2023. It is now read-only.

withMutation should support loading/error/called/data states #2952

Closed
slikts opened this issue Apr 11, 2019 · 4 comments
Closed

withMutation should support loading/error/called/data states #2952

slikts opened this issue Apr 11, 2019 · 4 comments

Comments

@slikts
Copy link

slikts commented Apr 11, 2019

Previous (closed) issues: #421 #1842

The graphql() (and withMutation()) HOCs currently have a surprising limitation in that the mutation results aren't passed by them, which isn't explained by the docs, and there also isn't an obvious reason for it. The natural expectation from reading the docs would be that HOCs and components would have feature parity (despite HOCs having fallen by the wayside to render props and more recently hooks) and would just be alternative APIs for the same functionality, especially since graphql() delegates to components under the hood. In other words, passing mutation results in withMutation() would follow the principle of least surprise.

The answer also shouldn't be "just use components or hooks"; the reason to pick HOCs currently is that components suffer from "wrapper hell" unless a helper library like react-adopt is used, and that hooks are still immature.

@cihadturhan
Copy link

I prefer using HOC over components and hooks. With HOC, I can easily separate query/mutate logic from view, especially using with decorators

@graphql(MY_CANDIDATES_AND_PRIMARY, { name: "myCandidatesQuery" })
@graphql(CANDIDATES, { name: "candidatesQuery" })
@graphql(UPDATE_CANDIDATES, { name: "updateCandidatesMutation" })
class CandidatesListScreen extends Component {
   //...
}

However, I can't get why there is no variables provided like queries.

@rwoody
Copy link

rwoody commented Jun 10, 2019

I have the same problem when wrapping my components with graphql. Isn't this a regression? I thought I remembered mutations triggering loading and error props...

@slikts
Copy link
Author

slikts commented Jun 12, 2019

Yes; it is (was) a regression and is fixed by #3008 (not sure in which release the changes are in).

Closing this ticket as a duplicate of #1967

@slikts slikts closed this as completed Jun 12, 2019
@rwoody
Copy link

rwoody commented Jun 12, 2019 via email

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants