react-apollo
Advanced tools
Comparing version 2.1.0-beta.1 to 2.1.0-beta.2
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var PropTypes = require("prop-types"); | ||
var invariant_1 = require("invariant"); | ||
var invariant = require('invariant'); | ||
var ApolloConsumer = function (props, context) { | ||
invariant_1.default(!!context.client, "Could not find \"client\" in the context of ApolloConsumer. Wrap the root component in an <ApolloProvider>"); | ||
invariant(!!context.client, "Could not find \"client\" in the context of ApolloConsumer. Wrap the root component in an <ApolloProvider>"); | ||
return props.children(context.client); | ||
@@ -8,0 +8,0 @@ }; |
@@ -17,3 +17,3 @@ "use strict"; | ||
var QueryRecyclerProvider_1 = require("./QueryRecyclerProvider"); | ||
var invariant_1 = require("invariant"); | ||
var invariant = require('invariant'); | ||
var ApolloProvider = (function (_super) { | ||
@@ -23,3 +23,3 @@ __extends(ApolloProvider, _super); | ||
var _this = _super.call(this, props, context) || this; | ||
invariant_1.default(props.client, 'ApolloClient was not passed a client instance. Make ' + | ||
invariant(props.client, 'ApolloClient was not passed a client instance. Make ' + | ||
'sure you pass in your client via the "client" prop.'); | ||
@@ -26,0 +26,0 @@ return _this; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var react_1 = require("react"); | ||
var object_assign_1 = require("object-assign"); | ||
var assign = require('object-assign'); | ||
function getProps(element) { | ||
@@ -28,3 +28,3 @@ return (element.props || | ||
var Comp = element.type; | ||
var props = object_assign_1.default({}, Comp.defaultProps, getProps(element)); | ||
var props = assign({}, Comp.defaultProps, getProps(element)); | ||
var childContext = context; | ||
@@ -41,3 +41,3 @@ var child = void 0; | ||
} | ||
instance_1.state = object_assign_1.default({}, instance_1.state, newState); | ||
instance_1.state = assign({}, instance_1.state, newState); | ||
}; | ||
@@ -48,3 +48,3 @@ if (instance_1.componentWillMount) { | ||
if (providesChildContext(instance_1)) { | ||
childContext = object_assign_1.default({}, context, instance_1.getChildContext()); | ||
childContext = assign({}, context, instance_1.getChildContext()); | ||
} | ||
@@ -51,0 +51,0 @@ if (visitor(element, instance_1, context) === false) { |
@@ -24,7 +24,7 @@ "use strict"; | ||
var parser_1 = require("./parser"); | ||
var pick_1 = require("lodash/pick"); | ||
var object_assign_1 = require("object-assign"); | ||
var hoist_non_react_statics_1 = require("hoist-non-react-statics"); | ||
var shallowEqual_1 = require("fbjs/lib/shallowEqual"); | ||
var invariant_1 = require("invariant"); | ||
var pick = require('lodash/pick'); | ||
var assign = require('object-assign'); | ||
var hoistNonReactStatics = require('hoist-non-react-statics'); | ||
var shallowEqual = require('fbjs/lib/shallowEqual'); | ||
var invariant = require('invariant'); | ||
var defaultMapPropsToOptions = function () { return ({}); }; | ||
@@ -34,3 +34,3 @@ var defaultMapResultToProps = function (props) { return props; }; | ||
function observableQueryFields(observable) { | ||
var fields = pick_1.default(observable, 'variables', 'refetch', 'fetchMore', 'updateQuery', 'startPolling', 'stopPolling', 'subscribeToMore'); | ||
var fields = pick(observable, 'variables', 'refetch', 'fetchMore', 'updateQuery', 'startPolling', 'stopPolling', 'subscribeToMore'); | ||
Object.keys(fields).forEach(function (key) { | ||
@@ -101,3 +101,3 @@ var k = key; | ||
var client = mapPropsToOptions(nextProps).client; | ||
if (shallowEqual_1.default(this.props, nextProps) && | ||
if (shallowEqual(this.props, nextProps) && | ||
(this.client === client || this.client === nextContext.client)) { | ||
@@ -167,3 +167,3 @@ return; | ||
} | ||
invariant_1.default(!!this.client, "Could not find \"client\" in the context of " + | ||
invariant(!!this.client, "Could not find \"client\" in the context of " + | ||
("\"" + graphQLDisplayName + "\". ") + | ||
@@ -177,6 +177,6 @@ "Wrap the root component in an <ApolloProvider>"); | ||
if (newOpts && newOpts.variables) { | ||
newOpts.variables = object_assign_1.default({}, opts.variables, newOpts.variables); | ||
newOpts.variables = assign({}, opts.variables, newOpts.variables); | ||
} | ||
if (newOpts) | ||
opts = object_assign_1.default({}, opts, newOpts); | ||
opts = assign({}, opts, newOpts); | ||
if (opts.variables || !operation.variables.length) | ||
@@ -199,3 +199,3 @@ return opts; | ||
} | ||
invariant_1.default(typeof variableProp !== 'undefined', "The operation '" + operation.name + "' wrapping '" + getDisplayName(WrappedComponent) + "' " + | ||
invariant(typeof variableProp !== 'undefined', "The operation '" + operation.name + "' wrapping '" + getDisplayName(WrappedComponent) + "' " + | ||
("is expecting a variable: '" + variable.name.value + "' but it was not found in the props ") + | ||
@@ -230,3 +230,3 @@ ("passed to '" + graphQLDisplayName + "'")); | ||
if (this.type === parser_1.DocumentType.Subscription) { | ||
this.queryObservable = this.getClient(props).subscribe(object_assign_1.default({ query: document }, opts)); | ||
this.queryObservable = this.getClient(props).subscribe(assign({ query: document }, opts)); | ||
} | ||
@@ -239,3 +239,3 @@ else { | ||
if (queryObservable === null) { | ||
this.queryObservable = this.getClient(props).watchQuery(object_assign_1.default({ | ||
this.queryObservable = this.getClient(props).watchQuery(assign({ | ||
query: document, | ||
@@ -283,3 +283,3 @@ metadata: { | ||
} | ||
var observable = this.getClient(this.props).watchQuery(object_assign_1.default({ query: document }, opts)); | ||
var observable = this.getClient(this.props).watchQuery(assign({ query: document }, opts)); | ||
var result = observable.currentResult(); | ||
@@ -303,3 +303,3 @@ if (result.loading) { | ||
var clashingKeys = Object.keys(observableQueryFields(results.data)); | ||
invariant_1.default(clashingKeys.length === 0, "the result of the '" + graphQLDisplayName + "' operation contains " + | ||
invariant(clashingKeys.length === 0, "the result of the '" + graphQLDisplayName + "' operation contains " + | ||
"keys that conflict with the return object." + | ||
@@ -350,3 +350,3 @@ clashingKeys.map(function (k) { return "'" + k + "'"; }).join(', ') + | ||
GraphQL.prototype.getWrappedInstance = function () { | ||
invariant_1.default(operationOptions.withRef, "To access the wrapped instance, you need to specify " + | ||
invariant(operationOptions.withRef, "To access the wrapped instance, you need to specify " + | ||
"{ withRef: true } in the options"); | ||
@@ -372,5 +372,5 @@ return this.wrappedInstance; | ||
var data = {}; | ||
object_assign_1.default(data, observableQueryFields(this.queryObservable)); | ||
assign(data, observableQueryFields(this.queryObservable)); | ||
if (this.type === parser_1.DocumentType.Subscription) { | ||
object_assign_1.default(data, { | ||
assign(data, { | ||
loading: !this.lastSubscriptionData, | ||
@@ -383,3 +383,3 @@ variables: opts.variables, | ||
var loading = currentResult.loading, error_1 = currentResult.error, networkStatus = currentResult.networkStatus; | ||
object_assign_1.default(data, { loading: loading, networkStatus: networkStatus }); | ||
assign(data, { loading: loading, networkStatus: networkStatus }); | ||
var logErrorTimeoutId_1 = setTimeout(function () { | ||
@@ -405,9 +405,9 @@ if (error_1) { | ||
if (loading) { | ||
object_assign_1.default(data, this.previousData, currentResult.data); | ||
assign(data, this.previousData, currentResult.data); | ||
} | ||
else if (error_1) { | ||
object_assign_1.default(data, (this.queryObservable.getLastResult() || {}).data); | ||
assign(data, (this.queryObservable.getLastResult() || {}).data); | ||
} | ||
else { | ||
object_assign_1.default(data, currentResult.data); | ||
assign(data, currentResult.data); | ||
this.previousData = currentResult.data; | ||
@@ -428,3 +428,3 @@ } | ||
if (operationOptions.withRef) { | ||
return (React.createElement(WrappedComponent, __assign({}, object_assign_1.default({}, this.props, { ref: this.setWrappedInstance })))); | ||
return (React.createElement(WrappedComponent, __assign({}, assign({}, this.props, { ref: this.setWrappedInstance })))); | ||
} | ||
@@ -442,3 +442,3 @@ return React.createElement(WrappedComponent, __assign({}, this.props)); | ||
var clientProps = this.calculateResultProps(data); | ||
var mergedPropsAndData = object_assign_1.default({}, props, clientProps); | ||
var mergedPropsAndData = assign({}, props, clientProps); | ||
if (operationOptions.withRef) | ||
@@ -457,3 +457,3 @@ mergedPropsAndData.ref = this.setWrappedInstance; | ||
}(React.Component)); | ||
return hoist_non_react_statics_1.default(GraphQL, WrappedComponent, {}); | ||
return hoistNonReactStatics(GraphQL, WrappedComponent, {}); | ||
} | ||
@@ -460,0 +460,0 @@ return wrapWithApolloComponent; |
{ | ||
"name": "react-apollo", | ||
"version": "2.1.0-beta.1", | ||
"version": "2.1.0-beta.2", | ||
"description": "React data container for Apollo Client", | ||
@@ -5,0 +5,0 @@ "module": "index.mjs", |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var invariant_1 = require("invariant"); | ||
var invariant = require('invariant'); | ||
var DocumentType; | ||
@@ -12,3 +12,3 @@ (function (DocumentType) { | ||
var variables, type, name; | ||
invariant_1.default(!!document && !!document.kind, "Argument of " + document + " passed to parser was not a valid GraphQL " + | ||
invariant(!!document && !!document.kind, "Argument of " + document + " passed to parser was not a valid GraphQL " + | ||
"DocumentNode. You may need to use 'graphql-tag' or another method " + | ||
@@ -26,6 +26,6 @@ "to convert your operation into a document"); | ||
}); | ||
invariant_1.default(!fragments.length || | ||
invariant(!fragments.length || | ||
(queries.length || mutations.length || subscriptions.length), "Passing only a fragment to 'graphql' is not yet supported. " + | ||
"You must include a query, subscription or mutation as well"); | ||
invariant_1.default(queries.length + mutations.length + subscriptions.length <= 1, "react-apollo only supports a query, subscription, or a mutation per HOC. " + | ||
invariant(queries.length + mutations.length + subscriptions.length <= 1, "react-apollo only supports a query, subscription, or a mutation per HOC. " + | ||
(document + " had " + queries.length + " queries, " + subscriptions.length + " ") + | ||
@@ -40,3 +40,3 @@ ("subscriptions and " + mutations.length + " mutations. ") + | ||
: mutations.length ? mutations : subscriptions; | ||
invariant_1.default(definitions.length === 1, "react-apollo only supports one defintion per HOC. " + document + " had " + | ||
invariant(definitions.length === 1, "react-apollo only supports one defintion per HOC. " + document + " had " + | ||
(definitions.length + " definitions. ") + | ||
@@ -43,0 +43,0 @@ "You can use 'compose' to join multiple operation types to a component"); |
14
Query.js
@@ -33,7 +33,7 @@ "use strict"; | ||
var parser_1 = require("./parser"); | ||
var pick_1 = require("lodash/pick"); | ||
var shallowEqual_1 = require("fbjs/lib/shallowEqual"); | ||
var invariant_1 = require("invariant"); | ||
var pick = require('lodash/pick'); | ||
var shallowEqual = require('fbjs/lib/shallowEqual'); | ||
var invariant = require('invariant'); | ||
function observableQueryFields(observable) { | ||
var fields = pick_1.default(observable, 'refetch', 'fetchMore', 'updateQuery', 'startPolling', 'stopPolling'); | ||
var fields = pick(observable, 'refetch', 'fetchMore', 'updateQuery', 'startPolling', 'stopPolling'); | ||
Object.keys(fields).forEach(function (key) { | ||
@@ -57,3 +57,3 @@ var k = key; | ||
var operation = parser_1.parser(query); | ||
invariant_1.default(operation.type === parser_1.DocumentType.Query, "The <Query /> component requires a graphql query, but got a " + (operation.type === parser_1.DocumentType.Mutation ? 'mutation' : 'subscription') + "."); | ||
invariant(operation.type === parser_1.DocumentType.Query, "The <Query /> component requires a graphql query, but got a " + (operation.type === parser_1.DocumentType.Mutation ? 'mutation' : 'subscription') + "."); | ||
var clientOptions = { | ||
@@ -94,3 +94,3 @@ variables: variables, | ||
}; | ||
invariant_1.default(!!context.client, "Could not find \"client\" in the context of Query. Wrap the root component in an <ApolloProvider>"); | ||
invariant(!!context.client, "Could not find \"client\" in the context of Query. Wrap the root component in an <ApolloProvider>"); | ||
_this.client = context.client; | ||
@@ -124,3 +124,3 @@ _this.initializeQueryObservable(props); | ||
Query.prototype.componentWillReceiveProps = function (nextProps, nextContext) { | ||
if (shallowEqual_1.default(this.props, nextProps) && | ||
if (shallowEqual(this.props, nextProps) && | ||
this.client === nextContext.client) { | ||
@@ -127,0 +127,0 @@ return; |
@@ -1,2 +0,2 @@ | ||
(function(a,b){'object'==typeof exports&&'undefined'!=typeof module?b(exports,require('react'),require('object-assign'),require('prop-types'),require('invariant'),require('fbjs/lib/shallowEqual'),require('lodash/pick'),require('hoist-non-react-statics'),require('lodash/flowRight')):'function'==typeof define&&define.amd?define(['exports','react','object-assign','prop-types','invariant','fbjs/lib/shallowEqual','lodash/pick','hoist-non-react-statics','lodash/flowRight'],b):b(a['react-apollo']={},a.React,a.object_assign_1,a.PropTypes,a.invariant_1,a.shallowEqual_1,a.pick,a.hoistNonReactStatics,a.flowRight)})(this,function(a,b,c,d,e,f,g,h,i){'use strict';function j(a){return a&&a.__esModule&&Object.prototype.hasOwnProperty.call(a,'default')?a['default']:a}function k(a,b){return b={exports:{}},a(b,b.exports),b.exports}b=b&&b.hasOwnProperty('default')?b['default']:b,c=c&&c.hasOwnProperty('default')?c['default']:c,d=d&&d.hasOwnProperty('default')?d['default']:d,e=e&&e.hasOwnProperty('default')?e['default']:e,f=f&&f.hasOwnProperty('default')?f['default']:f,g=g&&g.hasOwnProperty('default')?g['default']:g,h=h&&h.hasOwnProperty('default')?h['default']:h,i=i&&i.hasOwnProperty('default')?i['default']:i;var l='undefined'==typeof window?'undefined'==typeof global?'undefined'==typeof self?{}:self:global:window,m=k(function(a,d){function e(a){return a.props||a.attributes}function f(a){return!!a.type}function g(a){return a.prototype&&(a.prototype.render||a.prototype.isReactComponent)}function h(a){return!!a.getChildContext}function i(a,d,j){if(Array.isArray(a))return void a.forEach(function(a){return i(a,d,j)});if(a)if(!f(a))('string'==typeof a||'number'==typeof a)&&j(a,null,d);else if('function'==typeof a.type){var k,l=a.type,m=c.default({},l.defaultProps,e(a)),n=d;if(g(l)){var o=new l(m,d);if(o.props=o.props||m,o.context=o.context||d,o.state=o.state||null,o.setState=function(a){'function'==typeof a&&(a=a(o.state,o.props,o.context)),o.state=c.default({},o.state,a)},o.componentWillMount&&o.componentWillMount(),h(o)&&(n=c.default({},d,o.getChildContext())),!1===j(a,o,d))return;k=o.render()}else{if(!1===j(a,null,d))return;k=l(m,d)}k&&(Array.isArray(k)?k.forEach(function(a){return i(a,d,j)}):i(k,n,j))}else{if(!1===j(a,null,d))return;a.props&&a.props.children&&b.Children.forEach(a.props.children,function(a){a&&i(a,d,j)})}}function j(a){return'function'==typeof a.fetchData}function k(a){return'function'==typeof a.then}function l(a,b){var c=a.rootElement,d=a.rootContext,e=void 0===d?{}:d;void 0===b&&(b=!0);var g=[];return i(c,e,function(a,d,e){var h=!b&&a===c;if(!h&&d&&f(a)&&j(d)){var i=d.fetchData();if(k(i))return g.push({query:i,element:a,context:e}),!1}}),g}function m(a,b,c){void 0===b&&(b={}),void 0===c&&(c=!0);var d=l({rootElement:a,rootContext:b},c);if(!d.length)return Promise.resolve();var f=[],e=d.map(function(a){var b=a.query,c=a.element,d=a.context;return b.then(function(){return m(c,d,!1)}).catch(function(a){return f.push(a)})});return Promise.all(e).then(function(){if(0<f.length){var a=1===f.length?f[0]:new Error(f.length+' errors were thrown when executing your GraphQL queries.');throw a.queryErrors=f,a}})}Object.defineProperty(d,'__esModule',{value:!0}),d.walkTree=i,d.default=m});j(m);var n=m.walkTree,o=k(function(a,b){Object.defineProperty(b,'__esModule',{value:!0});var c=function(a,b){return e.default(!!b.client,'Could not find "client" in the context of ApolloConsumer. Wrap the root component in an <ApolloProvider>'),a.children(b.client)};c.contextTypes={client:d.object.isRequired},b.default=c});j(o);var p=k(function(a,b){var c=l&&l.__assign||Object.assign||function(a){for(var b,c=1,d=arguments.length;c<d;c++)for(var e in b=arguments[c],b)Object.prototype.hasOwnProperty.call(b,e)&&(a[e]=b[e]);return a},d=l&&l.__rest||function(a,b){var c={};for(var d in a)Object.prototype.hasOwnProperty.call(a,d)&&0>b.indexOf(d)&&(c[d]=a[d]);if(null!=a&&'function'==typeof Object.getOwnPropertySymbols)for(var e=0,d=Object.getOwnPropertySymbols(a);e<d.length;e++)0>b.indexOf(d[e])&&(c[d[e]]=a[d[e]]);return c};Object.defineProperty(b,'__esModule',{value:!0});var e=function(){function a(){this.observableQueries=[]}return a.prototype.recycle=function(a){a.setOptions({fetchPolicy:'standby',pollInterval:0,fetchResults:!1}),this.observableQueries.push({observableQuery:a,subscription:a.subscribe({})})},a.prototype.reuse=function(a){if(0>=this.observableQueries.length)return null;var b=this.observableQueries.pop();if(!b)return null;var e=b.observableQuery,g=b.subscription;g.unsubscribe();var h=a.ssr,i=a.client,j=d(a,['ssr','client']);return f(j.variables||{},e.variables)?(e.setOptions(c({},j,{pollInterval:a.pollInterval,fetchPolicy:a.fetchPolicy})),e):null},a}();b.ObservableQueryRecycler=e});j(p);var q=p.ObservableQueryRecycler,r=k(function(a,c){var e=l&&l.__extends||function(){var a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(a,c){a.__proto__=c}||function(a,c){for(var b in c)c.hasOwnProperty(b)&&(a[b]=c[b])};return function(c,d){function b(){this.constructor=c}a(c,d),c.prototype=null===d?Object.create(d):(b.prototype=d.prototype,new b)}}();Object.defineProperty(c,'__esModule',{value:!0});var f=function(a){function b(b){var c=a.call(this,b)||this;return c.recyclers=new WeakMap,c.getQueryRecycler=c.getQueryRecycler.bind(c),c}return e(b,a),b.prototype.componentWillReceiveProps=function(a,b){this.context.client!==b.client&&(this.recyclers=new WeakMap)},b.prototype.getQueryRecycler=function(a){return this.recyclers.has(a)||this.recyclers.set(a,new p.ObservableQueryRecycler),this.recyclers.get(a)},b.prototype.getChildContext=function(){return{getQueryRecycler:this.getQueryRecycler}},b.prototype.render=function(){return this.props.children},b.propTypes={children:d.element.isRequired},b.contextTypes={client:d.object},b.childContextTypes={getQueryRecycler:d.func.isRequired},b}(b.Component);c.default=f});j(r);var s=k(function(a,c){var f=l&&l.__extends||function(){var a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(a,c){a.__proto__=c}||function(a,c){for(var b in c)c.hasOwnProperty(b)&&(a[b]=c[b])};return function(c,d){function b(){this.constructor=c}a(c,d),c.prototype=null===d?Object.create(d):(b.prototype=d.prototype,new b)}}();Object.defineProperty(c,'__esModule',{value:!0});var g=b,h=function(a){function c(b,c){var d=a.call(this,b,c)||this;return e.default(b.client,'ApolloClient was not passed a client instance. Make sure you pass in your client via the "client" prop.'),d}return f(c,a),c.prototype.getChildContext=function(){return{client:this.props.client}},c.prototype.render=function(){return b.createElement(r.default,null,b.Children.only(this.props.children))},c.propTypes={client:d.object.isRequired,children:d.element.isRequired},c.childContextTypes={client:d.object.isRequired},c}(g.Component);c.default=h});j(s);var t=k(function(a,b){Object.defineProperty(b,'__esModule',{value:!0});var c;(function(a){a[a.Query=0]='Query',a[a.Mutation=1]='Mutation',a[a.Subscription=2]='Subscription'})(c=b.DocumentType||(b.DocumentType={})),b.parser=function(a){var b,d,f;e.default(!!a&&!!a.kind,'Argument of '+a+' passed to parser was not a valid GraphQL DocumentNode. You may need to use \'graphql-tag\' or another method to convert your operation into a document');var g=a.definitions.filter(function(a){return'FragmentDefinition'===a.kind}),h=a.definitions.filter(function(a){return'OperationDefinition'===a.kind&&'query'===a.operation}),i=a.definitions.filter(function(a){return'OperationDefinition'===a.kind&&'mutation'===a.operation}),j=a.definitions.filter(function(a){return'OperationDefinition'===a.kind&&'subscription'===a.operation});e.default(!g.length||h.length||i.length||j.length,'Passing only a fragment to \'graphql\' is not yet supported. You must include a query, subscription or mutation as well'),e.default(1>=h.length+i.length+j.length,'react-apollo only supports a query, subscription, or a mutation per HOC. '+(a+' had '+h.length+' queries, '+j.length+' ')+('subscriptions and '+i.length+' mutations. You can use \'compose\' to join multiple operation types to a component')),d=h.length?c.Query:c.Mutation,h.length||i.length||(d=c.Subscription);var k=h.length?h:i.length?i:j;e.default(1===k.length,'react-apollo only supports one defintion per HOC. '+a+' had '+(k.length+' definitions. You can use \'compose\' to join multiple operation types to a component'));var l=k[0];return b=l.variableDefinitions||[],f=l.name&&'Name'===l.name.kind?l.name.value:'data',{name:f,type:d,variables:b}}});j(t);var u=t.DocumentType,v=t.parser,w=k(function(a,c){function h(a){var b=g.default(a,'refetch','fetchMore','updateQuery','startPolling','stopPolling');return Object.keys(b).forEach(function(c){var d=c;'function'==typeof b[d]&&(b[d]=b[d].bind(a))}),b}function i(a){return 0<Object.keys(a).length}var j=l&&l.__extends||function(){var a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(a,c){a.__proto__=c}||function(a,c){for(var b in c)c.hasOwnProperty(b)&&(a[b]=c[b])};return function(c,d){function b(){this.constructor=c}a(c,d),c.prototype=null===d?Object.create(d):(b.prototype=d.prototype,new b)}}(),k=l&&l.__assign||Object.assign||function(a){for(var b,c=1,d=arguments.length;c<d;c++)for(var e in b=arguments[c],b)Object.prototype.hasOwnProperty.call(b,e)&&(a[e]=b[e]);return a},m=l&&l.__rest||function(a,b){var c={};for(var d in a)Object.prototype.hasOwnProperty.call(a,d)&&0>b.indexOf(d)&&(c[d]=a[d]);if(null!=a&&'function'==typeof Object.getOwnPropertySymbols)for(var e=0,d=Object.getOwnPropertySymbols(a);e<d.length;e++)0>b.indexOf(d[e])&&(c[d[e]]=a[d[e]]);return c};Object.defineProperty(c,'__esModule',{value:!0});var n=function(a){function b(b,c){var d=a.call(this,b,c)||this;return d.initializeQueryObservable=function(a){var b=a.variables,c=a.pollInterval,f=a.fetchPolicy,g=a.notifyOnNetworkStatusChange,h=a.query,i=t.parser(h);e.default(i.type===t.DocumentType.Query,'The <Query /> component requires a graphql query, but got a '+(i.type===t.DocumentType.Mutation?'mutation':'subscription')+'.');d.queryObservable=d.client.watchQuery({variables:b,pollInterval:c,query:h,fetchPolicy:f,notifyOnNetworkStatusChange:g})},d.startQuerySubscription=function(){d.querySubscription=d.queryObservable.subscribe({next:d.updateCurrentData,error:function(a){if(d.resubscribeToQuery(),!a.hasOwnProperty('graphQLErrors'))throw a;d.updateCurrentData()}})},d.removeQuerySubscription=function(){d.querySubscription&&d.querySubscription.unsubscribe()},d.updateCurrentData=function(){d.setState({result:d.queryObservable.currentResult()})},d.getQueryResult=function(){var a=d.state.result,b=a.loading,c=a.error,e=a.networkStatus,f=a.data;return k({client:d.client,data:i(f)?f:void 0,loading:b,error:c,networkStatus:e},h(d.queryObservable))},e.default(!!c.client,'Could not find "client" in the context of Query. Wrap the root component in an <ApolloProvider>'),d.client=c.client,d.initializeQueryObservable(b),d.state={result:d.queryObservable.currentResult()},d}return j(b,a),b.prototype.fetchData=function(){var a=this.props,b=a.children,c=a.ssr,d=m(a,['children','ssr']),e=d.fetchPolicy;if(!1===c)return!1;('network-only'===e||'cache-and-network'===e)&&(e='cache-first');var f=this.client.watchQuery(k({},d,{fetchPolicy:e})),g=this.queryObservable.currentResult();return!!g.loading&&f.result()},b.prototype.componentDidMount=function(){this.startQuerySubscription()},b.prototype.componentWillReceiveProps=function(a,b){f.default(this.props,a)&&this.client===b.client||(this.client!==b.client&&(this.client=b.client),this.removeQuerySubscription(),this.initializeQueryObservable(a),this.startQuerySubscription(),this.updateCurrentData())},b.prototype.componentWillUnmount=function(){this.removeQuerySubscription()},b.prototype.render=function(){var a=this.props.children,b=this.getQueryResult();return a(b)},b.prototype.resubscribeToQuery=function(){this.removeQuerySubscription();var a=this.queryObservable.getLastError(),b=this.queryObservable.getLastResult();this.queryObservable.resetLastResults(),this.startQuerySubscription(),Object.assign(this.queryObservable,{lastError:a,lastResult:b})},b.contextTypes={client:d.object.isRequired},b}(b.Component);c.default=n});j(w);var x=k(function(a,i){function j(a){var b=g.default(a,'variables','refetch','fetchMore','updateQuery','startPolling','stopPolling','subscribeToMore');return Object.keys(b).forEach(function(c){var d=c;'function'==typeof b[d]&&(b[d]=b[d].bind(a))}),b}function k(a){return a.displayName||a.name||'Component'}var m=l&&l.__extends||function(){var a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(a,c){a.__proto__=c}||function(a,c){for(var b in c)c.hasOwnProperty(b)&&(a[b]=c[b])};return function(c,d){function b(){this.constructor=c}a(c,d),c.prototype=null===d?Object.create(d):(b.prototype=d.prototype,new b)}}(),n=l&&l.__assign||Object.assign||function(a){for(var b,c=1,d=arguments.length;c<d;c++)for(var e in b=arguments[c],b)Object.prototype.hasOwnProperty.call(b,e)&&(a[e]=b[e]);return a};Object.defineProperty(i,'__esModule',{value:!0});var o=function(){return{}},p=function(a){return a},q=function(){return!1},r=0;i.default=function(a,g){void 0===g&&(g={});var i=g.options,l=void 0===i?o:i,s=g.skip,u=void 0===s?q:s,v=g.alias,w=void 0===v?'Apollo':v,x=l;'function'!=typeof x&&(x=function(){return l});var y=u;'function'!=typeof y&&(y=function(){return u});var z=g.props,A=t.parser(a),B=r++;return function(i){var l=w+'('+k(i)+')',o=function(h){function o(a,b){var c=h.call(this,a,b)||this;return c.previousData={},c.version=B,c.type=A.type,c.dataForChildViaMutation=c.dataForChildViaMutation.bind(c),c.setWrappedInstance=c.setWrappedInstance.bind(c),c}return m(o,h),o.prototype.componentWillMount=function(){this.shouldSkip(this.props)||this.setInitialProps()},o.prototype.componentDidMount=function(){if((this.hasMounted=!0,this.type!==t.DocumentType.Mutation)&&!this.shouldSkip(this.props)&&(this.subscribeToQuery(),this.refetcherQueue)){var a=this.refetcherQueue,b=a.args,c=a.resolve,d=a.reject;this.queryObservable.refetch(b).then(c).catch(d)}},o.prototype.componentWillReceiveProps=function(a,b){if(this.shouldSkip(a))return void(this.shouldSkip(this.props)||this.unsubscribeFromQuery());var c=x(a).client;if(!(f.default(this.props,a)&&(this.client===c||this.client===b.client)))return this.shouldRerender=!0,this.client!==c&&this.client!==b.client?(this.client=c?c:b.client,this.unsubscribeFromQuery(),this.queryObservable=null,this.previousData={},this.updateQuery(a),void(this.shouldSkip(a)||this.subscribeToQuery())):this.type===t.DocumentType.Mutation?void 0:this.type===t.DocumentType.Subscription&&g.shouldResubscribe&&g.shouldResubscribe(this.props,a)?(this.unsubscribeFromQuery(),delete this.queryObservable,this.updateQuery(a),void this.subscribeToQuery()):void(this.updateQuery(a),this.subscribeToQuery())},o.prototype.componentWillUnmount=function(){if(this.type===t.DocumentType.Query){if(this.queryObservable){var a=this.getQueryRecycler();a&&(a.recycle(this.queryObservable),delete this.queryObservable)}this.unsubscribeFromQuery()}this.type===t.DocumentType.Subscription&&this.unsubscribeFromQuery(),this.hasMounted=!1},o.prototype.getQueryRecycler=function(){return this.context.getQueryRecycler&&this.context.getQueryRecycler(o)},o.prototype.getClient=function(a){if(this.client)return this.client;var b=x(a).client;return this.client=b?b:this.context.client,e.default(!!this.client,'Could not find "client" in the context of "'+l+'". Wrap the root component in an <ApolloProvider>'),this.client},o.prototype.calculateOptions=function(a,b){void 0===a&&(a=this.props);var d=x(a);if(b&&b.variables&&(b.variables=c.default({},d.variables,b.variables)),b&&(d=c.default({},d,b)),d.variables||!A.variables.length)return d;for(var f={},g=0,h=A.variables;g<h.length;g++){var j=h[g],m=j.variable,o=j.type;if(m.name&&m.name.value){var p=m.name.value,q=a[p];if('undefined'!=typeof q){f[p]=q;continue}if('NonNullType'!==o.kind){f[p]=null;continue}e.default('undefined'!=typeof q,'The operation \''+A.name+'\' wrapping \''+k(i)+'\' '+('is expecting a variable: \''+m.name.value+'\' but it was not found in the props ')+('passed to \''+l+'\''))}}return d=n({},d,{variables:f}),d},o.prototype.calculateResultProps=function(a){var b=this.type===t.DocumentType.Mutation?'mutate':'data';g.name&&(b=g.name);var c=(d={},d[b]=a,d.ownProps=this.props,d);return z?z(c):(e={},e[b]=p(a),e);var d,e},o.prototype.setInitialProps=function(){if(this.type!==t.DocumentType.Mutation){var a=this.calculateOptions(this.props);this.createQuery(a)}},o.prototype.createQuery=function(b,d){if(void 0===d&&(d=this.props),this.type===t.DocumentType.Subscription)this.queryObservable=this.getClient(d).subscribe(c.default({query:a},b));else{var e=this.getQueryRecycler(),f=null;e&&(f=e.reuse(b)),this.queryObservable=null===f?this.getClient(d).watchQuery(c.default({query:a,metadata:{reactComponent:{displayName:l}}},b)):f}},o.prototype.updateQuery=function(a){var b=this.calculateOptions(a);this.queryObservable||this.createQuery(b,a),this.queryObservable._setOptionsNoResult?this.queryObservable._setOptionsNoResult(b):this.queryObservable.setOptions&&this.queryObservable.setOptions(b).catch(function(){return null})},o.prototype.fetchData=function(){if(this.shouldSkip())return!1;if(A.type===t.DocumentType.Mutation||A.type===t.DocumentType.Subscription)return!1;var b=this.calculateOptions();if(!1===b.ssr)return!1;('network-only'===b.fetchPolicy||'cache-and-network'===b.fetchPolicy)&&(b.fetchPolicy='cache-first');var d=this.getClient(this.props).watchQuery(c.default({query:a},b)),e=d.currentResult();return!!e.loading&&d.result()},o.prototype.subscribeToQuery=function(){var a=this;if(!this.querySubscription){var b=function(b){a.type===t.DocumentType.Subscription&&(a.lastSubscriptionData=b);var c=Object.keys(j(b.data));e.default(0===c.length,'the result of the \''+l+'\' operation contains keys that conflict with the return object.'+c.map(function(a){return'\''+a+'\''}).join(', ')+' not allowed.'),a.forceRenderChildren()},c=function(c){if(a.resubscribeToQuery(),c.hasOwnProperty('graphQLErrors'))return b({error:c});throw c};this.querySubscription=this.queryObservable.subscribe({next:b,error:c})}},o.prototype.unsubscribeFromQuery=function(){this.querySubscription&&(this.querySubscription.unsubscribe(),delete this.querySubscription)},o.prototype.resubscribeToQuery=function(){var a=this.querySubscription;a&&delete this.querySubscription;var b=this.queryObservable,c=b.lastError,d=b.lastResult;this.queryObservable.resetLastResults(),this.subscribeToQuery(),Object.assign(this.queryObservable,{lastError:c,lastResult:d}),a&&a.unsubscribe()},o.prototype.shouldSkip=function(a){return void 0===a&&(a=this.props),y(a)},o.prototype.forceRenderChildren=function(){this.shouldRerender=!0,this.hasMounted&&this.forceUpdate()},o.prototype.getWrappedInstance=function(){return e.default(g.withRef,'To access the wrapped instance, you need to specify { withRef: true } in the options'),this.wrappedInstance},o.prototype.setWrappedInstance=function(a){this.wrappedInstance=a},o.prototype.dataForChildViaMutation=function(b){var c=this.calculateOptions(this.props,b);return'undefined'==typeof c.variables&&delete c.variables,c.mutation=a,this.getClient(this.props).mutate(c)},o.prototype.dataForChild=function(){var a=this;if(this.type===t.DocumentType.Mutation)return this.dataForChildViaMutation;var b=this.calculateOptions(this.props),d={};if(c.default(d,j(this.queryObservable)),this.type===t.DocumentType.Subscription)c.default(d,{loading:!this.lastSubscriptionData,variables:b.variables},this.lastSubscriptionData&&this.lastSubscriptionData.data);else{var e=this.queryObservable.currentResult(),f=e.loading,g=e.error,h=e.networkStatus;c.default(d,{loading:f,networkStatus:h});var i=setTimeout(function(){if(g){var a=g;g.stack&&(a=g.stack.includes(g.message)?g.stack:g.message+'\n'+g.stack),console.error('Unhandled (in react-apollo:'+l+')',a)}},10);Object.defineProperty(d,'error',{configurable:!0,enumerable:!0,get:function(){return clearTimeout(i),g}}),f?c.default(d,this.previousData,e.data):g?c.default(d,(this.queryObservable.getLastResult()||{}).data):(c.default(d,e.data),this.previousData=e.data),this.querySubscription||(d.refetch=function(b){return new Promise(function(c,d){a.refetcherQueue={resolve:c,reject:d,args:b}})})}return d},o.prototype.render=function(){if(this.shouldSkip())return g.withRef?b.createElement(i,n({},c.default({},this.props,{ref:this.setWrappedInstance}))):b.createElement(i,n({},this.props));var a=this,d=a.shouldRerender,e=a.renderedElement,f=a.props;if(this.shouldRerender=!1,!d&&e&&e.type===i)return e;var h=this.dataForChild(),j=this.calculateResultProps(h),k=c.default({},f,j);return g.withRef&&(k.ref=this.setWrappedInstance),this.renderedElement=b.createElement(i,n({},k)),this.renderedElement},o.displayName=l,o.WrappedComponent=i,o.contextTypes={client:d.object,getQueryRecycler:d.func},o}(b.Component);return h.default(o,i,{})}}});j(x);var y=k(function(a,d){function f(a){return a.displayName||a.name||'Component'}var g=l&&l.__extends||function(){var a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(a,c){a.__proto__=c}||function(a,c){for(var b in c)c.hasOwnProperty(b)&&(a[b]=c[b])};return function(c,d){function b(){this.constructor=c}a(c,d),c.prototype=null===d?Object.create(d):(b.prototype=d.prototype,new b)}}(),i=l&&l.__assign||Object.assign||function(a){for(var b,c=1,d=arguments.length;c<d;c++)for(var e in b=arguments[c],b)Object.prototype.hasOwnProperty.call(b,e)&&(a[e]=b[e]);return a};Object.defineProperty(d,'__esModule',{value:!0}),d.default=function(a,d){void 0===d&&(d={});var j='withApollo('+f(a)+')',k=function(f){function h(a){var b=f.call(this,a)||this;return b.setWrappedInstance=b.setWrappedInstance.bind(b),b}return g(h,f),h.prototype.getWrappedInstance=function(){return e.default(d.withRef,'To access the wrapped instance, you need to specify { withRef: true } in the options'),this.wrappedInstance},h.prototype.setWrappedInstance=function(a){this.wrappedInstance=a},h.prototype.render=function(){var e=this;return b.createElement(o.default,null,function(f){var g=c.default({},e.props,{client:f,ref:d.withRef?e.setWrappedInstance:void 0});return b.createElement(a,i({},g))})},h.displayName=j,h.WrappedComponent=a,h}(b.Component);return h.default(k,a,{})}});j(y);var z=k(function(a,b){function c(a){for(var c in a)b.hasOwnProperty(c)||(b[c]=a[c])}Object.defineProperty(b,'__esModule',{value:!0}),b.getDataFromTree=m.default,c(m),b.ApolloConsumer=o.default,c(o),b.ApolloProvider=s.default,c(s),b.Query=w.default,c(w),b.graphql=x.default,c(x),b.withApollo=y.default,b.compose=i}),A=j(z),B=z.getDataFromTree,C=z.ApolloConsumer,D=z.ApolloProvider,E=z.Query,F=z.graphql,G=z.withApollo,H=z.compose;a.default=A,a.getDataFromTree=B,a.ApolloConsumer=C,a.ApolloProvider=D,a.Query=E,a.graphql=F,a.withApollo=G,a.compose=H,Object.defineProperty(a,'__esModule',{value:!0})}); | ||
(function(a,b){'object'==typeof exports&&'undefined'!=typeof module?b(exports,require('react'),require('object-assign'),require('prop-types'),require('invariant'),require('fbjs/lib/shallowEqual'),require('lodash/pick'),require('hoist-non-react-statics'),require('lodash/flowRight')):'function'==typeof define&&define.amd?define(['exports','react','object-assign','prop-types','invariant','fbjs/lib/shallowEqual','lodash/pick','hoist-non-react-statics','lodash/flowRight'],b):b(a['react-apollo']={},a.React,a.assign,a.PropTypes,a.invariant,a.shallowEqual,a.pick,a.hoistNonReactStatics,a.flowRight)})(this,function(a,b,c,d,e,f,g,h,i){'use strict';function j(a){return a&&a.__esModule&&Object.prototype.hasOwnProperty.call(a,'default')?a['default']:a}function k(a,b){return b={exports:{}},a(b,b.exports),b.exports}b=b&&b.hasOwnProperty('default')?b['default']:b,c=c&&c.hasOwnProperty('default')?c['default']:c,d=d&&d.hasOwnProperty('default')?d['default']:d,e=e&&e.hasOwnProperty('default')?e['default']:e,f=f&&f.hasOwnProperty('default')?f['default']:f,g=g&&g.hasOwnProperty('default')?g['default']:g,h=h&&h.hasOwnProperty('default')?h['default']:h,i=i&&i.hasOwnProperty('default')?i['default']:i;var l='undefined'==typeof window?'undefined'==typeof global?'undefined'==typeof self?{}:self:global:window,m=k(function(a,d){function e(a){return a.props||a.attributes}function f(a){return!!a.type}function g(a){return a.prototype&&(a.prototype.render||a.prototype.isReactComponent)}function h(a){return!!a.getChildContext}function i(a,d,j){if(Array.isArray(a))return void a.forEach(function(a){return i(a,d,j)});if(a)if(!f(a))('string'==typeof a||'number'==typeof a)&&j(a,null,d);else if('function'==typeof a.type){var k,l=a.type,m=c({},l.defaultProps,e(a)),n=d;if(g(l)){var o=new l(m,d);if(o.props=o.props||m,o.context=o.context||d,o.state=o.state||null,o.setState=function(a){'function'==typeof a&&(a=a(o.state,o.props,o.context)),o.state=c({},o.state,a)},o.componentWillMount&&o.componentWillMount(),h(o)&&(n=c({},d,o.getChildContext())),!1===j(a,o,d))return;k=o.render()}else{if(!1===j(a,null,d))return;k=l(m,d)}k&&(Array.isArray(k)?k.forEach(function(a){return i(a,d,j)}):i(k,n,j))}else{if(!1===j(a,null,d))return;a.props&&a.props.children&&b.Children.forEach(a.props.children,function(a){a&&i(a,d,j)})}}function j(a){return'function'==typeof a.fetchData}function k(a){return'function'==typeof a.then}function l(a,b){var c=a.rootElement,d=a.rootContext,e=void 0===d?{}:d;void 0===b&&(b=!0);var g=[];return i(c,e,function(a,d,e){var h=!b&&a===c;if(!h&&d&&f(a)&&j(d)){var i=d.fetchData();if(k(i))return g.push({query:i,element:a,context:e}),!1}}),g}function m(a,b,c){void 0===b&&(b={}),void 0===c&&(c=!0);var d=l({rootElement:a,rootContext:b},c);if(!d.length)return Promise.resolve();var f=[],e=d.map(function(a){var b=a.query,c=a.element,d=a.context;return b.then(function(){return m(c,d,!1)}).catch(function(a){return f.push(a)})});return Promise.all(e).then(function(){if(0<f.length){var a=1===f.length?f[0]:new Error(f.length+' errors were thrown when executing your GraphQL queries.');throw a.queryErrors=f,a}})}Object.defineProperty(d,'__esModule',{value:!0}),d.walkTree=i,d.default=m});j(m);var n=m.walkTree,o=k(function(a,b){Object.defineProperty(b,'__esModule',{value:!0});var c=function(a,b){return e(!!b.client,'Could not find "client" in the context of ApolloConsumer. Wrap the root component in an <ApolloProvider>'),a.children(b.client)};c.contextTypes={client:d.object.isRequired},b.default=c});j(o);var p=k(function(a,b){var c=l&&l.__assign||Object.assign||function(a){for(var b,c=1,d=arguments.length;c<d;c++)for(var e in b=arguments[c],b)Object.prototype.hasOwnProperty.call(b,e)&&(a[e]=b[e]);return a},d=l&&l.__rest||function(a,b){var c={};for(var d in a)Object.prototype.hasOwnProperty.call(a,d)&&0>b.indexOf(d)&&(c[d]=a[d]);if(null!=a&&'function'==typeof Object.getOwnPropertySymbols)for(var e=0,d=Object.getOwnPropertySymbols(a);e<d.length;e++)0>b.indexOf(d[e])&&(c[d[e]]=a[d[e]]);return c};Object.defineProperty(b,'__esModule',{value:!0});var e=function(){function a(){this.observableQueries=[]}return a.prototype.recycle=function(a){a.setOptions({fetchPolicy:'standby',pollInterval:0,fetchResults:!1}),this.observableQueries.push({observableQuery:a,subscription:a.subscribe({})})},a.prototype.reuse=function(a){if(0>=this.observableQueries.length)return null;var b=this.observableQueries.pop();if(!b)return null;var e=b.observableQuery,g=b.subscription;g.unsubscribe();var h=a.ssr,i=a.client,j=d(a,['ssr','client']);return f(j.variables||{},e.variables)?(e.setOptions(c({},j,{pollInterval:a.pollInterval,fetchPolicy:a.fetchPolicy})),e):null},a}();b.ObservableQueryRecycler=e});j(p);var q=p.ObservableQueryRecycler,r=k(function(a,c){var e=l&&l.__extends||function(){var a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(a,c){a.__proto__=c}||function(a,c){for(var b in c)c.hasOwnProperty(b)&&(a[b]=c[b])};return function(c,d){function b(){this.constructor=c}a(c,d),c.prototype=null===d?Object.create(d):(b.prototype=d.prototype,new b)}}();Object.defineProperty(c,'__esModule',{value:!0});var f=function(a){function b(b){var c=a.call(this,b)||this;return c.recyclers=new WeakMap,c.getQueryRecycler=c.getQueryRecycler.bind(c),c}return e(b,a),b.prototype.componentWillReceiveProps=function(a,b){this.context.client!==b.client&&(this.recyclers=new WeakMap)},b.prototype.getQueryRecycler=function(a){return this.recyclers.has(a)||this.recyclers.set(a,new p.ObservableQueryRecycler),this.recyclers.get(a)},b.prototype.getChildContext=function(){return{getQueryRecycler:this.getQueryRecycler}},b.prototype.render=function(){return this.props.children},b.propTypes={children:d.element.isRequired},b.contextTypes={client:d.object},b.childContextTypes={getQueryRecycler:d.func.isRequired},b}(b.Component);c.default=f});j(r);var s=k(function(a,c){var f=l&&l.__extends||function(){var a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(a,c){a.__proto__=c}||function(a,c){for(var b in c)c.hasOwnProperty(b)&&(a[b]=c[b])};return function(c,d){function b(){this.constructor=c}a(c,d),c.prototype=null===d?Object.create(d):(b.prototype=d.prototype,new b)}}();Object.defineProperty(c,'__esModule',{value:!0});var g=b,h=function(a){function c(b,c){var d=a.call(this,b,c)||this;return e(b.client,'ApolloClient was not passed a client instance. Make sure you pass in your client via the "client" prop.'),d}return f(c,a),c.prototype.getChildContext=function(){return{client:this.props.client}},c.prototype.render=function(){return b.createElement(r.default,null,b.Children.only(this.props.children))},c.propTypes={client:d.object.isRequired,children:d.element.isRequired},c.childContextTypes={client:d.object.isRequired},c}(g.Component);c.default=h});j(s);var t=k(function(a,b){Object.defineProperty(b,'__esModule',{value:!0});var c;(function(a){a[a.Query=0]='Query',a[a.Mutation=1]='Mutation',a[a.Subscription=2]='Subscription'})(c=b.DocumentType||(b.DocumentType={})),b.parser=function(a){var b,d,f;e(!!a&&!!a.kind,'Argument of '+a+' passed to parser was not a valid GraphQL DocumentNode. You may need to use \'graphql-tag\' or another method to convert your operation into a document');var g=a.definitions.filter(function(a){return'FragmentDefinition'===a.kind}),h=a.definitions.filter(function(a){return'OperationDefinition'===a.kind&&'query'===a.operation}),i=a.definitions.filter(function(a){return'OperationDefinition'===a.kind&&'mutation'===a.operation}),j=a.definitions.filter(function(a){return'OperationDefinition'===a.kind&&'subscription'===a.operation});e(!g.length||h.length||i.length||j.length,'Passing only a fragment to \'graphql\' is not yet supported. You must include a query, subscription or mutation as well'),e(1>=h.length+i.length+j.length,'react-apollo only supports a query, subscription, or a mutation per HOC. '+(a+' had '+h.length+' queries, '+j.length+' ')+('subscriptions and '+i.length+' mutations. You can use \'compose\' to join multiple operation types to a component')),d=h.length?c.Query:c.Mutation,h.length||i.length||(d=c.Subscription);var k=h.length?h:i.length?i:j;e(1===k.length,'react-apollo only supports one defintion per HOC. '+a+' had '+(k.length+' definitions. You can use \'compose\' to join multiple operation types to a component'));var l=k[0];return b=l.variableDefinitions||[],f=l.name&&'Name'===l.name.kind?l.name.value:'data',{name:f,type:d,variables:b}}});j(t);var u=t.DocumentType,v=t.parser,w=k(function(a,c){function h(a){var b=g(a,'refetch','fetchMore','updateQuery','startPolling','stopPolling');return Object.keys(b).forEach(function(c){var d=c;'function'==typeof b[d]&&(b[d]=b[d].bind(a))}),b}function i(a){return 0<Object.keys(a).length}var j=l&&l.__extends||function(){var a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(a,c){a.__proto__=c}||function(a,c){for(var b in c)c.hasOwnProperty(b)&&(a[b]=c[b])};return function(c,d){function b(){this.constructor=c}a(c,d),c.prototype=null===d?Object.create(d):(b.prototype=d.prototype,new b)}}(),k=l&&l.__assign||Object.assign||function(a){for(var b,c=1,d=arguments.length;c<d;c++)for(var e in b=arguments[c],b)Object.prototype.hasOwnProperty.call(b,e)&&(a[e]=b[e]);return a},m=l&&l.__rest||function(a,b){var c={};for(var d in a)Object.prototype.hasOwnProperty.call(a,d)&&0>b.indexOf(d)&&(c[d]=a[d]);if(null!=a&&'function'==typeof Object.getOwnPropertySymbols)for(var e=0,d=Object.getOwnPropertySymbols(a);e<d.length;e++)0>b.indexOf(d[e])&&(c[d[e]]=a[d[e]]);return c};Object.defineProperty(c,'__esModule',{value:!0});var n=function(a){function b(b,c){var d=a.call(this,b,c)||this;return d.initializeQueryObservable=function(a){var b=a.variables,c=a.pollInterval,f=a.fetchPolicy,g=a.notifyOnNetworkStatusChange,h=a.query,i=t.parser(h);e(i.type===t.DocumentType.Query,'The <Query /> component requires a graphql query, but got a '+(i.type===t.DocumentType.Mutation?'mutation':'subscription')+'.');d.queryObservable=d.client.watchQuery({variables:b,pollInterval:c,query:h,fetchPolicy:f,notifyOnNetworkStatusChange:g})},d.startQuerySubscription=function(){d.querySubscription=d.queryObservable.subscribe({next:d.updateCurrentData,error:function(a){if(d.resubscribeToQuery(),!a.hasOwnProperty('graphQLErrors'))throw a;d.updateCurrentData()}})},d.removeQuerySubscription=function(){d.querySubscription&&d.querySubscription.unsubscribe()},d.updateCurrentData=function(){d.setState({result:d.queryObservable.currentResult()})},d.getQueryResult=function(){var a=d.state.result,b=a.loading,c=a.error,e=a.networkStatus,f=a.data;return k({client:d.client,data:i(f)?f:void 0,loading:b,error:c,networkStatus:e},h(d.queryObservable))},e(!!c.client,'Could not find "client" in the context of Query. Wrap the root component in an <ApolloProvider>'),d.client=c.client,d.initializeQueryObservable(b),d.state={result:d.queryObservable.currentResult()},d}return j(b,a),b.prototype.fetchData=function(){var a=this.props,b=a.children,c=a.ssr,d=m(a,['children','ssr']),e=d.fetchPolicy;if(!1===c)return!1;('network-only'===e||'cache-and-network'===e)&&(e='cache-first');var f=this.client.watchQuery(k({},d,{fetchPolicy:e})),g=this.queryObservable.currentResult();return!!g.loading&&f.result()},b.prototype.componentDidMount=function(){this.startQuerySubscription()},b.prototype.componentWillReceiveProps=function(a,b){f(this.props,a)&&this.client===b.client||(this.client!==b.client&&(this.client=b.client),this.removeQuerySubscription(),this.initializeQueryObservable(a),this.startQuerySubscription(),this.updateCurrentData())},b.prototype.componentWillUnmount=function(){this.removeQuerySubscription()},b.prototype.render=function(){var a=this.props.children,b=this.getQueryResult();return a(b)},b.prototype.resubscribeToQuery=function(){this.removeQuerySubscription();var a=this.queryObservable.getLastError(),b=this.queryObservable.getLastResult();this.queryObservable.resetLastResults(),this.startQuerySubscription(),Object.assign(this.queryObservable,{lastError:a,lastResult:b})},b.contextTypes={client:d.object.isRequired},b}(b.Component);c.default=n});j(w);var x=k(function(a,i){function j(a){var b=g(a,'variables','refetch','fetchMore','updateQuery','startPolling','stopPolling','subscribeToMore');return Object.keys(b).forEach(function(c){var d=c;'function'==typeof b[d]&&(b[d]=b[d].bind(a))}),b}function k(a){return a.displayName||a.name||'Component'}var m=l&&l.__extends||function(){var a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(a,c){a.__proto__=c}||function(a,c){for(var b in c)c.hasOwnProperty(b)&&(a[b]=c[b])};return function(c,d){function b(){this.constructor=c}a(c,d),c.prototype=null===d?Object.create(d):(b.prototype=d.prototype,new b)}}(),n=l&&l.__assign||Object.assign||function(a){for(var b,c=1,d=arguments.length;c<d;c++)for(var e in b=arguments[c],b)Object.prototype.hasOwnProperty.call(b,e)&&(a[e]=b[e]);return a};Object.defineProperty(i,'__esModule',{value:!0});var o=function(){return{}},p=function(a){return a},q=function(){return!1},r=0;i.default=function(a,g){void 0===g&&(g={});var i=g.options,l=void 0===i?o:i,s=g.skip,u=void 0===s?q:s,v=g.alias,w=void 0===v?'Apollo':v,x=l;'function'!=typeof x&&(x=function(){return l});var y=u;'function'!=typeof y&&(y=function(){return u});var z=g.props,A=t.parser(a),B=r++;return function(i){var l=w+'('+k(i)+')',o=function(h){function o(a,b){var c=h.call(this,a,b)||this;return c.previousData={},c.version=B,c.type=A.type,c.dataForChildViaMutation=c.dataForChildViaMutation.bind(c),c.setWrappedInstance=c.setWrappedInstance.bind(c),c}return m(o,h),o.prototype.componentWillMount=function(){this.shouldSkip(this.props)||this.setInitialProps()},o.prototype.componentDidMount=function(){if((this.hasMounted=!0,this.type!==t.DocumentType.Mutation)&&!this.shouldSkip(this.props)&&(this.subscribeToQuery(),this.refetcherQueue)){var a=this.refetcherQueue,b=a.args,c=a.resolve,d=a.reject;this.queryObservable.refetch(b).then(c).catch(d)}},o.prototype.componentWillReceiveProps=function(a,b){if(this.shouldSkip(a))return void(this.shouldSkip(this.props)||this.unsubscribeFromQuery());var c=x(a).client;if(!(f(this.props,a)&&(this.client===c||this.client===b.client)))return this.shouldRerender=!0,this.client!==c&&this.client!==b.client?(this.client=c?c:b.client,this.unsubscribeFromQuery(),this.queryObservable=null,this.previousData={},this.updateQuery(a),void(this.shouldSkip(a)||this.subscribeToQuery())):this.type===t.DocumentType.Mutation?void 0:this.type===t.DocumentType.Subscription&&g.shouldResubscribe&&g.shouldResubscribe(this.props,a)?(this.unsubscribeFromQuery(),delete this.queryObservable,this.updateQuery(a),void this.subscribeToQuery()):void(this.updateQuery(a),this.subscribeToQuery())},o.prototype.componentWillUnmount=function(){if(this.type===t.DocumentType.Query){if(this.queryObservable){var a=this.getQueryRecycler();a&&(a.recycle(this.queryObservable),delete this.queryObservable)}this.unsubscribeFromQuery()}this.type===t.DocumentType.Subscription&&this.unsubscribeFromQuery(),this.hasMounted=!1},o.prototype.getQueryRecycler=function(){return this.context.getQueryRecycler&&this.context.getQueryRecycler(o)},o.prototype.getClient=function(a){if(this.client)return this.client;var b=x(a).client;return this.client=b?b:this.context.client,e(!!this.client,'Could not find "client" in the context of "'+l+'". Wrap the root component in an <ApolloProvider>'),this.client},o.prototype.calculateOptions=function(a,b){void 0===a&&(a=this.props);var d=x(a);if(b&&b.variables&&(b.variables=c({},d.variables,b.variables)),b&&(d=c({},d,b)),d.variables||!A.variables.length)return d;for(var f={},g=0,h=A.variables;g<h.length;g++){var j=h[g],m=j.variable,o=j.type;if(m.name&&m.name.value){var p=m.name.value,q=a[p];if('undefined'!=typeof q){f[p]=q;continue}if('NonNullType'!==o.kind){f[p]=null;continue}e('undefined'!=typeof q,'The operation \''+A.name+'\' wrapping \''+k(i)+'\' '+('is expecting a variable: \''+m.name.value+'\' but it was not found in the props ')+('passed to \''+l+'\''))}}return d=n({},d,{variables:f}),d},o.prototype.calculateResultProps=function(a){var b=this.type===t.DocumentType.Mutation?'mutate':'data';g.name&&(b=g.name);var c=(d={},d[b]=a,d.ownProps=this.props,d);return z?z(c):(e={},e[b]=p(a),e);var d,e},o.prototype.setInitialProps=function(){if(this.type!==t.DocumentType.Mutation){var a=this.calculateOptions(this.props);this.createQuery(a)}},o.prototype.createQuery=function(b,d){if(void 0===d&&(d=this.props),this.type===t.DocumentType.Subscription)this.queryObservable=this.getClient(d).subscribe(c({query:a},b));else{var e=this.getQueryRecycler(),f=null;e&&(f=e.reuse(b)),this.queryObservable=null===f?this.getClient(d).watchQuery(c({query:a,metadata:{reactComponent:{displayName:l}}},b)):f}},o.prototype.updateQuery=function(a){var b=this.calculateOptions(a);this.queryObservable||this.createQuery(b,a),this.queryObservable._setOptionsNoResult?this.queryObservable._setOptionsNoResult(b):this.queryObservable.setOptions&&this.queryObservable.setOptions(b).catch(function(){return null})},o.prototype.fetchData=function(){if(this.shouldSkip())return!1;if(A.type===t.DocumentType.Mutation||A.type===t.DocumentType.Subscription)return!1;var b=this.calculateOptions();if(!1===b.ssr)return!1;('network-only'===b.fetchPolicy||'cache-and-network'===b.fetchPolicy)&&(b.fetchPolicy='cache-first');var d=this.getClient(this.props).watchQuery(c({query:a},b)),e=d.currentResult();return!!e.loading&&d.result()},o.prototype.subscribeToQuery=function(){var a=this;if(!this.querySubscription){var b=function(b){a.type===t.DocumentType.Subscription&&(a.lastSubscriptionData=b);var c=Object.keys(j(b.data));e(0===c.length,'the result of the \''+l+'\' operation contains keys that conflict with the return object.'+c.map(function(a){return'\''+a+'\''}).join(', ')+' not allowed.'),a.forceRenderChildren()},c=function(c){if(a.resubscribeToQuery(),c.hasOwnProperty('graphQLErrors'))return b({error:c});throw c};this.querySubscription=this.queryObservable.subscribe({next:b,error:c})}},o.prototype.unsubscribeFromQuery=function(){this.querySubscription&&(this.querySubscription.unsubscribe(),delete this.querySubscription)},o.prototype.resubscribeToQuery=function(){var a=this.querySubscription;a&&delete this.querySubscription;var b=this.queryObservable,c=b.lastError,d=b.lastResult;this.queryObservable.resetLastResults(),this.subscribeToQuery(),Object.assign(this.queryObservable,{lastError:c,lastResult:d}),a&&a.unsubscribe()},o.prototype.shouldSkip=function(a){return void 0===a&&(a=this.props),y(a)},o.prototype.forceRenderChildren=function(){this.shouldRerender=!0,this.hasMounted&&this.forceUpdate()},o.prototype.getWrappedInstance=function(){return e(g.withRef,'To access the wrapped instance, you need to specify { withRef: true } in the options'),this.wrappedInstance},o.prototype.setWrappedInstance=function(a){this.wrappedInstance=a},o.prototype.dataForChildViaMutation=function(b){var c=this.calculateOptions(this.props,b);return'undefined'==typeof c.variables&&delete c.variables,c.mutation=a,this.getClient(this.props).mutate(c)},o.prototype.dataForChild=function(){var a=this;if(this.type===t.DocumentType.Mutation)return this.dataForChildViaMutation;var b=this.calculateOptions(this.props),d={};if(c(d,j(this.queryObservable)),this.type===t.DocumentType.Subscription)c(d,{loading:!this.lastSubscriptionData,variables:b.variables},this.lastSubscriptionData&&this.lastSubscriptionData.data);else{var e=this.queryObservable.currentResult(),f=e.loading,g=e.error,h=e.networkStatus;c(d,{loading:f,networkStatus:h});var i=setTimeout(function(){if(g){var a=g;g.stack&&(a=g.stack.includes(g.message)?g.stack:g.message+'\n'+g.stack),console.error('Unhandled (in react-apollo:'+l+')',a)}},10);Object.defineProperty(d,'error',{configurable:!0,enumerable:!0,get:function(){return clearTimeout(i),g}}),f?c(d,this.previousData,e.data):g?c(d,(this.queryObservable.getLastResult()||{}).data):(c(d,e.data),this.previousData=e.data),this.querySubscription||(d.refetch=function(b){return new Promise(function(c,d){a.refetcherQueue={resolve:c,reject:d,args:b}})})}return d},o.prototype.render=function(){if(this.shouldSkip())return g.withRef?b.createElement(i,n({},c({},this.props,{ref:this.setWrappedInstance}))):b.createElement(i,n({},this.props));var a=this,d=a.shouldRerender,e=a.renderedElement,f=a.props;if(this.shouldRerender=!1,!d&&e&&e.type===i)return e;var h=this.dataForChild(),j=this.calculateResultProps(h),k=c({},f,j);return g.withRef&&(k.ref=this.setWrappedInstance),this.renderedElement=b.createElement(i,n({},k)),this.renderedElement},o.displayName=l,o.WrappedComponent=i,o.contextTypes={client:d.object,getQueryRecycler:d.func},o}(b.Component);return h(o,i,{})}}});j(x);var y=k(function(a,d){function f(a){return a.displayName||a.name||'Component'}var g=l&&l.__extends||function(){var a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(a,c){a.__proto__=c}||function(a,c){for(var b in c)c.hasOwnProperty(b)&&(a[b]=c[b])};return function(c,d){function b(){this.constructor=c}a(c,d),c.prototype=null===d?Object.create(d):(b.prototype=d.prototype,new b)}}(),i=l&&l.__assign||Object.assign||function(a){for(var b,c=1,d=arguments.length;c<d;c++)for(var e in b=arguments[c],b)Object.prototype.hasOwnProperty.call(b,e)&&(a[e]=b[e]);return a};Object.defineProperty(d,'__esModule',{value:!0}),d.default=function(a,d){void 0===d&&(d={});var j='withApollo('+f(a)+')',k=function(f){function h(a){var b=f.call(this,a)||this;return b.setWrappedInstance=b.setWrappedInstance.bind(b),b}return g(h,f),h.prototype.getWrappedInstance=function(){return e(d.withRef,'To access the wrapped instance, you need to specify { withRef: true } in the options'),this.wrappedInstance},h.prototype.setWrappedInstance=function(a){this.wrappedInstance=a},h.prototype.render=function(){var e=this;return b.createElement(o.default,null,function(f){var g=c({},e.props,{client:f,ref:d.withRef?e.setWrappedInstance:void 0});return b.createElement(a,i({},g))})},h.displayName=j,h.WrappedComponent=a,h}(b.Component);return h(k,a,{})}});j(y);var z=k(function(a,b){function c(a){for(var c in a)b.hasOwnProperty(c)||(b[c]=a[c])}Object.defineProperty(b,'__esModule',{value:!0}),b.getDataFromTree=m.default,c(m),b.ApolloConsumer=o.default,c(o),b.ApolloProvider=s.default,c(s),b.Query=w.default,c(w),b.graphql=x.default,c(x),b.withApollo=y.default,b.compose=i}),A=j(z),B=z.getDataFromTree,C=z.ApolloConsumer,D=z.ApolloProvider,E=z.Query,F=z.graphql,G=z.withApollo,H=z.compose;a.default=A,a.getDataFromTree=B,a.ApolloConsumer=C,a.ApolloProvider=D,a.Query=E,a.graphql=F,a.withApollo=G,a.compose=H,Object.defineProperty(a,'__esModule',{value:!0})}); | ||
//# sourceMappingURL=react-apollo.browser.umd.js.map |
@@ -1,1 +0,1 @@ | ||
(function(a,b){'object'==typeof exports&&'undefined'!=typeof module?b(exports,require('react'),require('object-assign'),require('prop-types'),require('invariant'),require('fbjs/lib/shallowEqual'),require('lodash/pick'),require('hoist-non-react-statics'),require('lodash/flowRight'),require('react-dom/server')):'function'==typeof define&&define.amd?define(['exports','react','object-assign','prop-types','invariant','fbjs/lib/shallowEqual','lodash/pick','hoist-non-react-statics','lodash/flowRight','react-dom/server'],b):b(a['react-apollo']={},a.React,a.object_assign_1,a.PropTypes,a.invariant_1,a.shallowEqual_1,a.pick,a.hoistNonReactStatics,a.flowRight,a.server)})(this,function(a,b,c,d,e,f,g,h,i,j){'use strict';function k(a){return a&&a.__esModule&&Object.prototype.hasOwnProperty.call(a,'default')?a['default']:a}function l(a,b){return b={exports:{}},a(b,b.exports),b.exports}b=b&&b.hasOwnProperty('default')?b['default']:b,c=c&&c.hasOwnProperty('default')?c['default']:c,d=d&&d.hasOwnProperty('default')?d['default']:d,e=e&&e.hasOwnProperty('default')?e['default']:e,f=f&&f.hasOwnProperty('default')?f['default']:f,g=g&&g.hasOwnProperty('default')?g['default']:g,h=h&&h.hasOwnProperty('default')?h['default']:h,i=i&&i.hasOwnProperty('default')?i['default']:i,j=j&&j.hasOwnProperty('default')?j['default']:j;var m='undefined'==typeof window?'undefined'==typeof global?'undefined'==typeof self?{}:self:global:window,n=l(function(a,d){function e(a){return a.props||a.attributes}function f(a){return!!a.type}function g(a){return a.prototype&&(a.prototype.render||a.prototype.isReactComponent)}function h(a){return!!a.getChildContext}function i(a,d,j){if(Array.isArray(a))return void a.forEach(function(a){return i(a,d,j)});if(a)if(!f(a))('string'==typeof a||'number'==typeof a)&&j(a,null,d);else if('function'==typeof a.type){var k,l=a.type,m=c.default({},l.defaultProps,e(a)),n=d;if(g(l)){var o=new l(m,d);if(o.props=o.props||m,o.context=o.context||d,o.state=o.state||null,o.setState=function(a){'function'==typeof a&&(a=a(o.state,o.props,o.context)),o.state=c.default({},o.state,a)},o.componentWillMount&&o.componentWillMount(),h(o)&&(n=c.default({},d,o.getChildContext())),!1===j(a,o,d))return;k=o.render()}else{if(!1===j(a,null,d))return;k=l(m,d)}k&&(Array.isArray(k)?k.forEach(function(a){return i(a,d,j)}):i(k,n,j))}else{if(!1===j(a,null,d))return;a.props&&a.props.children&&b.Children.forEach(a.props.children,function(a){a&&i(a,d,j)})}}function j(a){return'function'==typeof a.fetchData}function k(a){return'function'==typeof a.then}function l(a,b){var c=a.rootElement,d=a.rootContext,e=void 0===d?{}:d;void 0===b&&(b=!0);var g=[];return i(c,e,function(a,d,e){var h=!b&&a===c;if(!h&&d&&f(a)&&j(d)){var i=d.fetchData();if(k(i))return g.push({query:i,element:a,context:e}),!1}}),g}function m(a,b,c){void 0===b&&(b={}),void 0===c&&(c=!0);var d=l({rootElement:a,rootContext:b},c);if(!d.length)return Promise.resolve();var f=[],e=d.map(function(a){var b=a.query,c=a.element,d=a.context;return b.then(function(){return m(c,d,!1)}).catch(function(a){return f.push(a)})});return Promise.all(e).then(function(){if(0<f.length){var a=1===f.length?f[0]:new Error(f.length+' errors were thrown when executing your GraphQL queries.');throw a.queryErrors=f,a}})}Object.defineProperty(d,'__esModule',{value:!0}),d.walkTree=i,d.default=m});k(n);var o=n.walkTree,p=l(function(a,b){Object.defineProperty(b,'__esModule',{value:!0});var c=function(a,b){return e.default(!!b.client,'Could not find "client" in the context of ApolloConsumer. Wrap the root component in an <ApolloProvider>'),a.children(b.client)};c.contextTypes={client:d.object.isRequired},b.default=c});k(p);var q=l(function(a,b){var c=m&&m.__assign||Object.assign||function(a){for(var b,c=1,d=arguments.length;c<d;c++)for(var e in b=arguments[c],b)Object.prototype.hasOwnProperty.call(b,e)&&(a[e]=b[e]);return a},d=m&&m.__rest||function(a,b){var c={};for(var d in a)Object.prototype.hasOwnProperty.call(a,d)&&0>b.indexOf(d)&&(c[d]=a[d]);if(null!=a&&'function'==typeof Object.getOwnPropertySymbols)for(var e=0,d=Object.getOwnPropertySymbols(a);e<d.length;e++)0>b.indexOf(d[e])&&(c[d[e]]=a[d[e]]);return c};Object.defineProperty(b,'__esModule',{value:!0});var e=function(){function a(){this.observableQueries=[]}return a.prototype.recycle=function(a){a.setOptions({fetchPolicy:'standby',pollInterval:0,fetchResults:!1}),this.observableQueries.push({observableQuery:a,subscription:a.subscribe({})})},a.prototype.reuse=function(a){if(0>=this.observableQueries.length)return null;var b=this.observableQueries.pop();if(!b)return null;var e=b.observableQuery,g=b.subscription;g.unsubscribe();var h=a.ssr,i=a.client,j=d(a,['ssr','client']);return f(j.variables||{},e.variables)?(e.setOptions(c({},j,{pollInterval:a.pollInterval,fetchPolicy:a.fetchPolicy})),e):null},a}();b.ObservableQueryRecycler=e});k(q);var r=q.ObservableQueryRecycler,s=l(function(a,c){var e=m&&m.__extends||function(){var a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(a,c){a.__proto__=c}||function(a,c){for(var b in c)c.hasOwnProperty(b)&&(a[b]=c[b])};return function(c,d){function b(){this.constructor=c}a(c,d),c.prototype=null===d?Object.create(d):(b.prototype=d.prototype,new b)}}();Object.defineProperty(c,'__esModule',{value:!0});var f=function(a){function b(b){var c=a.call(this,b)||this;return c.recyclers=new WeakMap,c.getQueryRecycler=c.getQueryRecycler.bind(c),c}return e(b,a),b.prototype.componentWillReceiveProps=function(a,b){this.context.client!==b.client&&(this.recyclers=new WeakMap)},b.prototype.getQueryRecycler=function(a){return this.recyclers.has(a)||this.recyclers.set(a,new q.ObservableQueryRecycler),this.recyclers.get(a)},b.prototype.getChildContext=function(){return{getQueryRecycler:this.getQueryRecycler}},b.prototype.render=function(){return this.props.children},b.propTypes={children:d.element.isRequired},b.contextTypes={client:d.object},b.childContextTypes={getQueryRecycler:d.func.isRequired},b}(b.Component);c.default=f});k(s);var t=l(function(a,c){var f=m&&m.__extends||function(){var a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(a,c){a.__proto__=c}||function(a,c){for(var b in c)c.hasOwnProperty(b)&&(a[b]=c[b])};return function(c,d){function b(){this.constructor=c}a(c,d),c.prototype=null===d?Object.create(d):(b.prototype=d.prototype,new b)}}();Object.defineProperty(c,'__esModule',{value:!0});var g=b,h=function(a){function c(b,c){var d=a.call(this,b,c)||this;return e.default(b.client,'ApolloClient was not passed a client instance. Make sure you pass in your client via the "client" prop.'),d}return f(c,a),c.prototype.getChildContext=function(){return{client:this.props.client}},c.prototype.render=function(){return b.createElement(s.default,null,b.Children.only(this.props.children))},c.propTypes={client:d.object.isRequired,children:d.element.isRequired},c.childContextTypes={client:d.object.isRequired},c}(g.Component);c.default=h});k(t);var u=l(function(a,b){Object.defineProperty(b,'__esModule',{value:!0});var c;(function(a){a[a.Query=0]='Query',a[a.Mutation=1]='Mutation',a[a.Subscription=2]='Subscription'})(c=b.DocumentType||(b.DocumentType={})),b.parser=function(a){var b,d,f;e.default(!!a&&!!a.kind,'Argument of '+a+' passed to parser was not a valid GraphQL DocumentNode. You may need to use \'graphql-tag\' or another method to convert your operation into a document');var g=a.definitions.filter(function(a){return'FragmentDefinition'===a.kind}),h=a.definitions.filter(function(a){return'OperationDefinition'===a.kind&&'query'===a.operation}),i=a.definitions.filter(function(a){return'OperationDefinition'===a.kind&&'mutation'===a.operation}),j=a.definitions.filter(function(a){return'OperationDefinition'===a.kind&&'subscription'===a.operation});e.default(!g.length||h.length||i.length||j.length,'Passing only a fragment to \'graphql\' is not yet supported. You must include a query, subscription or mutation as well'),e.default(1>=h.length+i.length+j.length,'react-apollo only supports a query, subscription, or a mutation per HOC. '+(a+' had '+h.length+' queries, '+j.length+' ')+('subscriptions and '+i.length+' mutations. You can use \'compose\' to join multiple operation types to a component')),d=h.length?c.Query:c.Mutation,h.length||i.length||(d=c.Subscription);var k=h.length?h:i.length?i:j;e.default(1===k.length,'react-apollo only supports one defintion per HOC. '+a+' had '+(k.length+' definitions. You can use \'compose\' to join multiple operation types to a component'));var l=k[0];return b=l.variableDefinitions||[],f=l.name&&'Name'===l.name.kind?l.name.value:'data',{name:f,type:d,variables:b}}});k(u);var v=u.DocumentType,w=u.parser,x=l(function(a,c){function h(a){var b=g.default(a,'refetch','fetchMore','updateQuery','startPolling','stopPolling');return Object.keys(b).forEach(function(c){var d=c;'function'==typeof b[d]&&(b[d]=b[d].bind(a))}),b}function i(a){return 0<Object.keys(a).length}var j=m&&m.__extends||function(){var a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(a,c){a.__proto__=c}||function(a,c){for(var b in c)c.hasOwnProperty(b)&&(a[b]=c[b])};return function(c,d){function b(){this.constructor=c}a(c,d),c.prototype=null===d?Object.create(d):(b.prototype=d.prototype,new b)}}(),k=m&&m.__assign||Object.assign||function(a){for(var b,c=1,d=arguments.length;c<d;c++)for(var e in b=arguments[c],b)Object.prototype.hasOwnProperty.call(b,e)&&(a[e]=b[e]);return a},l=m&&m.__rest||function(a,b){var c={};for(var d in a)Object.prototype.hasOwnProperty.call(a,d)&&0>b.indexOf(d)&&(c[d]=a[d]);if(null!=a&&'function'==typeof Object.getOwnPropertySymbols)for(var e=0,d=Object.getOwnPropertySymbols(a);e<d.length;e++)0>b.indexOf(d[e])&&(c[d[e]]=a[d[e]]);return c};Object.defineProperty(c,'__esModule',{value:!0});var n=function(a){function b(b,c){var d=a.call(this,b,c)||this;return d.initializeQueryObservable=function(a){var b=a.variables,c=a.pollInterval,f=a.fetchPolicy,g=a.notifyOnNetworkStatusChange,h=a.query,i=u.parser(h);e.default(i.type===u.DocumentType.Query,'The <Query /> component requires a graphql query, but got a '+(i.type===u.DocumentType.Mutation?'mutation':'subscription')+'.');d.queryObservable=d.client.watchQuery({variables:b,pollInterval:c,query:h,fetchPolicy:f,notifyOnNetworkStatusChange:g})},d.startQuerySubscription=function(){d.querySubscription=d.queryObservable.subscribe({next:d.updateCurrentData,error:function(a){if(d.resubscribeToQuery(),!a.hasOwnProperty('graphQLErrors'))throw a;d.updateCurrentData()}})},d.removeQuerySubscription=function(){d.querySubscription&&d.querySubscription.unsubscribe()},d.updateCurrentData=function(){d.setState({result:d.queryObservable.currentResult()})},d.getQueryResult=function(){var a=d.state.result,b=a.loading,c=a.error,e=a.networkStatus,f=a.data;return k({client:d.client,data:i(f)?f:void 0,loading:b,error:c,networkStatus:e},h(d.queryObservable))},e.default(!!c.client,'Could not find "client" in the context of Query. Wrap the root component in an <ApolloProvider>'),d.client=c.client,d.initializeQueryObservable(b),d.state={result:d.queryObservable.currentResult()},d}return j(b,a),b.prototype.fetchData=function(){var a=this.props,b=a.children,c=a.ssr,d=l(a,['children','ssr']),e=d.fetchPolicy;if(!1===c)return!1;('network-only'===e||'cache-and-network'===e)&&(e='cache-first');var f=this.client.watchQuery(k({},d,{fetchPolicy:e})),g=this.queryObservable.currentResult();return!!g.loading&&f.result()},b.prototype.componentDidMount=function(){this.startQuerySubscription()},b.prototype.componentWillReceiveProps=function(a,b){f.default(this.props,a)&&this.client===b.client||(this.client!==b.client&&(this.client=b.client),this.removeQuerySubscription(),this.initializeQueryObservable(a),this.startQuerySubscription(),this.updateCurrentData())},b.prototype.componentWillUnmount=function(){this.removeQuerySubscription()},b.prototype.render=function(){var a=this.props.children,b=this.getQueryResult();return a(b)},b.prototype.resubscribeToQuery=function(){this.removeQuerySubscription();var a=this.queryObservable.getLastError(),b=this.queryObservable.getLastResult();this.queryObservable.resetLastResults(),this.startQuerySubscription(),Object.assign(this.queryObservable,{lastError:a,lastResult:b})},b.contextTypes={client:d.object.isRequired},b}(b.Component);c.default=n});k(x);var y=l(function(a,i){function j(a){var b=g.default(a,'variables','refetch','fetchMore','updateQuery','startPolling','stopPolling','subscribeToMore');return Object.keys(b).forEach(function(c){var d=c;'function'==typeof b[d]&&(b[d]=b[d].bind(a))}),b}function k(a){return a.displayName||a.name||'Component'}var l=m&&m.__extends||function(){var a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(a,c){a.__proto__=c}||function(a,c){for(var b in c)c.hasOwnProperty(b)&&(a[b]=c[b])};return function(c,d){function b(){this.constructor=c}a(c,d),c.prototype=null===d?Object.create(d):(b.prototype=d.prototype,new b)}}(),n=m&&m.__assign||Object.assign||function(a){for(var b,c=1,d=arguments.length;c<d;c++)for(var e in b=arguments[c],b)Object.prototype.hasOwnProperty.call(b,e)&&(a[e]=b[e]);return a};Object.defineProperty(i,'__esModule',{value:!0});var o=function(){return{}},p=function(a){return a},q=function(){return!1},r=0;i.default=function(a,g){void 0===g&&(g={});var i=g.options,m=void 0===i?o:i,s=g.skip,t=void 0===s?q:s,v=g.alias,w=void 0===v?'Apollo':v,x=m;'function'!=typeof x&&(x=function(){return m});var y=t;'function'!=typeof y&&(y=function(){return t});var z=g.props,A=u.parser(a),B=r++;return function(i){var m=w+'('+k(i)+')',o=function(h){function o(a,b){var c=h.call(this,a,b)||this;return c.previousData={},c.version=B,c.type=A.type,c.dataForChildViaMutation=c.dataForChildViaMutation.bind(c),c.setWrappedInstance=c.setWrappedInstance.bind(c),c}return l(o,h),o.prototype.componentWillMount=function(){this.shouldSkip(this.props)||this.setInitialProps()},o.prototype.componentDidMount=function(){if((this.hasMounted=!0,this.type!==u.DocumentType.Mutation)&&!this.shouldSkip(this.props)&&(this.subscribeToQuery(),this.refetcherQueue)){var a=this.refetcherQueue,b=a.args,c=a.resolve,d=a.reject;this.queryObservable.refetch(b).then(c).catch(d)}},o.prototype.componentWillReceiveProps=function(a,b){if(this.shouldSkip(a))return void(this.shouldSkip(this.props)||this.unsubscribeFromQuery());var c=x(a).client;if(!(f.default(this.props,a)&&(this.client===c||this.client===b.client)))return this.shouldRerender=!0,this.client!==c&&this.client!==b.client?(this.client=c?c:b.client,this.unsubscribeFromQuery(),this.queryObservable=null,this.previousData={},this.updateQuery(a),void(this.shouldSkip(a)||this.subscribeToQuery())):this.type===u.DocumentType.Mutation?void 0:this.type===u.DocumentType.Subscription&&g.shouldResubscribe&&g.shouldResubscribe(this.props,a)?(this.unsubscribeFromQuery(),delete this.queryObservable,this.updateQuery(a),void this.subscribeToQuery()):void(this.updateQuery(a),this.subscribeToQuery())},o.prototype.componentWillUnmount=function(){if(this.type===u.DocumentType.Query){if(this.queryObservable){var a=this.getQueryRecycler();a&&(a.recycle(this.queryObservable),delete this.queryObservable)}this.unsubscribeFromQuery()}this.type===u.DocumentType.Subscription&&this.unsubscribeFromQuery(),this.hasMounted=!1},o.prototype.getQueryRecycler=function(){return this.context.getQueryRecycler&&this.context.getQueryRecycler(o)},o.prototype.getClient=function(a){if(this.client)return this.client;var b=x(a).client;return this.client=b?b:this.context.client,e.default(!!this.client,'Could not find "client" in the context of "'+m+'". Wrap the root component in an <ApolloProvider>'),this.client},o.prototype.calculateOptions=function(a,b){void 0===a&&(a=this.props);var d=x(a);if(b&&b.variables&&(b.variables=c.default({},d.variables,b.variables)),b&&(d=c.default({},d,b)),d.variables||!A.variables.length)return d;for(var f={},g=0,h=A.variables;g<h.length;g++){var j=h[g],l=j.variable,o=j.type;if(l.name&&l.name.value){var p=l.name.value,q=a[p];if('undefined'!=typeof q){f[p]=q;continue}if('NonNullType'!==o.kind){f[p]=null;continue}e.default('undefined'!=typeof q,'The operation \''+A.name+'\' wrapping \''+k(i)+'\' '+('is expecting a variable: \''+l.name.value+'\' but it was not found in the props ')+('passed to \''+m+'\''))}}return d=n({},d,{variables:f}),d},o.prototype.calculateResultProps=function(a){var b=this.type===u.DocumentType.Mutation?'mutate':'data';g.name&&(b=g.name);var c=(d={},d[b]=a,d.ownProps=this.props,d);return z?z(c):(e={},e[b]=p(a),e);var d,e},o.prototype.setInitialProps=function(){if(this.type!==u.DocumentType.Mutation){var a=this.calculateOptions(this.props);this.createQuery(a)}},o.prototype.createQuery=function(b,d){if(void 0===d&&(d=this.props),this.type===u.DocumentType.Subscription)this.queryObservable=this.getClient(d).subscribe(c.default({query:a},b));else{var e=this.getQueryRecycler(),f=null;e&&(f=e.reuse(b)),this.queryObservable=null===f?this.getClient(d).watchQuery(c.default({query:a,metadata:{reactComponent:{displayName:m}}},b)):f}},o.prototype.updateQuery=function(a){var b=this.calculateOptions(a);this.queryObservable||this.createQuery(b,a),this.queryObservable._setOptionsNoResult?this.queryObservable._setOptionsNoResult(b):this.queryObservable.setOptions&&this.queryObservable.setOptions(b).catch(function(){return null})},o.prototype.fetchData=function(){if(this.shouldSkip())return!1;if(A.type===u.DocumentType.Mutation||A.type===u.DocumentType.Subscription)return!1;var b=this.calculateOptions();if(!1===b.ssr)return!1;('network-only'===b.fetchPolicy||'cache-and-network'===b.fetchPolicy)&&(b.fetchPolicy='cache-first');var d=this.getClient(this.props).watchQuery(c.default({query:a},b)),e=d.currentResult();return!!e.loading&&d.result()},o.prototype.subscribeToQuery=function(){var a=this;if(!this.querySubscription){var b=function(b){a.type===u.DocumentType.Subscription&&(a.lastSubscriptionData=b);var c=Object.keys(j(b.data));e.default(0===c.length,'the result of the \''+m+'\' operation contains keys that conflict with the return object.'+c.map(function(a){return'\''+a+'\''}).join(', ')+' not allowed.'),a.forceRenderChildren()},c=function(c){if(a.resubscribeToQuery(),c.hasOwnProperty('graphQLErrors'))return b({error:c});throw c};this.querySubscription=this.queryObservable.subscribe({next:b,error:c})}},o.prototype.unsubscribeFromQuery=function(){this.querySubscription&&(this.querySubscription.unsubscribe(),delete this.querySubscription)},o.prototype.resubscribeToQuery=function(){var a=this.querySubscription;a&&delete this.querySubscription;var b=this.queryObservable,c=b.lastError,d=b.lastResult;this.queryObservable.resetLastResults(),this.subscribeToQuery(),Object.assign(this.queryObservable,{lastError:c,lastResult:d}),a&&a.unsubscribe()},o.prototype.shouldSkip=function(a){return void 0===a&&(a=this.props),y(a)},o.prototype.forceRenderChildren=function(){this.shouldRerender=!0,this.hasMounted&&this.forceUpdate()},o.prototype.getWrappedInstance=function(){return e.default(g.withRef,'To access the wrapped instance, you need to specify { withRef: true } in the options'),this.wrappedInstance},o.prototype.setWrappedInstance=function(a){this.wrappedInstance=a},o.prototype.dataForChildViaMutation=function(b){var c=this.calculateOptions(this.props,b);return'undefined'==typeof c.variables&&delete c.variables,c.mutation=a,this.getClient(this.props).mutate(c)},o.prototype.dataForChild=function(){var a=this;if(this.type===u.DocumentType.Mutation)return this.dataForChildViaMutation;var b=this.calculateOptions(this.props),d={};if(c.default(d,j(this.queryObservable)),this.type===u.DocumentType.Subscription)c.default(d,{loading:!this.lastSubscriptionData,variables:b.variables},this.lastSubscriptionData&&this.lastSubscriptionData.data);else{var e=this.queryObservable.currentResult(),f=e.loading,g=e.error,h=e.networkStatus;c.default(d,{loading:f,networkStatus:h});var i=setTimeout(function(){if(g){var a=g;g.stack&&(a=g.stack.includes(g.message)?g.stack:g.message+'\n'+g.stack),console.error('Unhandled (in react-apollo:'+m+')',a)}},10);Object.defineProperty(d,'error',{configurable:!0,enumerable:!0,get:function(){return clearTimeout(i),g}}),f?c.default(d,this.previousData,e.data):g?c.default(d,(this.queryObservable.getLastResult()||{}).data):(c.default(d,e.data),this.previousData=e.data),this.querySubscription||(d.refetch=function(b){return new Promise(function(c,d){a.refetcherQueue={resolve:c,reject:d,args:b}})})}return d},o.prototype.render=function(){if(this.shouldSkip())return g.withRef?b.createElement(i,n({},c.default({},this.props,{ref:this.setWrappedInstance}))):b.createElement(i,n({},this.props));var a=this,d=a.shouldRerender,e=a.renderedElement,f=a.props;if(this.shouldRerender=!1,!d&&e&&e.type===i)return e;var h=this.dataForChild(),j=this.calculateResultProps(h),k=c.default({},f,j);return g.withRef&&(k.ref=this.setWrappedInstance),this.renderedElement=b.createElement(i,n({},k)),this.renderedElement},o.displayName=m,o.WrappedComponent=i,o.contextTypes={client:d.object,getQueryRecycler:d.func},o}(b.Component);return h.default(o,i,{})}}});k(y);var z=l(function(a,d){function f(a){return a.displayName||a.name||'Component'}var g=m&&m.__extends||function(){var a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(a,c){a.__proto__=c}||function(a,c){for(var b in c)c.hasOwnProperty(b)&&(a[b]=c[b])};return function(c,d){function b(){this.constructor=c}a(c,d),c.prototype=null===d?Object.create(d):(b.prototype=d.prototype,new b)}}(),i=m&&m.__assign||Object.assign||function(a){for(var b,c=1,d=arguments.length;c<d;c++)for(var e in b=arguments[c],b)Object.prototype.hasOwnProperty.call(b,e)&&(a[e]=b[e]);return a};Object.defineProperty(d,'__esModule',{value:!0}),d.default=function(a,d){void 0===d&&(d={});var j='withApollo('+f(a)+')',k=function(f){function h(a){var b=f.call(this,a)||this;return b.setWrappedInstance=b.setWrappedInstance.bind(b),b}return g(h,f),h.prototype.getWrappedInstance=function(){return e.default(d.withRef,'To access the wrapped instance, you need to specify { withRef: true } in the options'),this.wrappedInstance},h.prototype.setWrappedInstance=function(a){this.wrappedInstance=a},h.prototype.render=function(){var e=this;return b.createElement(p.default,null,function(f){var g=c.default({},e.props,{client:f,ref:d.withRef?e.setWrappedInstance:void 0});return b.createElement(a,i({},g))})},h.displayName=j,h.WrappedComponent=a,h}(b.Component);return h.default(k,a,{})}});k(z);var A=l(function(a,b){function c(a){for(var c in a)b.hasOwnProperty(c)||(b[c]=a[c])}Object.defineProperty(b,'__esModule',{value:!0}),b.getDataFromTree=n.default,c(n),b.ApolloConsumer=p.default,c(p),b.ApolloProvider=t.default,c(t),b.Query=x.default,c(x),b.graphql=y.default,c(y),b.withApollo=z.default,b.compose=i});k(A);var B=A.getDataFromTree,C=A.ApolloConsumer,D=A.ApolloProvider,E=A.Query,F=A.graphql,G=A.withApollo,H=A.compose,I=l(function(a,b){Object.defineProperty(b,'__esModule',{value:!0}),b.renderToStringWithData=function(a){return n.default(a).then(function(){return j.renderToString(a)})}});k(I);var J=I.renderToStringWithData,K=l(function(a,b){Object.defineProperty(b,'__esModule',{value:!0}),function(a){for(var c in a)b.hasOwnProperty(c)||(b[c]=a[c])}(A),b.renderToStringWithData=I.renderToStringWithData}),L=k(K),M=K.renderToStringWithData;a.default=L,a.renderToStringWithData=M,Object.defineProperty(a,'__esModule',{value:!0})}); | ||
(function(a,b){'object'==typeof exports&&'undefined'!=typeof module?b(exports,require('react'),require('object-assign'),require('prop-types'),require('invariant'),require('fbjs/lib/shallowEqual'),require('lodash/pick'),require('hoist-non-react-statics'),require('lodash/flowRight'),require('react-dom/server')):'function'==typeof define&&define.amd?define(['exports','react','object-assign','prop-types','invariant','fbjs/lib/shallowEqual','lodash/pick','hoist-non-react-statics','lodash/flowRight','react-dom/server'],b):b(a['react-apollo']={},a.React,a.assign,a.PropTypes,a.invariant,a.shallowEqual,a.pick,a.hoistNonReactStatics,a.flowRight,a.server)})(this,function(a,b,c,d,e,f,g,h,i,j){'use strict';function k(a){return a&&a.__esModule&&Object.prototype.hasOwnProperty.call(a,'default')?a['default']:a}function l(a,b){return b={exports:{}},a(b,b.exports),b.exports}b=b&&b.hasOwnProperty('default')?b['default']:b,c=c&&c.hasOwnProperty('default')?c['default']:c,d=d&&d.hasOwnProperty('default')?d['default']:d,e=e&&e.hasOwnProperty('default')?e['default']:e,f=f&&f.hasOwnProperty('default')?f['default']:f,g=g&&g.hasOwnProperty('default')?g['default']:g,h=h&&h.hasOwnProperty('default')?h['default']:h,i=i&&i.hasOwnProperty('default')?i['default']:i,j=j&&j.hasOwnProperty('default')?j['default']:j;var m='undefined'==typeof window?'undefined'==typeof global?'undefined'==typeof self?{}:self:global:window,n=l(function(a,d){function e(a){return a.props||a.attributes}function f(a){return!!a.type}function g(a){return a.prototype&&(a.prototype.render||a.prototype.isReactComponent)}function h(a){return!!a.getChildContext}function i(a,d,j){if(Array.isArray(a))return void a.forEach(function(a){return i(a,d,j)});if(a)if(!f(a))('string'==typeof a||'number'==typeof a)&&j(a,null,d);else if('function'==typeof a.type){var k,l=a.type,m=c({},l.defaultProps,e(a)),n=d;if(g(l)){var o=new l(m,d);if(o.props=o.props||m,o.context=o.context||d,o.state=o.state||null,o.setState=function(a){'function'==typeof a&&(a=a(o.state,o.props,o.context)),o.state=c({},o.state,a)},o.componentWillMount&&o.componentWillMount(),h(o)&&(n=c({},d,o.getChildContext())),!1===j(a,o,d))return;k=o.render()}else{if(!1===j(a,null,d))return;k=l(m,d)}k&&(Array.isArray(k)?k.forEach(function(a){return i(a,d,j)}):i(k,n,j))}else{if(!1===j(a,null,d))return;a.props&&a.props.children&&b.Children.forEach(a.props.children,function(a){a&&i(a,d,j)})}}function j(a){return'function'==typeof a.fetchData}function k(a){return'function'==typeof a.then}function l(a,b){var c=a.rootElement,d=a.rootContext,e=void 0===d?{}:d;void 0===b&&(b=!0);var g=[];return i(c,e,function(a,d,e){var h=!b&&a===c;if(!h&&d&&f(a)&&j(d)){var i=d.fetchData();if(k(i))return g.push({query:i,element:a,context:e}),!1}}),g}function m(a,b,c){void 0===b&&(b={}),void 0===c&&(c=!0);var d=l({rootElement:a,rootContext:b},c);if(!d.length)return Promise.resolve();var f=[],e=d.map(function(a){var b=a.query,c=a.element,d=a.context;return b.then(function(){return m(c,d,!1)}).catch(function(a){return f.push(a)})});return Promise.all(e).then(function(){if(0<f.length){var a=1===f.length?f[0]:new Error(f.length+' errors were thrown when executing your GraphQL queries.');throw a.queryErrors=f,a}})}Object.defineProperty(d,'__esModule',{value:!0}),d.walkTree=i,d.default=m});k(n);var o=n.walkTree,p=l(function(a,b){Object.defineProperty(b,'__esModule',{value:!0});var c=function(a,b){return e(!!b.client,'Could not find "client" in the context of ApolloConsumer. Wrap the root component in an <ApolloProvider>'),a.children(b.client)};c.contextTypes={client:d.object.isRequired},b.default=c});k(p);var q=l(function(a,b){var c=m&&m.__assign||Object.assign||function(a){for(var b,c=1,d=arguments.length;c<d;c++)for(var e in b=arguments[c],b)Object.prototype.hasOwnProperty.call(b,e)&&(a[e]=b[e]);return a},d=m&&m.__rest||function(a,b){var c={};for(var d in a)Object.prototype.hasOwnProperty.call(a,d)&&0>b.indexOf(d)&&(c[d]=a[d]);if(null!=a&&'function'==typeof Object.getOwnPropertySymbols)for(var e=0,d=Object.getOwnPropertySymbols(a);e<d.length;e++)0>b.indexOf(d[e])&&(c[d[e]]=a[d[e]]);return c};Object.defineProperty(b,'__esModule',{value:!0});var e=function(){function a(){this.observableQueries=[]}return a.prototype.recycle=function(a){a.setOptions({fetchPolicy:'standby',pollInterval:0,fetchResults:!1}),this.observableQueries.push({observableQuery:a,subscription:a.subscribe({})})},a.prototype.reuse=function(a){if(0>=this.observableQueries.length)return null;var b=this.observableQueries.pop();if(!b)return null;var e=b.observableQuery,g=b.subscription;g.unsubscribe();var h=a.ssr,i=a.client,j=d(a,['ssr','client']);return f(j.variables||{},e.variables)?(e.setOptions(c({},j,{pollInterval:a.pollInterval,fetchPolicy:a.fetchPolicy})),e):null},a}();b.ObservableQueryRecycler=e});k(q);var r=q.ObservableQueryRecycler,s=l(function(a,c){var e=m&&m.__extends||function(){var a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(a,c){a.__proto__=c}||function(a,c){for(var b in c)c.hasOwnProperty(b)&&(a[b]=c[b])};return function(c,d){function b(){this.constructor=c}a(c,d),c.prototype=null===d?Object.create(d):(b.prototype=d.prototype,new b)}}();Object.defineProperty(c,'__esModule',{value:!0});var f=function(a){function b(b){var c=a.call(this,b)||this;return c.recyclers=new WeakMap,c.getQueryRecycler=c.getQueryRecycler.bind(c),c}return e(b,a),b.prototype.componentWillReceiveProps=function(a,b){this.context.client!==b.client&&(this.recyclers=new WeakMap)},b.prototype.getQueryRecycler=function(a){return this.recyclers.has(a)||this.recyclers.set(a,new q.ObservableQueryRecycler),this.recyclers.get(a)},b.prototype.getChildContext=function(){return{getQueryRecycler:this.getQueryRecycler}},b.prototype.render=function(){return this.props.children},b.propTypes={children:d.element.isRequired},b.contextTypes={client:d.object},b.childContextTypes={getQueryRecycler:d.func.isRequired},b}(b.Component);c.default=f});k(s);var t=l(function(a,c){var f=m&&m.__extends||function(){var a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(a,c){a.__proto__=c}||function(a,c){for(var b in c)c.hasOwnProperty(b)&&(a[b]=c[b])};return function(c,d){function b(){this.constructor=c}a(c,d),c.prototype=null===d?Object.create(d):(b.prototype=d.prototype,new b)}}();Object.defineProperty(c,'__esModule',{value:!0});var g=b,h=function(a){function c(b,c){var d=a.call(this,b,c)||this;return e(b.client,'ApolloClient was not passed a client instance. Make sure you pass in your client via the "client" prop.'),d}return f(c,a),c.prototype.getChildContext=function(){return{client:this.props.client}},c.prototype.render=function(){return b.createElement(s.default,null,b.Children.only(this.props.children))},c.propTypes={client:d.object.isRequired,children:d.element.isRequired},c.childContextTypes={client:d.object.isRequired},c}(g.Component);c.default=h});k(t);var u=l(function(a,b){Object.defineProperty(b,'__esModule',{value:!0});var c;(function(a){a[a.Query=0]='Query',a[a.Mutation=1]='Mutation',a[a.Subscription=2]='Subscription'})(c=b.DocumentType||(b.DocumentType={})),b.parser=function(a){var b,d,f;e(!!a&&!!a.kind,'Argument of '+a+' passed to parser was not a valid GraphQL DocumentNode. You may need to use \'graphql-tag\' or another method to convert your operation into a document');var g=a.definitions.filter(function(a){return'FragmentDefinition'===a.kind}),h=a.definitions.filter(function(a){return'OperationDefinition'===a.kind&&'query'===a.operation}),i=a.definitions.filter(function(a){return'OperationDefinition'===a.kind&&'mutation'===a.operation}),j=a.definitions.filter(function(a){return'OperationDefinition'===a.kind&&'subscription'===a.operation});e(!g.length||h.length||i.length||j.length,'Passing only a fragment to \'graphql\' is not yet supported. You must include a query, subscription or mutation as well'),e(1>=h.length+i.length+j.length,'react-apollo only supports a query, subscription, or a mutation per HOC. '+(a+' had '+h.length+' queries, '+j.length+' ')+('subscriptions and '+i.length+' mutations. You can use \'compose\' to join multiple operation types to a component')),d=h.length?c.Query:c.Mutation,h.length||i.length||(d=c.Subscription);var k=h.length?h:i.length?i:j;e(1===k.length,'react-apollo only supports one defintion per HOC. '+a+' had '+(k.length+' definitions. You can use \'compose\' to join multiple operation types to a component'));var l=k[0];return b=l.variableDefinitions||[],f=l.name&&'Name'===l.name.kind?l.name.value:'data',{name:f,type:d,variables:b}}});k(u);var v=u.DocumentType,w=u.parser,x=l(function(a,c){function h(a){var b=g(a,'refetch','fetchMore','updateQuery','startPolling','stopPolling');return Object.keys(b).forEach(function(c){var d=c;'function'==typeof b[d]&&(b[d]=b[d].bind(a))}),b}function i(a){return 0<Object.keys(a).length}var j=m&&m.__extends||function(){var a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(a,c){a.__proto__=c}||function(a,c){for(var b in c)c.hasOwnProperty(b)&&(a[b]=c[b])};return function(c,d){function b(){this.constructor=c}a(c,d),c.prototype=null===d?Object.create(d):(b.prototype=d.prototype,new b)}}(),k=m&&m.__assign||Object.assign||function(a){for(var b,c=1,d=arguments.length;c<d;c++)for(var e in b=arguments[c],b)Object.prototype.hasOwnProperty.call(b,e)&&(a[e]=b[e]);return a},l=m&&m.__rest||function(a,b){var c={};for(var d in a)Object.prototype.hasOwnProperty.call(a,d)&&0>b.indexOf(d)&&(c[d]=a[d]);if(null!=a&&'function'==typeof Object.getOwnPropertySymbols)for(var e=0,d=Object.getOwnPropertySymbols(a);e<d.length;e++)0>b.indexOf(d[e])&&(c[d[e]]=a[d[e]]);return c};Object.defineProperty(c,'__esModule',{value:!0});var n=function(a){function b(b,c){var d=a.call(this,b,c)||this;return d.initializeQueryObservable=function(a){var b=a.variables,c=a.pollInterval,f=a.fetchPolicy,g=a.notifyOnNetworkStatusChange,h=a.query,i=u.parser(h);e(i.type===u.DocumentType.Query,'The <Query /> component requires a graphql query, but got a '+(i.type===u.DocumentType.Mutation?'mutation':'subscription')+'.');d.queryObservable=d.client.watchQuery({variables:b,pollInterval:c,query:h,fetchPolicy:f,notifyOnNetworkStatusChange:g})},d.startQuerySubscription=function(){d.querySubscription=d.queryObservable.subscribe({next:d.updateCurrentData,error:function(a){if(d.resubscribeToQuery(),!a.hasOwnProperty('graphQLErrors'))throw a;d.updateCurrentData()}})},d.removeQuerySubscription=function(){d.querySubscription&&d.querySubscription.unsubscribe()},d.updateCurrentData=function(){d.setState({result:d.queryObservable.currentResult()})},d.getQueryResult=function(){var a=d.state.result,b=a.loading,c=a.error,e=a.networkStatus,f=a.data;return k({client:d.client,data:i(f)?f:void 0,loading:b,error:c,networkStatus:e},h(d.queryObservable))},e(!!c.client,'Could not find "client" in the context of Query. Wrap the root component in an <ApolloProvider>'),d.client=c.client,d.initializeQueryObservable(b),d.state={result:d.queryObservable.currentResult()},d}return j(b,a),b.prototype.fetchData=function(){var a=this.props,b=a.children,c=a.ssr,d=l(a,['children','ssr']),e=d.fetchPolicy;if(!1===c)return!1;('network-only'===e||'cache-and-network'===e)&&(e='cache-first');var f=this.client.watchQuery(k({},d,{fetchPolicy:e})),g=this.queryObservable.currentResult();return!!g.loading&&f.result()},b.prototype.componentDidMount=function(){this.startQuerySubscription()},b.prototype.componentWillReceiveProps=function(a,b){f(this.props,a)&&this.client===b.client||(this.client!==b.client&&(this.client=b.client),this.removeQuerySubscription(),this.initializeQueryObservable(a),this.startQuerySubscription(),this.updateCurrentData())},b.prototype.componentWillUnmount=function(){this.removeQuerySubscription()},b.prototype.render=function(){var a=this.props.children,b=this.getQueryResult();return a(b)},b.prototype.resubscribeToQuery=function(){this.removeQuerySubscription();var a=this.queryObservable.getLastError(),b=this.queryObservable.getLastResult();this.queryObservable.resetLastResults(),this.startQuerySubscription(),Object.assign(this.queryObservable,{lastError:a,lastResult:b})},b.contextTypes={client:d.object.isRequired},b}(b.Component);c.default=n});k(x);var y=l(function(a,i){function j(a){var b=g(a,'variables','refetch','fetchMore','updateQuery','startPolling','stopPolling','subscribeToMore');return Object.keys(b).forEach(function(c){var d=c;'function'==typeof b[d]&&(b[d]=b[d].bind(a))}),b}function k(a){return a.displayName||a.name||'Component'}var l=m&&m.__extends||function(){var a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(a,c){a.__proto__=c}||function(a,c){for(var b in c)c.hasOwnProperty(b)&&(a[b]=c[b])};return function(c,d){function b(){this.constructor=c}a(c,d),c.prototype=null===d?Object.create(d):(b.prototype=d.prototype,new b)}}(),n=m&&m.__assign||Object.assign||function(a){for(var b,c=1,d=arguments.length;c<d;c++)for(var e in b=arguments[c],b)Object.prototype.hasOwnProperty.call(b,e)&&(a[e]=b[e]);return a};Object.defineProperty(i,'__esModule',{value:!0});var o=function(){return{}},p=function(a){return a},q=function(){return!1},r=0;i.default=function(a,g){void 0===g&&(g={});var i=g.options,m=void 0===i?o:i,s=g.skip,t=void 0===s?q:s,v=g.alias,w=void 0===v?'Apollo':v,x=m;'function'!=typeof x&&(x=function(){return m});var y=t;'function'!=typeof y&&(y=function(){return t});var z=g.props,A=u.parser(a),B=r++;return function(i){var m=w+'('+k(i)+')',o=function(h){function o(a,b){var c=h.call(this,a,b)||this;return c.previousData={},c.version=B,c.type=A.type,c.dataForChildViaMutation=c.dataForChildViaMutation.bind(c),c.setWrappedInstance=c.setWrappedInstance.bind(c),c}return l(o,h),o.prototype.componentWillMount=function(){this.shouldSkip(this.props)||this.setInitialProps()},o.prototype.componentDidMount=function(){if((this.hasMounted=!0,this.type!==u.DocumentType.Mutation)&&!this.shouldSkip(this.props)&&(this.subscribeToQuery(),this.refetcherQueue)){var a=this.refetcherQueue,b=a.args,c=a.resolve,d=a.reject;this.queryObservable.refetch(b).then(c).catch(d)}},o.prototype.componentWillReceiveProps=function(a,b){if(this.shouldSkip(a))return void(this.shouldSkip(this.props)||this.unsubscribeFromQuery());var c=x(a).client;if(!(f(this.props,a)&&(this.client===c||this.client===b.client)))return this.shouldRerender=!0,this.client!==c&&this.client!==b.client?(this.client=c?c:b.client,this.unsubscribeFromQuery(),this.queryObservable=null,this.previousData={},this.updateQuery(a),void(this.shouldSkip(a)||this.subscribeToQuery())):this.type===u.DocumentType.Mutation?void 0:this.type===u.DocumentType.Subscription&&g.shouldResubscribe&&g.shouldResubscribe(this.props,a)?(this.unsubscribeFromQuery(),delete this.queryObservable,this.updateQuery(a),void this.subscribeToQuery()):void(this.updateQuery(a),this.subscribeToQuery())},o.prototype.componentWillUnmount=function(){if(this.type===u.DocumentType.Query){if(this.queryObservable){var a=this.getQueryRecycler();a&&(a.recycle(this.queryObservable),delete this.queryObservable)}this.unsubscribeFromQuery()}this.type===u.DocumentType.Subscription&&this.unsubscribeFromQuery(),this.hasMounted=!1},o.prototype.getQueryRecycler=function(){return this.context.getQueryRecycler&&this.context.getQueryRecycler(o)},o.prototype.getClient=function(a){if(this.client)return this.client;var b=x(a).client;return this.client=b?b:this.context.client,e(!!this.client,'Could not find "client" in the context of "'+m+'". Wrap the root component in an <ApolloProvider>'),this.client},o.prototype.calculateOptions=function(a,b){void 0===a&&(a=this.props);var d=x(a);if(b&&b.variables&&(b.variables=c({},d.variables,b.variables)),b&&(d=c({},d,b)),d.variables||!A.variables.length)return d;for(var f={},g=0,h=A.variables;g<h.length;g++){var j=h[g],l=j.variable,o=j.type;if(l.name&&l.name.value){var p=l.name.value,q=a[p];if('undefined'!=typeof q){f[p]=q;continue}if('NonNullType'!==o.kind){f[p]=null;continue}e('undefined'!=typeof q,'The operation \''+A.name+'\' wrapping \''+k(i)+'\' '+('is expecting a variable: \''+l.name.value+'\' but it was not found in the props ')+('passed to \''+m+'\''))}}return d=n({},d,{variables:f}),d},o.prototype.calculateResultProps=function(a){var b=this.type===u.DocumentType.Mutation?'mutate':'data';g.name&&(b=g.name);var c=(d={},d[b]=a,d.ownProps=this.props,d);return z?z(c):(e={},e[b]=p(a),e);var d,e},o.prototype.setInitialProps=function(){if(this.type!==u.DocumentType.Mutation){var a=this.calculateOptions(this.props);this.createQuery(a)}},o.prototype.createQuery=function(b,d){if(void 0===d&&(d=this.props),this.type===u.DocumentType.Subscription)this.queryObservable=this.getClient(d).subscribe(c({query:a},b));else{var e=this.getQueryRecycler(),f=null;e&&(f=e.reuse(b)),this.queryObservable=null===f?this.getClient(d).watchQuery(c({query:a,metadata:{reactComponent:{displayName:m}}},b)):f}},o.prototype.updateQuery=function(a){var b=this.calculateOptions(a);this.queryObservable||this.createQuery(b,a),this.queryObservable._setOptionsNoResult?this.queryObservable._setOptionsNoResult(b):this.queryObservable.setOptions&&this.queryObservable.setOptions(b).catch(function(){return null})},o.prototype.fetchData=function(){if(this.shouldSkip())return!1;if(A.type===u.DocumentType.Mutation||A.type===u.DocumentType.Subscription)return!1;var b=this.calculateOptions();if(!1===b.ssr)return!1;('network-only'===b.fetchPolicy||'cache-and-network'===b.fetchPolicy)&&(b.fetchPolicy='cache-first');var d=this.getClient(this.props).watchQuery(c({query:a},b)),e=d.currentResult();return!!e.loading&&d.result()},o.prototype.subscribeToQuery=function(){var a=this;if(!this.querySubscription){var b=function(b){a.type===u.DocumentType.Subscription&&(a.lastSubscriptionData=b);var c=Object.keys(j(b.data));e(0===c.length,'the result of the \''+m+'\' operation contains keys that conflict with the return object.'+c.map(function(a){return'\''+a+'\''}).join(', ')+' not allowed.'),a.forceRenderChildren()},c=function(c){if(a.resubscribeToQuery(),c.hasOwnProperty('graphQLErrors'))return b({error:c});throw c};this.querySubscription=this.queryObservable.subscribe({next:b,error:c})}},o.prototype.unsubscribeFromQuery=function(){this.querySubscription&&(this.querySubscription.unsubscribe(),delete this.querySubscription)},o.prototype.resubscribeToQuery=function(){var a=this.querySubscription;a&&delete this.querySubscription;var b=this.queryObservable,c=b.lastError,d=b.lastResult;this.queryObservable.resetLastResults(),this.subscribeToQuery(),Object.assign(this.queryObservable,{lastError:c,lastResult:d}),a&&a.unsubscribe()},o.prototype.shouldSkip=function(a){return void 0===a&&(a=this.props),y(a)},o.prototype.forceRenderChildren=function(){this.shouldRerender=!0,this.hasMounted&&this.forceUpdate()},o.prototype.getWrappedInstance=function(){return e(g.withRef,'To access the wrapped instance, you need to specify { withRef: true } in the options'),this.wrappedInstance},o.prototype.setWrappedInstance=function(a){this.wrappedInstance=a},o.prototype.dataForChildViaMutation=function(b){var c=this.calculateOptions(this.props,b);return'undefined'==typeof c.variables&&delete c.variables,c.mutation=a,this.getClient(this.props).mutate(c)},o.prototype.dataForChild=function(){var a=this;if(this.type===u.DocumentType.Mutation)return this.dataForChildViaMutation;var b=this.calculateOptions(this.props),d={};if(c(d,j(this.queryObservable)),this.type===u.DocumentType.Subscription)c(d,{loading:!this.lastSubscriptionData,variables:b.variables},this.lastSubscriptionData&&this.lastSubscriptionData.data);else{var e=this.queryObservable.currentResult(),f=e.loading,g=e.error,h=e.networkStatus;c(d,{loading:f,networkStatus:h});var i=setTimeout(function(){if(g){var a=g;g.stack&&(a=g.stack.includes(g.message)?g.stack:g.message+'\n'+g.stack),console.error('Unhandled (in react-apollo:'+m+')',a)}},10);Object.defineProperty(d,'error',{configurable:!0,enumerable:!0,get:function(){return clearTimeout(i),g}}),f?c(d,this.previousData,e.data):g?c(d,(this.queryObservable.getLastResult()||{}).data):(c(d,e.data),this.previousData=e.data),this.querySubscription||(d.refetch=function(b){return new Promise(function(c,d){a.refetcherQueue={resolve:c,reject:d,args:b}})})}return d},o.prototype.render=function(){if(this.shouldSkip())return g.withRef?b.createElement(i,n({},c({},this.props,{ref:this.setWrappedInstance}))):b.createElement(i,n({},this.props));var a=this,d=a.shouldRerender,e=a.renderedElement,f=a.props;if(this.shouldRerender=!1,!d&&e&&e.type===i)return e;var h=this.dataForChild(),j=this.calculateResultProps(h),k=c({},f,j);return g.withRef&&(k.ref=this.setWrappedInstance),this.renderedElement=b.createElement(i,n({},k)),this.renderedElement},o.displayName=m,o.WrappedComponent=i,o.contextTypes={client:d.object,getQueryRecycler:d.func},o}(b.Component);return h(o,i,{})}}});k(y);var z=l(function(a,d){function f(a){return a.displayName||a.name||'Component'}var g=m&&m.__extends||function(){var a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(a,c){a.__proto__=c}||function(a,c){for(var b in c)c.hasOwnProperty(b)&&(a[b]=c[b])};return function(c,d){function b(){this.constructor=c}a(c,d),c.prototype=null===d?Object.create(d):(b.prototype=d.prototype,new b)}}(),i=m&&m.__assign||Object.assign||function(a){for(var b,c=1,d=arguments.length;c<d;c++)for(var e in b=arguments[c],b)Object.prototype.hasOwnProperty.call(b,e)&&(a[e]=b[e]);return a};Object.defineProperty(d,'__esModule',{value:!0}),d.default=function(a,d){void 0===d&&(d={});var j='withApollo('+f(a)+')',k=function(f){function h(a){var b=f.call(this,a)||this;return b.setWrappedInstance=b.setWrappedInstance.bind(b),b}return g(h,f),h.prototype.getWrappedInstance=function(){return e(d.withRef,'To access the wrapped instance, you need to specify { withRef: true } in the options'),this.wrappedInstance},h.prototype.setWrappedInstance=function(a){this.wrappedInstance=a},h.prototype.render=function(){var e=this;return b.createElement(p.default,null,function(f){var g=c({},e.props,{client:f,ref:d.withRef?e.setWrappedInstance:void 0});return b.createElement(a,i({},g))})},h.displayName=j,h.WrappedComponent=a,h}(b.Component);return h(k,a,{})}});k(z);var A=l(function(a,b){function c(a){for(var c in a)b.hasOwnProperty(c)||(b[c]=a[c])}Object.defineProperty(b,'__esModule',{value:!0}),b.getDataFromTree=n.default,c(n),b.ApolloConsumer=p.default,c(p),b.ApolloProvider=t.default,c(t),b.Query=x.default,c(x),b.graphql=y.default,c(y),b.withApollo=z.default,b.compose=i});k(A);var B=A.getDataFromTree,C=A.ApolloConsumer,D=A.ApolloProvider,E=A.Query,F=A.graphql,G=A.withApollo,H=A.compose,I=l(function(a,b){Object.defineProperty(b,'__esModule',{value:!0}),b.renderToStringWithData=function(a){return n.default(a).then(function(){return j.renderToString(a)})}});k(I);var J=I.renderToStringWithData,K=l(function(a,b){Object.defineProperty(b,'__esModule',{value:!0}),function(a){for(var c in a)b.hasOwnProperty(c)||(b[c]=a[c])}(A),b.renderToStringWithData=I.renderToStringWithData}),L=k(K),M=K.renderToStringWithData;a.default=L,a.renderToStringWithData=M,Object.defineProperty(a,'__esModule',{value:!0})}); |
@@ -23,5 +23,5 @@ "use strict"; | ||
var ApolloConsumer_1 = require("./ApolloConsumer"); | ||
var object_assign_1 = require("object-assign"); | ||
var invariant_1 = require("invariant"); | ||
var hoist_non_react_statics_1 = require("hoist-non-react-statics"); | ||
var assign = require('object-assign'); | ||
var invariant = require('invariant'); | ||
var hoistNonReactStatics = require('hoist-non-react-statics'); | ||
function getDisplayName(WrappedComponent) { | ||
@@ -41,3 +41,3 @@ return WrappedComponent.displayName || WrappedComponent.name || 'Component'; | ||
WithApollo.prototype.getWrappedInstance = function () { | ||
invariant_1.default(operationOptions.withRef, "To access the wrapped instance, you need to specify " + | ||
invariant(operationOptions.withRef, "To access the wrapped instance, you need to specify " + | ||
"{ withRef: true } in the options"); | ||
@@ -52,3 +52,3 @@ return this.wrappedInstance; | ||
return (React.createElement(ApolloConsumer_1.default, null, function (client) { | ||
var props = object_assign_1.default({}, _this.props, { | ||
var props = assign({}, _this.props, { | ||
client: client, | ||
@@ -66,5 +66,5 @@ ref: operationOptions.withRef | ||
}(React.Component)); | ||
return hoist_non_react_statics_1.default(WithApollo, WrappedComponent, {}); | ||
return hoistNonReactStatics(WithApollo, WrappedComponent, {}); | ||
} | ||
exports.default = withApollo; | ||
//# sourceMappingURL=withApollo.js.map |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
294572
2922