Skip to content

Simple experiment showing how to generate forms using Graph.Cool backend

Notifications You must be signed in to change notification settings

Fundflow/apollo-redux-form-cool

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simple proof-of-concept experiment showing how to build forms from a graph.cool schema.

We followed the example project with Apollo.

Project built with create-react-app.

Basic idea

1) Define a type with Graph.Cool

type User @model {
  id: ID! @isUnique
  name: String!
  surname: String!
  posts: [Post!]! @relation(name: "UserPosts")
}

type Post @model {
  id: ID! @isUnique
  title: String!
  content: String!
  author: User! @relation(name: "UserPosts")
}

2) Read Graph.Cool schema with introspection

import {
  introspectionQuery
} from 'graphql';

import { graphql, gql } from 'react-apollo'

graphql( gql(introspectionQuery) )((props) => {
  const {
    data: {
      loading,
      __schema // graph.cool schema
    }
  } = props;
  return (
    ...  
  )
});

3) Build form with apollo-redux-form

import {
  apolloForm
} from '@fundflow/apollo-redux-form';

CreatePostForm = apolloForm(createPost, {
  schema, // <-- schema read at step 2
});

About

Simple experiment showing how to generate forms using Graph.Cool backend

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages