Giter VIP home page Giter VIP logo

apollo-redux-form's Introduction

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
$ yarn run storybook
// point your browser to http://localhost:6006/

References

apollo-redux-form's People

Contributors

ewhittick avatar jenkins-ff avatar mstn avatar pasquale-guglielmi avatar streamz88 avatar

Watchers

 avatar  avatar

Forkers

reoxb

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.