@specialblend/apollo-blackbox

React Apollo Providers with loading, error and data states

Usage no npm install needed!

<script type="module">
  import specialblendApolloBlackbox from 'https://cdn.skypack.dev/@specialblend/apollo-blackbox';
</script>

README

@specialblend/apollo-blackbox

React Apollo Providers with loading, error and data states

NPM JavaScript Style Guide

Install

npm install --save @specialblend/apollo-blackbox

Usage

import React from 'react'
import MyComponent from './MyComponent'
import typeDefs from './typeDefs'

import { ApolloBlackbox } from '@specialblend/apollo-blackbox'

// simulates query is loading forever
function LoadingExample () {
    return (
        <ApolloBlackbox loading>
            <MyComponent />
        </ApolloBlackbox>
    )
}

// simulates query returned an error
function ErrorExample () {

    const error = new Error('oops. something bad happened.')

    return (
        <ApolloBlackbox error={error}>
            <MyComponent />
        </ApolloBlackbox>
    )
}

// simulates mock API from typeDefs
function DataExample () {
    return (
        <ApolloBlackbox typeDefs={typeDefs}>
            <MyComponent />
        </ApolloBlackbox>
    )
}

License

MIT © specialblend