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.
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")
}
import {
introspectionQuery
} from 'graphql';
import { graphql, gql } from 'react-apollo'
graphql( gql(introspectionQuery) )((props) => {
const {
data: {
loading,
__schema // graph.cool schema
}
} = props;
return (
...
)
});
import {
apolloForm
} from '@fundflow/apollo-redux-form';
CreatePostForm = apolloForm(createPost, {
schema, // <-- schema read at step 2
});