Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-apollo

Package Overview
Dependencies
Maintainers
2
Versions
220
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-apollo - npm Package Compare versions

Comparing version 0.3.3 to 0.3.4

8

Changelog.md

@@ -5,4 +5,10 @@ # Change log

### v0.3.2
### v0.3.4
Bug: Fix bug where state / props weren't accurate when executing mutations.
Perf: Increase performance by limiting re-renders and re-execution of queries.
Chore: Split tests to make them easier to maintain.
### v0.3.2 || v0.3.3 (publish fix)
Feature: add `startPolling` and `stopPolling` to the prop object for queries

@@ -9,0 +15,0 @@ Bug: Fix bug where full options were not being passed to watchQuery

6

connect.d.ts

@@ -15,6 +15,6 @@ /// <reference path="../../typings/main.d.ts" />

options?: IConnectOptions;
mergeProps?(stateProps: any, dispatchProps: any, ownProps: any): any;
mapQueriesToProps?(opts: MapQueriesToPropsOptions): any;
mapMutationsToProps?(opts: MapMutationsToPropsOptions): any;
mergeProps?(stateProps: Object, dispatchProps: Object, ownProps: Object): Object;
mapQueriesToProps?(opts: MapQueriesToPropsOptions): Object;
mapMutationsToProps?(opts: MapMutationsToPropsOptions): Object;
}
export default function connect(opts?: ConnectOptions): (WrappedComponent: any) => any;

@@ -53,2 +53,3 @@ "use strict";

this.state = assign({}, storeState);
this.previousState = storeState;
this.data = {};

@@ -58,5 +59,6 @@ this.mutations = {};

ApolloConnect.prototype.componentWillMount = function () {
var _a = this, props = _a.props, state = _a.state;
this.subscribeToAllQueries(props, state);
this.createAllMutationHandles(props, state);
var props = this.props;
this.subscribeToAllQueries(props);
this.createAllMutationHandles(props);
this.bindStoreUpdates();
};

@@ -66,4 +68,4 @@ ApolloConnect.prototype.componentWillReceiveProps = function (nextProps) {

this.haveOwnPropsChanged = true;
this.unsubcribeAllQueries();
this.subscribeToAllQueries(nextProps, this.state);
this.createAllMutationHandles(nextProps);
this.subscribeToAllQueries(nextProps);
}

@@ -73,2 +75,3 @@ };

return this.haveOwnPropsChanged ||
this.hasOwnStateChanged ||
this.hasQueryDataChanged ||

@@ -79,4 +82,25 @@ this.hasMutationDataChanged;

this.unsubcribeAllQueries();
if (this.unsubscribeFromStore) {
this.unsubscribeFromStore();
this.unsubscribeFromStore = null;
}
};
ApolloConnect.prototype.subscribeToAllQueries = function (props, state) {
ApolloConnect.prototype.bindStoreUpdates = function () {
var _this = this;
var _a = this, store = _a.store, props = _a.props;
var reduxRootKey = this.client.reduxRootKey;
this.unsubscribeFromStore = store.subscribe(function () {
var newState = assign({}, store.getState());
var oldState = assign({}, _this.previousState);
delete newState[reduxRootKey];
delete oldState[reduxRootKey];
if (!isEqual(oldState, newState)) {
_this.previousState = newState;
_this.hasOwnStateChanged = true;
_this.subscribeToAllQueries(props);
_this.createAllMutationHandles(props);
}
});
};
ApolloConnect.prototype.subscribeToAllQueries = function (props) {
var _a = this.client, watchQuery = _a.watchQuery, reduxRootKey = _a.reduxRootKey;

@@ -88,2 +112,10 @@ var store = this.store;

});
var oldQueries = assign({}, this.previousQueries);
this.previousQueries = assign({}, queryHandles);
if (isEqual(oldQueries, queryHandles)) {
return;
}
else if (oldQueries) {
this.unsubcribeAllQueries();
}
if (isObject(queryHandles) && Object.keys(queryHandles).length) {

@@ -181,6 +213,6 @@ this.queryHandles = queryHandles;

};
ApolloConnect.prototype.createAllMutationHandles = function (props, state) {
ApolloConnect.prototype.createAllMutationHandles = function (props) {
var mutations = mapMutationsToProps({
state: state,
ownProps: props,
state: this.store.getState(),
});

@@ -226,2 +258,7 @@ if (isObject(mutations) && Object.keys(mutations).length) {

}
var stateAndProps = {
state: store.getState(),
ownProps: _this.props,
};
args.push(stateAndProps);
var _a = method.apply(_this.client, args), mutation = _a.mutation, variables = _a.variables;

@@ -244,4 +281,5 @@ return new Promise(function (resolve, reject) {

ApolloConnect.prototype.render = function () {
var _a = this, haveOwnPropsChanged = _a.haveOwnPropsChanged, hasQueryDataChanged = _a.hasQueryDataChanged, hasMutationDataChanged = _a.hasMutationDataChanged, renderedElement = _a.renderedElement, mutations = _a.mutations, props = _a.props, data = _a.data;
var _a = this, haveOwnPropsChanged = _a.haveOwnPropsChanged, hasOwnStateChanged = _a.hasOwnStateChanged, hasQueryDataChanged = _a.hasQueryDataChanged, hasMutationDataChanged = _a.hasMutationDataChanged, renderedElement = _a.renderedElement, mutations = _a.mutations, props = _a.props, data = _a.data;
this.haveOwnPropsChanged = false;
this.hasOwnStateChanged = false;
this.hasQueryDataChanged = false;

@@ -258,2 +296,3 @@ this.hasMutationDataChanged = false;

if (!haveOwnPropsChanged &&
!hasOwnStateChanged &&
!hasQueryDataChanged &&

@@ -260,0 +299,0 @@ !hasMutationDataChanged &&

{
"name": "react-apollo",
"version": "0.3.3",
"version": "0.3.4",
"description": "React data container for Apollo Client",

@@ -5,0 +5,0 @@ "main": "index.js",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc