@department/apollo-component
Advanced tools
Comparing version 1.5.0 to 1.6.0
@@ -11,2 +11,4 @@ 'use strict'; | ||
var isPlainObject = function (obj) { return typeof obj === "object" && obj.constructor === Object; }; | ||
/** | ||
@@ -122,4 +124,3 @@ * Example: | ||
// ex. <button onClick={refetch} /> | ||
var isPlainObj = typeof vars == "object" && vars.constructor == Object; | ||
return this.observable.refetch(isPlainObj ? vars : undefined); | ||
return this.observable.refetch(isPlainObject(vars) ? vars : undefined); | ||
} | ||
@@ -290,2 +291,11 @@ }; | ||
// special case for when vars are event | ||
// ex. <button onClick={mutate} /> | ||
if (!isPlainObject(variables)) { | ||
variables = undefined; | ||
} | ||
// default to variables prop | ||
if (typeof variables == "undefined") { | ||
variables = this.props.variables; | ||
} | ||
var ref = this.context.apollo; | ||
@@ -327,4 +337,4 @@ var client = ref.client; | ||
// <Mutate fail> will throw the error instead of using the callback | ||
if (this.props.fail && state.error) { | ||
throw state.error; | ||
if (this.props.fail && this.state.error) { | ||
throw this.state.error; | ||
} | ||
@@ -348,2 +358,6 @@ | ||
// Default variables passed into the Mutation | ||
// (when no variables are passed into the mutation callback) | ||
variables: PropTypes.object, | ||
// Fail by throwing an exception and letting the React error boundary | ||
@@ -350,0 +364,0 @@ // take care of it instead of passing the error into the render callback |
{ | ||
"name": "@department/apollo-component", | ||
"version": "1.5.0", | ||
"version": "1.6.0", | ||
"description": "Render component for your Apollo Client", | ||
@@ -16,4 +16,3 @@ "repository": "department-stockholm/apollo-component", | ||
"prepare": "rollup -c", | ||
"release": "release", | ||
"postpublish": "release" | ||
"release": "release" | ||
}, | ||
@@ -31,3 +30,3 @@ "author": "Robert Sköld (https://department.se)", | ||
"react": "^16.1.0", | ||
"release": "^2.5.6", | ||
"release": "^3.0.1", | ||
"rollup": "^0.51.5", | ||
@@ -34,0 +33,0 @@ "rollup-plugin-buble": "^0.18.0" |
22437
470