From c373940d0c34421fe1cfc127c05a6c010f987cf8 Mon Sep 17 00:00:00 2001 From: 3nvi Date: Fri, 7 Jun 2019 12:11:51 +0300 Subject: [PATCH 1/3] update .gitignore to ignore Webstorm's `.idea` folder --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index ba28bbba..159646af 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ lib *.tgz lerna-debug.log .npmrc +.idea From 86c7e26d746a9f611fec40fe2999f974c1ceea45 Mon Sep 17 00:00:00 2001 From: 3nvi Date: Fri, 7 Jun 2019 12:12:16 +0300 Subject: [PATCH 2/3] make sure to account for `null` values of the `loading` prop --- packages/aws-appsync-react/src/rehydrated-rn.tsx | 2 +- packages/aws-appsync-react/src/rehydrated.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/aws-appsync-react/src/rehydrated-rn.tsx b/packages/aws-appsync-react/src/rehydrated-rn.tsx index 83410749..86dfafb0 100644 --- a/packages/aws-appsync-react/src/rehydrated-rn.tsx +++ b/packages/aws-appsync-react/src/rehydrated-rn.tsx @@ -71,7 +71,7 @@ export default class Rehydrated extends React.Component diff --git a/packages/aws-appsync-react/src/rehydrated.tsx b/packages/aws-appsync-react/src/rehydrated.tsx index 2c60a8d5..8a9854ef 100644 --- a/packages/aws-appsync-react/src/rehydrated.tsx +++ b/packages/aws-appsync-react/src/rehydrated.tsx @@ -59,7 +59,7 @@ export default class Rehydrated extends React.Component From 918bac66ea966c7aaac828989cf683245b1c35d1 Mon Sep 17 00:00:00 2001 From: 3nvi Date: Fri, 7 Jun 2019 12:14:49 +0300 Subject: [PATCH 3/3] Update README to document `Rehydrated`'s props --- packages/aws-appsync-react/README.md | 50 ++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/packages/aws-appsync-react/README.md b/packages/aws-appsync-react/README.md index 3d955c34..7c282f27 100644 --- a/packages/aws-appsync-react/README.md +++ b/packages/aws-appsync-react/README.md @@ -1 +1,51 @@ # aws-appsync-react + +This package provides the following helpers which are needed when working with the SDK on a React project. + +- `Rehydrated` +- `graphqlMutation` + +---- +## `Rehydrated` + +A React component that you need to wrap your app with, when working with Apollo, React & a custom client created with `aws-appsync`. It makes sure +to wait for a client hydration in an offline environment. + +### Import +``` +import { Rehydrated } from 'aws-appsync-react' +``` + +### Props + +| Prop name | Required | Details | +| ------------- |:-------------:| :-------| +| children | false | The React Element(s) to show when the client is fully hydrated | +| loading | false | The React Element to show while the client is hydrating. Defaults to the text element `Loading...` | +| render | false | A render-props function that has a single object parameter containing a boolean `rehydrated` and should return a React node. It's signature is: `({ rehydrated: boolean }) => React.ReactNode` | + + Although the props `children` and `render` are mutually exclusive, **at least** one of them should be defined. + + +### Example +``` +import { ApolloProvider } from 'react-apollo'; +import { Rehydrated } from 'aws-appsync-react'; +import App from './App'; + +const client = /* ... */ + +const WithProvider = () => ( + + + + + +) + +export default WithProvider +``` + +## `graphqlMutation` + +Full documentation for this helper can be found in the [Offline Helpers API page](https://github.com/awslabs/aws-mobile-appsync-sdk-js/blob/master/OFFLINE_HELPERS.md).