Ground - AWS Graphql Core
npm install ground-aws-graphql-core
Step 1 - Import Ground Store Provider
import { GroundGraphqlProvider } from 'ground-aws-graphql-core';
Step 2 - Wrap your application
function App() {
return (
<GroundGraphqlProvider aws={awsmobile} mode={process.env.NODE_ENV}>
<AttributeList />
</GroundGraphqlProvider>
);
}
Step 3 - Use the context store
import { GroundGraphqlContextStore } from 'ground-aws-graphql-core'
function AttributeList() {
// attributes in state
const attributes = GroundGraphqlContextStore.useStoreState(state => state.attribute.attributes)
// list attributes action
const listAttributes = GroundGraphqlContextStore.useStoreActions(actions => actions.attribute.listAttributes)
// create attribute action
const createAttribute = GroundGraphqlContextStore.useStoreActions(actions => actions.attribute.createAttribute)
return (
<div>
{attributes.map((attribute, index) => <div key={index}>{attribute}</div>)}
<FetchAttributes onFetch={listAttributes} />
<AddAttribute onAdd={addAttribute} />
</div>
)
}
Introduction
Ground AWS Graphql Core provides you the store provider and manage from you the state for your Ground React application using easy-peasy package.