react-apollo-mutations-status
v1.1.0
Published
Adds `loading` and `error` properties to apollo mutations
Downloads
2
Maintainers
Readme
react-apollo-mutations-status
Adds loading
and error
properties to apollo mutations. Based on https://gist.github.com/ctavan/7219a3eca42f96a5c5f755319690bda7
Table of Contents
Install
yarn add --dev react-apollo-mutations-status
Usage
import { graphql, compose } from 'react-apollo';
import mutationsStatus from 'react-apollo-mutations-status';
import React from 'react';
const Register = ({ register }) => (
<form onSubmit={register.exec}>
{register.loading && <div>Loading…</div>}
{register.error && <div>{register.error}</div>}
<button type="submit" />
</form>
);
export default compose(
graphql(GQL_MUTATION, { name: 'register' }),
mutationsStatus(['register'])
)(Register);
import { graphql, compose } from 'react-apollo';
import mutationsStatus from 'react-apollo-mutations-status';
import React from 'react';
const Register = ({ mutate, loading, error }) => (
<form onSubmit={mutate.exec}>
{loading && <div>Loading…</div>}
{error && <div>{error}</div>}
<button type="submit" />
</form>
);
export default compose(
graphql(GQL_MUTATION),
mutationsStatus()
)(Register);
License
BSD-3-Clause