Skip to content

Latest commit

 

History

History
54 lines (45 loc) · 2.59 KB

README.md

File metadata and controls

54 lines (45 loc) · 2.59 KB

@stellar-apps/apollo

This package contains react-apollo utilities and components

Installation

yarn add @stellar-apps/apollo

Usage

import {MutationForm, MutationButton} from '@stellar-apps/apollo'

MutationForm

A render props component for easily implementing a react-apollo-based Mutation form using Formik. No fetch polyfill is provided because the assumption is you're already implementing such a thing with your Apollo implementation.

Props

In addition to the props below, it inherits props from Formik and react-apollo Mutation

  • confirm {func}
    • If defined, the mutation will only run if this function returns true
    • Receives two arguments (formikValues, formikBag) seen here
  • prepareUpdate {func}
    • default ({variables}) => ({variables})
    • Should return an object to send to the react-apollo mutate() function. See here for details on additional options.
    • By default this returns the {values} from Formik as {variables}

Render function


MutationButton

A wrapper for SpinnerButton above and react-apollo/Mutation

Props

In addition to the props below, this component also receives props for SpinnerButton above and react-apollo Mutation

  • confirm {func}
    • If defined, the mutation will only run if this function returns true
    • Receives two arguments (formikValues, formikBag) seen here
  • prepareUpdate {func}
    • default ({variables}) => ({variables})
    • Should return an object to send to the react-apollo mutate() function. See here for details on additional options.
    • By default this returns the {values} from Formik as {variables}