Socket
Socket
Sign inDemoInstall

apollo-tote

Package Overview
Dependencies
0
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    apollo-tote

A declarative approach to handling your graphql queries in React


Version published
Weekly downloads
5
decreased by-50%
Maintainers
1
Install size
49.9 kB
Created
Weekly downloads
 

Readme

Source

apollo-tote

👜 A declarative approach to handling Apollo queries in React

npm version

Installation

yarn add apollo-tote

or

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.
<ApolloTote
    query={`
      query {
        user {
          id
        }
      }
    `}
    test={data => !!(data && data.user && data.user.id)}
    handleFail={() => Store.dispatch({ type: 'LOG_OUT' })}
    handlePass={() => Store.dispatch({ type: 'LOG_IN' })}
    renderError={error => this._renderError(error)}
    renderLoading={() => <App.Loading />}
    render={() => <App />}
/>
  • Render loading component until data comes back.
<ApolloTote
    query={`
      query {
        user {
          imageUrl
        }
      }
    `}
    renderLoading={() => <Avatar.Loading />}
    render={value => <Avatar imageUrl={value.user.imageUrl} />}
/>

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

Keywords

FAQs

Last updated on 20 Dec 2017

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc