Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2017
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. a.variables=a.options.variables||{},a.scheduler=r,a.queryManager=s,a.queryId=u,a.shouldSubscribe=i,a.observers=[],a.subscriptionHandles=[],a}return ht(r,t),r.prototype.result=function(){var e=this;return new Promise(function(t,r){var n=e.subscribe({next:function(e){t(e),setTimeout(function(){n.unsubscribe()},0)},error:function(e){r(e)}})})},r.prototype.currentResult=function(){var t=this.queryManager.getCurrentQueryResult(this,!0),r=t.data,n=t.partial,o=this.queryManager.getApolloState().queries[this.queryId];if(o&&(o.graphQLErrors&&o.graphQLErrors.length>0||o.networkError)){var i=new ft({graphQLErrors:o.graphQLErrors,networkError:o.networkError});return{data:{},loading:!1,networkStatus:o.networkStatus,error:i}}var a,s=!o||o.networkStatus===e.NetworkStatus.loading,u=this.options.forceFetch&&s||n&&!this.options.noFetch;return a=o?o.networkStatus:u?e.NetworkStatus.loading:e.NetworkStatus.ready,{data:r,loading:we(a),networkStatus:a,partial:n}},r.prototype.getLastResult=function(){return this.lastResult},r.prototype.refetch=function(e){var t=this;if(this.variables=dt({},this.variables,e),this.options.noFetch)throw new Error("noFetch option should not use query refetch.");this.options.variables=dt({},this.options.variables,this.variables);var r=dt({},this.options,{forceFetch:!0});return this.queryManager.fetchQuery(this.queryId,r,nt.refetch).then(function(e){return t.queryManager.transformResult(e)})},r.prototype.fetchMore=function(e){var t=this;return Promise.resolve().then(function(){var r=t.queryManager.generateQueryId(),n=null;if(e.query)n=e;else{var o=dt({},t.variables,e.variables);n=dt({},t.options,e,{variables:o})}return n=dt({},n,{query:n.query,forceFetch:!0}),t.queryManager.fetchQuery(r,n,nt.normal,t.queryId)}).then(function(r){var n=e.updateQuery,o=function(e,t){return n(e,{fetchMoreResult:r,queryVariables:t.variables})};return t.updateQuery(o),r})},r.prototype.subscribeToMore=function(e){var t=this,r=this.queryManager.startGraphQLSubscription({document:e.document,variables:e.variables}),n=e.updateQuery,o=r.subscribe({next:function(e){var r=function(t,r){return n(t,{subscriptionData:{data:e},variables:r.variables})};t.updateQuery(r)},error:function(t){e.onError?e.onError(t):console.error("Unhandled GraphQL subscription errror",t)}});return this.subscriptionHandles.push(o),function(){var e=t.subscriptionHandles.indexOf(o);e>=0&&(t.subscriptionHandles.splice(e,1),o.unsubscribe())}},r.prototype.setOptions=function(e){var t=this.options;this.options=dt({},this.options,e),e.pollInterval?this.startPolling(e.pollInterval):0===e.pollInterval&&this.stopPolling();var r=!t.forceFetch&&e.forceFetch||t.noFetch&&!e.noFetch||!1;return this.setVariables(this.options.variables,r)},r.prototype.setVariables=function(e,t){var r=this;void 0===t&&(t=!1);var n=dt({},this.variables,e);return ie(n,this.variables)&&!t?0===this.observers.length?new Promise(function(e){return e()}):this.result():(this.variables=n,0===this.observers.length?new Promise(function(e){return e()}):this.queryManager.fetchQuery(this.queryId,dt({},this.options,{variables:this.variables})).then(function(e){return r.queryManager.transformResult(e)}))},r.prototype.updateQuery=function(e){var t=this.queryManager.getQueryWithPreviousResult(this.queryId),r=t.previousResult,n=t.variables,o=t.document,i=be(function(){return e(r,{variables:n})});i&&this.queryManager.store.dispatch({type:"APOLLO_UPDATE_QUERY_RESULT",newResult:i,variables:n,document:o})},r.prototype.stopPolling=function(){this.isCurrentlyPolling&&(this.scheduler.stopPollingQuery(this.queryId),this.options.pollInterval=void 0,this.isCurrentlyPolling=!1)},r.prototype.startPolling=function(e){if(this.options.noFetch)throw new Error("noFetch option should not use query polling.");this.isCurrentlyPolling&&(this.scheduler.stopPollingQuery(this.queryId),this.isCurrentlyPolling=!1),this.options.pollInterval=e,this.isCurrentlyPolling=!0,this.scheduler.startPollingQuery(this.options,this.queryId)},r.prototype.onSubscribe=function(e){var t=this;return this.observers.push(e),e.next&&this.lastResult&&e.next(this.lastResult),e.error&&this.lastError&&e.error(this.lastError),1===this.observers.length&&this.setUpQuery(),{unsubscribe:function(){t.observers.findIndex(function(t){return t===e})<0||(t.observers=t.observers.filter(function(t){return t!==e}),0===t.observers.length&&t.tearDownQuery())}}},r.prototype.setUpQuery=function(){var e=this;if(this.shouldSubscribe&&this.queryManager.addObservableQuery(this.queryId,this),this.options.pollInterval){if(this.options.noFetch)throw new Error("noFetch option should not use query polling.");this.isCurrentlyPolling=!0,this.scheduler.startPollingQuery(this.options,this.queryId)}var t={next:function(t){e.lastResult=t,e.observers.forEach(function(e){e.next&&e.next(t)})},error:function(t){e.observers.forEach(function(e){e.error?e.error(t):console.error("Unhandled error",t.message,t.stack)}),e.lastError=t}};this.queryManager.startQuery(this.queryId,this.options,this.queryManager.queryListenerForObserver(this.queryId,this.options,t))},r.prototype.tearDownQuery=function(){this.isCurrentlyPolling&&(this.scheduler.stopPollingQuery(this.queryId),this.isCurrentlyPolling=!1),this.subscriptionHandles.forEach(function(e){return e.unsubscribe()}),this.subscriptionHandles=[],this.queryManager.stopQuery(this.queryId),this.shouldSubscribe&&this.queryManager.removeObservableQuery(this.queryId),this.observers=[]},r}(ut),yt={kind:"Field",name:{kind:"Name",value:"__typename"}},vt=function(){function e(e){this.networkInterface=e,this.inFlightRequestPromises={}}return e.prototype.query=function(e,t){var r=this;if(void 0===t&&(t=!0),!t)return this.networkInterface.query(e);var n=this.getKey(e);return this.inFlightRequestPromises[n]||(this.inFlightRequestPromises[n]=this.networkInterface.query(e)),this.inFlightRequestPromises[n].then(function(e){return delete r.inFlightRequestPromises[n],e})},e.prototype.getKey=function(e){return r.print(e.query)+"|"+JSON.stringify(e.variables)+"|"+e.operationName},e}(),mt=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++){t=arguments[r];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])}return e},bt=function(){function t(e){var t=e.queryManager;this.queryManager=t,this.pollingTimers={},this.inFlightQueries={},this.registeredQueries={},this.intervalQueries={}}return t.prototype.checkInFlight=function(t){var r=this.queryManager.getApolloState().queries;return r[t]&&r[t].networkStatus!==e.NetworkStatus.ready},t.prototype.fetchQuery=function(e,t,r){var n=this;return new Promise(function(o,i){n.queryManager.fetchQuery(e,t,r).then(function(e){o(e)}).catch(function(e){i(e)})})},t.prototype.startPollingQuery=function(e,t,r){if(!e.pollInterval)throw new Error("Attempted to start a polling query without a polling interval.");return this.registeredQueries[t]=e,r&&this.queryManager.addQueryListener(t,r),this.addQueryOnInterval(t,e),t},t.prototype.stopPollingQuery=function(e){delete this.registeredQueries[e]},t.prototype.fetchQueriesOnInterval=function(e){var t=this;this.intervalQueries[e]=this.intervalQueries[e].filter(function(e){if(!t.registeredQueries.hasOwnProperty(e))return!1;if(t.checkInFlight(e))return!0;var r=t.registeredQueries[e],n=mt({},r);return n.forceFetch=!0,t.fetchQuery(e,n,nt.poll),!0}),0===this.intervalQueries[e].length&&(clearInterval(this.pollingTimers[e]),delete this.intervalQueries[e])},t.prototype.addQueryOnInterval=function(e,t){var r=this,n=t.pollInterval;if(!n)throw new Error("A poll interval is required to start polling query with id '"+e+"'.");this.intervalQueries.hasOwnProperty(n.toString())&&this.intervalQueries[n].length>0?this.intervalQueries[n].push(e):(this.intervalQueries[n]=[e],this.pollingTimers[n]=setInterval(function(){r.fetchQueriesOnInterval(n)},n))},t.prototype.registerPollingQuery=function(e){if(!e.pollInterval)throw new Error("Attempted to register a non-polling query with the scheduler.");return new pt({scheduler:this,options:e})},t}(),gt=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++){t=arguments[r];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])}return e},wt=function(){function t(e){var t=e.networkInterface,r=e.store,n=e.reduxRootSelector,o=e.reducerConfig,i=void 0===o?{mutationBehaviorReducers:{}}:o,a=e.resultTransformer,s=e.resultComparator,u=e.addTypename,c=void 0===u||u,l=e.queryDeduplication,f=void 0!==l&&l,h=this;if(this.idCounter=1,this.networkInterface=t,this.deduplicator=new vt(t),this.store=r,this.reduxRootSelector=n,this.reducerConfig=i,this.resultTransformer=a,this.resultComparator=s,this.pollingTimers={},this.queryListeners={},this.queryDocuments={},this.addTypename=c,this.queryDeduplication=f,this.scheduler=new bt({queryManager:this}),this.fetchQueryPromises={},this.observableQueries={},this.queryIdsByName={},this.store.subscribe){var d;this.store.subscribe(function(){var e=d||{},t=Object.keys(e).length;d=h.getApolloState(),ie(e,d)&&t||h.broadcastQueries()})}}return t.prototype.broadcastNewStore=function(e){this.broadcastQueries()},t.prototype.mutate=function(e){var t=this,n=e.mutation,o=e.variables,i=e.optimisticResponse,a=e.updateQueries,s=e.refetchQueries,u=void 0===s?[]:s,c=e.update,l=this.generateQueryId();this.addTypename&&(n=Fe(n)),O(n);var f=r.print(n),h={query:n,variables:o,operationName:I(n)};this.queryDocuments[l]=n;var d={};return a&&Object.keys(a).forEach(function(e){return(t.queryIdsByName[e]||[]).forEach(function(t){d[t]=a[e]})}),this.store.dispatch({type:"APOLLO_MUTATION_INIT",mutationString:f,mutation:n,variables:o||{},operationName:I(n),mutationId:l,optimisticResponse:i,extraReducers:this.getExtraReducers(),updateQueries:d,update:c}),new Promise(function(e,r){t.networkInterface.query(h).then(function(i){if(i.errors)return void r(new ft({graphQLErrors:i.errors}));t.store.dispatch({type:"APOLLO_MUTATION_RESULT",result:i,mutationId:l,document:n,operationName:I(n),variables:o||{},extraReducers:t.getExtraReducers(),updateQueries:d,update:c});var a=t.getApolloState().reducerError;if(a)return void r(a);"string"==typeof u[0]?u.forEach(function(e){t.refetchQueryByName(e)}):u.forEach(function(e){t.query({query:e.query,variables:e.variables,forceFetch:!0})}),delete t.queryDocuments[l],e(t.transformResult(i))}).catch(function(e){t.store.dispatch({type:"APOLLO_MUTATION_ERROR",error:e,mutationId:l}),delete t.queryDocuments[l],r(new ft({networkError:e}))})})},t.prototype.queryListenerForObserver=function(e,t,r){var n,o=this;return function(i){if(i){var a=o.observableQueries[e]?o.observableQueries[e].observableQuery.options.noFetch:t.noFetch,s=i.returnPartialData||i.previousVariables||a,u=n&&i.networkStatus!==n.networkStatus;if(!we(i.networkStatus)||u&&t.notifyOnNetworkStatusChange||s)if(i.graphQLErrors&&i.graphQLErrors.length>0||i.networkError){var c=new ft({graphQLErrors:i.graphQLErrors,networkError:i.networkError});if(r.error)try{r.error(c)}catch(e){console.error("Error in observer.error \n",e.stack)}else console.error("Unhandled error",c,c.stack),ue()||console.info("An unhandled error was thrown because no error handler is registered for the query "+i.queryString)}else try{var l=he({store:o.getDataWithOptimisticResults(),query:o.queryDocuments[e],variables:i.previousVariables||i.variables,returnPartialData:!0,config:o.reducerConfig,previousResult:n&&n.data}),f=l.result,h=l.isMissing,d=void 0;if(d=!h||t.returnPartialData||a?{data:f,loading:we(i.networkStatus),networkStatus:i.networkStatus,stale:!1}:{data:n&&n.data,loading:we(i.networkStatus),networkStatus:i.networkStatus,stale:!0},r.next){var p=o.resultComparator?!o.resultComparator(n,d):!(n&&d&&n.networkStatus===d.networkStatus&&n.stale===d.stale&&n.data===d.data);if(p){n=d;try{r.next(je(o.transformResult(d)))}catch(e){console.error("Error in observer.next \n",e.stack)}}}}catch(e){return void(r.error&&r.error(new ft({networkError:e})))}}}},t.prototype.watchQuery=function(e,t){void 0===t&&(t=!0),Q(e.query);var r=gt({},e);return this.addTypename&&(r.query=Fe(r.query)),new pt({scheduler:this.scheduler,options:r,shouldSubscribe:t})},t.prototype.query=function(e){var t=this;if(e.returnPartialData)throw new Error("returnPartialData option only supported on watchQuery.");if("Document"!==e.query.kind)throw new Error('You must wrap the query string in a "gql" tag.');var r=this.idCounter,n=new Promise(function(o,i){return t.addFetchQueryPromise(r,n,o,i),t.watchQuery(e,!1).result().then(function(e){t.removeFetchQueryPromise(r),o(e)}).catch(function(e){t.removeFetchQueryPromise(r),i(e)})});return n},t.prototype.fetchQuery=function(e,t,n,o){var i,a=t.variables,s=void 0===a?{}:a,u=t.forceFetch,c=void 0!==u&&u,l=t.returnPartialData,f=void 0!==l&&l,h=t.noFetch,d=void 0!==h&&h,p=t.metadata,y=void 0===p?null:p,v=this.transformQueryDocument(t).queryDoc,m=r.print(v),b=c;if(n!==nt.refetch&&!c){var g=he({query:v,store:this.reduxRootSelector(this.store.getState()).data,returnPartialData:!0,variables:s,config:this.reducerConfig}),w=g.isMissing,q=g.result;b=w||!1,i=q}var O=this.generateRequestId(),I=b&&!d;return this.queryDocuments[e]=v,this.store.dispatch({type:"APOLLO_QUERY_INIT",queryString:m,document:v,variables:s,forceFetch:c,returnPartialData:f||d,queryId:e,requestId:O,storePreviousVariables:I,isPoll:n===nt.poll,isRefetch:n===nt.refetch,fetchMoreForQueryId:o,metadata:y}),I&&!f||this.store.dispatch({type:"APOLLO_QUERY_RESULT_CLIENT",result:{data:i},variables:s,document:v,complete:!I,queryId:e,requestId:O}),I?this.fetchRequest({requestId:O,queryId:e,document:v,options:t,fetchMoreForQueryId:o}):Promise.resolve({data:i})},t.prototype.generateQueryId=function(){var e=this.idCounter.toString();return this.idCounter++,e},t.prototype.stopQueryInStore=function(e){this.store.dispatch({type:"APOLLO_QUERY_STOP",queryId:e})},t.prototype.getApolloState=function(){return this.reduxRootSelector(this.store.getState())},t.prototype.selectApolloState=function(e){return this.reduxRootSelector(e.getState())},t.prototype.getInitialState=function(){return{data:this.getApolloState().data}},t.prototype.getDataWithOptimisticResults=function(){return te(this.getApolloState())},t.prototype.addQueryListener=function(e,t){this.queryListeners[e]=this.queryListeners[e]||[],this.queryListeners[e].push(t)},t.prototype.addFetchQueryPromise=function(e,t,r,n){this.fetchQueryPromises[e.toString()]={promise:t,resolve:r,reject:n}},t.prototype.removeFetchQueryPromise=function(e){delete this.fetchQueryPromises[e.toString()]},t.prototype.addObservableQuery=function(e,t){this.observableQueries[e]={observableQuery:t};var r=Q(t.options.query);if(r.name&&r.name.value){var n=r.name.value;this.queryIdsByName[n]=this.queryIdsByName[n]||[],this.queryIdsByName[n].push(t.queryId)}},t.prototype.removeObservableQuery=function(e){var t=this.observableQueries[e].observableQuery,r=Q(t.options.query),n=r.name?r.name.value:null;delete this.observableQueries[e],n&&(this.queryIdsByName[n]=this.queryIdsByName[n].filter(function(e){return!(t.queryId===e)}))},t.prototype.resetStore=function(){var e=this;Object.keys(this.fetchQueryPromises).forEach(function(t){(0,e.fetchQueryPromises[t].reject)(new Error("Store reset while query was in flight."))}),this.store.dispatch({type:"APOLLO_STORE_RESET",observableQueryIds:Object.keys(this.observableQueries)}),Object.keys(this.observableQueries).forEach(function(t){e.reduxRootSelector(e.store.getState()).queries[t];e.observableQueries[t].observableQuery.options.noFetch||e.observableQueries[t].observableQuery.refetch()})},t.prototype.startQuery=function(e,t,r){return this.addQueryListener(e,r),this.fetchQuery(e,t).catch(function(e){}),e},t.prototype.startGraphQLSubscription=function(e){var t=this,r=e.document,n=e.variables,o=r;this.addTypename&&(o=Fe(o));var i,a={query:o,variables:n,operationName:I(o)},s=[];return new ut(function(e){if(s.push(e),1===s.length){var r=function(e,r){e?s.forEach(function(t){t.error&&t.error(e)}):(t.store.dispatch({type:"APOLLO_SUBSCRIPTION_RESULT",document:o,operationName:I(o),result:{data:r},variables:n||{},subscriptionId:i,extraReducers:t.getExtraReducers()}),s.forEach(function(e){e.next&&e.next(r)}))};i=t.networkInterface.subscribe(a,r)}return{unsubscribe:function(){s=s.filter(function(t){return t!==e}),0===s.length&&t.networkInterface.unsubscribe(i)},_networkSubscriptionId:i}})},t.prototype.stopQuery=function(e){delete this.queryListeners[e],delete this.queryDocuments[e],this.stopQueryInStore(e)},t.prototype.getCurrentQueryResult=function(e,t){void 0===t&&(t=!1);var r=this.getQueryParts(e),n=r.variables,o=r.document,i=e.getLastResult(),a=e.options,s={store:t?this.getDataWithOptimisticResults():this.getApolloState().data,query:o,variables:n,returnPartialData:!1,config:this.reducerConfig,previousResult:i?i.data:void 0};try{var u=fe(s);return je({data:u,partial:!1})}catch(e){if(a.returnPartialData||a.noFetch)try{s.returnPartialData=!0;var u=fe(s);return{data:u,partial:!0}}catch(e){}return je({data:{},partial:!0})}},t.prototype.getQueryWithPreviousResult=function(e,t){void 0===t&&(t=!1);var r;if("string"==typeof e){if(!this.observableQueries[e])throw new Error("ObservableQuery with this id doesn't exist: "+e);r=this.observableQueries[e].observableQuery}else r=e;var n=this.getQueryParts(r),o=n.variables,i=n.document;return{previousResult:this.getCurrentQueryResult(r,t).data,variables:o,document:i}},t.prototype.transformResult=function(e){return this.resultTransformer?this.resultTransformer(e):e},t.prototype.getQueryParts=function(e){var t=e.options,r=e.options.query;return this.addTypename&&(r=Fe(r)),{variables:t.variables,document:r}},t.prototype.transformQueryDocument=function(e){var t=e.query;return this.addTypename&&(t=Fe(t)),{queryDoc:t}},t.prototype.getExtraReducers=function(){var e=this;return Object.keys(this.observableQueries).map(function(t){var r=e.observableQueries[t].observableQuery,n=r.options;return n.reducer?_e(n.reducer,n.query,r.variables||{},e.reducerConfig):null}).filter(function(e){return null!==e})},t.prototype.fetchRequest=function(t){var r=this,n=t.requestId,o=t.queryId,i=t.document,a=t.options,s=t.fetchMoreForQueryId,u=a.variables,c=a.noFetch,l=a.returnPartialData,f={query:i,variables:u,operationName:I(i)},h=new Promise(function(t,a){r.addFetchQueryPromise(n,h,t,a),r.deduplicator.query(f,r.queryDeduplication).then(function(e){var t=r.getExtraReducers();if(r.store.dispatch({type:"APOLLO_QUERY_RESULT",document:i,operationName:I(i),result:e,queryId:o,requestId:n,fetchMoreForQueryId:s,extraReducers:t}),r.removeFetchQueryPromise(n),e.errors)throw new ft({graphQLErrors:e.errors});return e}).then(function(){var o;try{o=fe({store:r.getApolloState().data,variables:u,returnPartialData:l||c,query:i,config:r.reducerConfig})}catch(e){}var a=r.getApolloState().reducerError;return!o&&a?Promise.reject(a):(r.removeFetchQueryPromise(n),t({data:o,loading:!1,networkStatus:e.NetworkStatus.ready,stale:!1}),null)}).catch(function(e){Re(e)?a(e):(r.store.dispatch({type:"APOLLO_QUERY_ERROR",error:e,queryId:o,requestId:n,fetchMoreForQueryId:s}),r.removeFetchQueryPromise(n),a(new ft({networkError:e})))})});return h},t.prototype.refetchQueryByName=function(e){var t=this,r=this.queryIdsByName[e];void 0===r?console.warn("Warning: unknown query with name "+e+" asked to refetch"):r.forEach(function(e){t.observableQueries[e].observableQuery.refetch()})},t.prototype.broadcastQueries=function(){var e=this,t=this.getApolloState().queries;Object.keys(this.queryListeners).forEach(function(r){var n=e.queryListeners[r];n&&n.forEach(function(e){if(e){e(t[r])}})})},t.prototype.generateRequestId=function(){var e=this.idCounter;return this.idCounter++,e},t}(),qt="local",Ot=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++){t=arguments[r];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])}return e},It="apollo",St=function(){function e(e){void 0===e&&(e={});var t=this;this.middleware=function(){return function(e){return t.setStore(e),function(r){return function(n){var o=t.queryManager.selectApolloState(e),i=r(n);return t.queryManager.selectApolloState(e)!==o&&t.queryManager.broadcastNewStore(e.getState()),t.devToolsHookCb&&t.devToolsHookCb({action:n,state:t.queryManager.getApolloState(),dataWithOptimisticResults:t.queryManager.getDataWithOptimisticResults()}),i}}}};var r=e.networkInterface,n=e.reduxRootKey,o=e.reduxRootSelector,i=e.initialState,a=e.dataIdFromObject,u=e.resultComparator,c=e.ssrMode,l=void 0!==c&&c,f=e.ssrForceFetchDelay,h=void 0===f?0:f,d=e.addTypename,p=void 0===d||d,y=e.resultTransformer,v=e.customResolvers,m=e.connectToDevTools,b=e.queryDeduplication,g=void 0!==b&&b;if(n&&o)throw new Error('Both "reduxRootKey" and "reduxRootSelector" are configured, but only one of two is allowed.');n&&(console.warn('"reduxRootKey" option is deprecated and might be removed in the upcoming versions, please use the "reduxRootSelector" instead.'),this.reduxRootKey=n),!o&&n?this.reduxRootSelector=function(e){return e[n]}:"string"==typeof o?(this.reduxRootKey=o,this.reduxRootSelector=function(e){return e[o]}):this.reduxRootSelector="function"==typeof o?o:null,this.initialState=i?i:{},this.networkInterface=r?r:s({uri:"/graphql"}),this.addTypename=p,y&&console.warn('"resultTransformer" is being considered for deprecation in an upcoming version. If you are using it, please file an issue on apollostack/apollo-client with a description of your use-case'),this.resultTransformer=y,this.resultComparator=u,this.shouldForceFetch=!(l||h>0),this.dataId=a,this.fieldWithArgs=D,this.queryDeduplication=g,h&&setTimeout(function(){return t.shouldForceFetch=!0},h),this.reducerConfig={dataIdFromObject:a,customResolvers:v},this.watchQuery=this.watchQuery.bind(this),this.query=this.query.bind(this),this.mutate=this.mutate.bind(this),this.setStore=this.setStore.bind(this),this.resetStore=this.resetStore.bind(this);var w=!ue()&&"undefined"!=typeof window&&!window.__APOLLO_CLIENT__;(void 0===m?w:m)&&(window.__APOLLO_CLIENT__=this),this.version=qt}return e.prototype.watchQuery=function(e){return this.initStore(),!this.shouldForceFetch&&e.forceFetch&&(e=Ot({},e,{forceFetch:!1})),this.queryManager.watchQuery(e)},e.prototype.query=function(e){return this.initStore(),!this.shouldForceFetch&&e.forceFetch&&(e=Ot({},e,{forceFetch:!1})),this.queryManager.query(e)},e.prototype.mutate=function(e){return this.initStore(),this.queryManager.mutate(e)},e.prototype.subscribe=function(e){this.initStore();var t=Ot({},e,{document:e.query});return delete t.query,this.queryManager.startGraphQLSubscription(t)},e.prototype.readQuery=function(e){return this.initProxy().readQuery(e)},e.prototype.readFragment=function(e){return this.initProxy().readFragment(e)},e.prototype.writeQuery=function(e){return this.initProxy().writeQuery(e)},e.prototype.writeFragment=function(e){return this.initProxy().writeFragment(e)},e.prototype.reducer=function(){return Se(this.reducerConfig)},e.prototype.__actionHookForDevTools=function(e){this.devToolsHookCb=e},e.prototype.initStore=function(){var e=this;if(!this.store){if(this.reduxRootSelector)throw new Error('Cannot initialize the store because "reduxRootSelector" or "reduxRootKey" is provided. They should only be used when the store is created outside of the client. This may lead to unexpected results when querying the store internally. Please remove that option from ApolloClient constructor.');this.setStore(Qe({reduxRootKey:It,initialState:this.initialState,config:this.reducerConfig,logger:function(t){return function(t){return function(r){var n=t(r);return e.devToolsHookCb&&e.devToolsHookCb({action:r,state:e.queryManager.getApolloState(),dataWithOptimisticResults:e.queryManager.getDataWithOptimisticResults()}),n}}}})),this.reduxRootKey=It}},e.prototype.resetStore=function(){this.queryManager&&this.queryManager.resetStore()},e.prototype.getInitialState=function(){return this.initStore(),this.queryManager.getInitialState()},e.prototype.setStore=function(e){var t;if(this.reduxRootSelector?t=this.reduxRootSelector:(t=Le,this.reduxRootKey=It),void 0===t(e.getState()))throw new Error('Existing store does not use apolloReducer. Please make sure the store is properly configured and "reduxRootSelector" is correctly specified.');this.store=e,this.queryManager=new wt({networkInterface:this.networkInterface,reduxRootSelector:t,store:e,addTypename:this.addTypename,resultTransformer:this.resultTransformer,resultComparator:this.resultComparator,reducerConfig:this.reducerConfig,queryDeduplication:this.queryDeduplication})},e.prototype.initProxy=function(){return this.proxy||(this.initStore(),this.proxy=new Ze(this.store,this.reduxRootSelector||Le)),this.proxy},e}();e.createNetworkInterface=s,e.createBatchingNetworkInterface=c,e.createApolloStore=Qe,e.createApolloReducer=Se,e.readQueryFromStore=fe,e.writeQueryToStore=G,e.printAST=r.print,e.addTypenameToDocument=Fe,e.createFragmentMap=R,e.ApolloError=ft,e.getQueryDefinition=Q,e.getFragmentDefinitions=S,e.toIdValue=W,e.HTTPFetchNetworkInterface=Ne,e.ObservableQuery=pt,e.ApolloClient=St,e.default=St,Object.defineProperty(e,"__esModule",{value:!0})})},367);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement