Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/peterpme/apollo-tote
👜 A declarative approach to handling Apollo GraphQL queries in React
https://github.com/peterpme/apollo-tote
apollo graphql react
Last synced: 5 days ago
JSON representation
👜 A declarative approach to handling Apollo GraphQL queries in React
- Host: GitHub
- URL: https://github.com/peterpme/apollo-tote
- Owner: peterpme
- Created: 2017-08-30T03:28:10.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2017-12-20T06:18:55.000Z (almost 7 years ago)
- Last Synced: 2024-11-01T06:42:26.750Z (12 days ago)
- Topics: apollo, graphql, react
- Language: JavaScript
- Homepage:
- Size: 42 KB
- Stars: 77
- Watchers: 4
- Forks: 5
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# apollo-tote
👜 A declarative approach to handling Apollo queries in React
[![npm version](https://badge.fury.io/js/apollo-tote.svg)](https://badge.fury.io/js/apollo-tote)
## Installation
```sh
yarn add apollo-tote
```or
```sh
npm install --save apollo-tote
```## Usage Examples
- Fetch `current user` query. If an api token exists but is no longer valid (ie: cleared database), log user out.
```jsx
!!(data && data.user && data.user.id)}
handleFail={() => Store.dispatch({ type: 'LOG_OUT' })}
handlePass={() => Store.dispatch({ type: 'LOG_IN' })}
renderError={error => this._renderError(error)}
renderLoading={() => }
render={() => }
/>
```- Render loading component until data comes back.
```jsx
}
render={value => }
/>
```## PropTypes
- `skip`: Boolean - Should we skip over query and just render?
- `query`: String - Your graphql query
- `variables`: String - Graphql query variables
- `test`: Function (Optional) - helper to handle a successful query's response
- `handlePass`: Function (Optional) - a function to render a successful `test`
- `handleFail`: Function (Optional) - a function to render a failed `test`
- `renderError`: Function - error function
- `renderLoading`: Function - loading function
- `render`: Function - a function that renders the result of your query