ground-aws-graphql-core
TypeScript icon, indicating that this package has built-in type declarations

1.0.25 • Public • Published

 

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.

Documentation

Dependents (0)

Package Sidebar

Install

npm i ground-aws-graphql-core

Weekly Downloads

0

Version

1.0.25

License

ISC

Unpacked Size

206 MB

Total Files

307

Last publish

Collaborators

  • mhallem