Skip to content

Fundflow/apollo-redux-form

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Mar 11, 2019
353a009 · Mar 11, 2019
Jul 18, 2017
Oct 13, 2017
Oct 13, 2017
May 24, 2018
May 24, 2018
May 24, 2018
Oct 9, 2017
May 24, 2018
Mar 27, 2017
Feb 19, 2018
Mar 11, 2019
Mar 11, 2019
Mar 11, 2019
Oct 6, 2017
Aug 15, 2017
May 24, 2018
Jul 19, 2017

Repository files navigation

Warning. This project is still WIP. Feedback is welcome.

Apollo ReduxForm

ReduxForm powered by Apollo and GraphQL

Features

  • Build forms from GraphQL mutations
  • Init forms from GraphQL queries
  • Store form state in Redux with ReduxForm
  • Submit forms via Apollo

install

npm install @fundflow/apollo-redux-form

How it works

Forms are built from mutation arguments, automagically.

const query = gql`
  mutation createPost($title: String!, $isDraft: Boolean, $views: Int, $average: Float) {
    createPost(title: $title, isDraft: $isDraft, views: $views, average: $average) {
      id
      createdAt
    }
  }`;
const CreatePostForm = apolloForm(query);

// CreatePostForm is a React component implementing a form with input fields corresponding to the mutation arguments

When submit button is clicked, the GraphQL mutation is executed.

It is possible to pre-fill a form with the results of a GraphQL query.

const query = gql`
  query getPost($id: ID) {
    getPost(id: $id) {
      id title isDraft views average createdAt
    }
  }`;
const withInit = initForm(query, { variables: { id: '123' } });
const PrefilledUpdatePostForm = withInit(apolloForm( /* ... */));

A quick look

Some user stories powered by React Storybook.

$ npm install
$ npm run compile
$ npm run storybook
// point your browser to http://localhost:6006/

References