1.1.0 • Published 7 years ago

react-apollo-mutations-status v1.1.0

Weekly downloads
2
License
BSD-3-Clause
Repository
github
Last release
7 years ago

react-apollo-mutations-status

npm License: BSD-3-Clause standard-readme compliant

David David

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