Socket
Socket
Sign inDemoInstall

apollo-link-redux

Package Overview
Dependencies
12
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    apollo-link-redux

Dispatches apollo-client 1.0-ish actions.


Version published
Weekly downloads
63
decreased by-43.24%
Maintainers
1
Created
Weekly downloads
 

Changelog

Source

0.1.6

  • Refine babel build to use shippedProposals and import/require babel runtime instead of duplicating helpers
  • Update README with example usage and browser support

Readme

Source

Dispatches apollo-client 1.0-ish actions.

Why?

While there are still Apollo Client 1.0 applications out there in the wild, this provides a little shim to back fill redux actions previously dispatched in Apollo Client 1.0 as you migrate to Apollo Client 2.0. (This link is framework agnostic despite the reference to React migration docs).

apollo-link-redux is intended to compliment apps that also use redux. It is not encouraging that redux also manage application state of GraphQL query and mutation responses. That is a job done much better by an Apollo Client cache.

Supported Actions

APOLLO_QUERY_INIT
APOLLO_QUERY_RESULT
APOLLO_MUTATION_INIT
APOLLO_MUTATION_RESULT

All actions have operationName, variables and document. *_RESULT actions will also contain result.

Setup

npm i -S apollo-link-redux
import { ApolloClient } from 'apollo-client';
import { ApolloLink } from 'apollo-link';
import ReduxLink from 'apollo-link-redux';
import { HttpLink } from 'apollo-link-http';

const link = ApolloLink.from([
  new ReduxLink(store),
  new HttpLink()
]);

const client = new ApolloClient({ link });

Example usage

import { APOLLO_MUTATION_RESULT } from 'apollo-link-redux';

export function mutationFooCounter(state = {
  count: 0
}, action) {
  if (
    action.operationName === 'MutateFoo' &&
    action.type === APOLLO_MUTATION_RESULT
  ) {
    const count += 1;
    return { count };
  }
  return state;
}

Support

  • > 1% market share browsers.

Keywords

FAQs

Last updated on 30 Nov 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