react-apollo
Advanced tools
Comparing version 2.1.9 to 2.2.0-alpha.0
@@ -134,3 +134,3 @@ import * as React from 'react'; | ||
} | ||
export default function getDataFromTree(rootElement, rootContext) { | ||
function getDataAndErrorsFromTree(rootElement, rootContext, storeError) { | ||
if (rootContext === void 0) { rootContext = {}; } | ||
@@ -141,19 +141,30 @@ var promises = getPromisesFromTree({ rootElement: rootElement, rootContext: rootContext }); | ||
} | ||
var errors = []; | ||
var mappedPromises = promises.map(function (_a) { | ||
var promise = _a.promise, context = _a.context, instance = _a.instance; | ||
return promise | ||
.then(function (_) { return getDataFromTree(instance.render(), context); }) | ||
.catch(function (e) { return errors.push(e); }); | ||
.then(function (_) { return getDataAndErrorsFromTree(instance.render(), context, storeError); }) | ||
.catch(function (e) { return storeError(e); }); | ||
}); | ||
return Promise.all(mappedPromises).then(function (_) { | ||
if (errors.length > 0) { | ||
var error = errors.length === 1 | ||
? errors[0] | ||
: new Error(errors.length + " errors were thrown when executing your fetchData functions."); | ||
error.queryErrors = errors; | ||
throw error; | ||
} | ||
return Promise.all(mappedPromises); | ||
} | ||
function processErrors(errors) { | ||
switch (errors.length) { | ||
case 0: | ||
break; | ||
case 1: | ||
throw errors.pop(); | ||
default: | ||
var wrapperError = new Error(errors.length + " errors were thrown when executing your fetchData functions."); | ||
wrapperError.queryErrors = errors; | ||
throw wrapperError; | ||
} | ||
} | ||
export default function getDataFromTree(rootElement, rootContext) { | ||
if (rootContext === void 0) { rootContext = {}; } | ||
var errors = []; | ||
var storeError = function (error) { return errors.push(error); }; | ||
return getDataAndErrorsFromTree(rootElement, rootContext, storeError).then(function (_) { | ||
return processErrors(errors); | ||
}); | ||
} | ||
//# sourceMappingURL=getDataFromTree.js.map |
@@ -36,3 +36,3 @@ import * as React from 'react'; | ||
optimisticResponse?: Object; | ||
refetchQueries?: string[] | PureQueryOptions[] | RefetchQueriesProviderFn; | ||
refetchQueries?: Array<string | PureQueryOptions> | RefetchQueriesProviderFn; | ||
update?: MutationUpdaterFn<TData>; | ||
@@ -46,3 +46,3 @@ }; | ||
variables?: TVariables; | ||
refetchQueries?: string[] | PureQueryOptions[] | RefetchQueriesProviderFn; | ||
refetchQueries?: Array<string | PureQueryOptions> | RefetchQueriesProviderFn; | ||
update?: MutationUpdaterFn<TData>; | ||
@@ -86,4 +86,4 @@ children: (mutateFn: MutationFn<TData, TVariables>, result: MutationResult<TData>) => React.ReactNode; | ||
private mutate; | ||
private onStartMutation; | ||
private onCompletedMutation; | ||
private onMutationStart; | ||
private onMutationCompleted; | ||
private onMutationError; | ||
@@ -90,0 +90,0 @@ private generateNewMutationId; |
@@ -37,7 +37,7 @@ var __extends = (this && this.__extends) || (function () { | ||
if (options === void 0) { options = {}; } | ||
_this.onStartMutation(); | ||
_this.onMutationStart(); | ||
var mutationId = _this.generateNewMutationId(); | ||
return _this.mutate(options) | ||
.then(function (response) { | ||
_this.onCompletedMutation(response, mutationId); | ||
_this.onMutationCompleted(response, mutationId); | ||
return response; | ||
@@ -69,3 +69,3 @@ }) | ||
}; | ||
_this.onStartMutation = function () { | ||
_this.onMutationStart = function () { | ||
if (!_this.state.loading && !_this.props.ignoreResults) { | ||
@@ -80,3 +80,3 @@ _this.setState({ | ||
}; | ||
_this.onCompletedMutation = function (response, mutationId) { | ||
_this.onMutationCompleted = function (response, mutationId) { | ||
if (_this.hasMounted === false) { | ||
@@ -169,4 +169,3 @@ return; | ||
refetchQueries: PropTypes.oneOfType([ | ||
PropTypes.arrayOf(PropTypes.string), | ||
PropTypes.arrayOf(PropTypes.object), | ||
PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.string, PropTypes.object])), | ||
PropTypes.func, | ||
@@ -173,0 +172,0 @@ ]), |
{ | ||
"name": "react-apollo", | ||
"version": "2.1.9", | ||
"version": "2.2.0-alpha.0", | ||
"author": "opensource@apollographql.com", | ||
@@ -21,3 +21,3 @@ "browser": "react-apollo.browser.umd.js", | ||
"peerDependencies": { | ||
"apollo-client": "^2.2.3", | ||
"apollo-client": "2.4.0-alpha.1", | ||
"react": "0.14.x || 15.* || ^15.0.0 || ^16.0.0" | ||
@@ -24,0 +24,0 @@ }, |
@@ -31,2 +31,3 @@ import * as React from 'react'; | ||
networkStatus: NetworkStatus; | ||
loadingState?: Record<string, any>; | ||
} | ||
@@ -33,0 +34,0 @@ export interface QueryProps<TData = any, TVariables = OperationVariables> { |
14
Query.js
@@ -63,9 +63,11 @@ var __extends = (this && this.__extends) || (function () { | ||
return; | ||
var current = _this.getQueryResult(); | ||
var initial = _this.getQueryResult(); | ||
_this.querySubscription = _this.queryObservable.subscribe({ | ||
next: function () { | ||
if (current && current.networkStatus === 7) { | ||
current = undefined; | ||
next: function (_a) { | ||
var data = _a.data; | ||
if (initial && initial.networkStatus === 7 && shallowEqual(initial.data, data)) { | ||
initial = undefined; | ||
return; | ||
} | ||
initial = undefined; | ||
_this.updateCurrentData(); | ||
@@ -106,3 +108,3 @@ }, | ||
var currentResult = _this.queryObservable.currentResult(); | ||
var loading = currentResult.loading, networkStatus = currentResult.networkStatus, errors = currentResult.errors; | ||
var loading = currentResult.loading, networkStatus = currentResult.networkStatus, errors = currentResult.errors, loadingState = currentResult.loadingState; | ||
var error = currentResult.error; | ||
@@ -112,3 +114,3 @@ if (errors && errors.length > 0) { | ||
} | ||
Object.assign(data, { loading: loading, networkStatus: networkStatus, error: error }); | ||
Object.assign(data, { loading: loading, networkStatus: networkStatus, error: error, loadingState: loadingState }); | ||
if (loading) { | ||
@@ -115,0 +117,0 @@ Object.assign(data.data, _this.previousData, currentResult.data); |
@@ -139,3 +139,3 @@ (function (global, factory) { | ||
} | ||
function getDataFromTree(rootElement, rootContext) { | ||
function getDataAndErrorsFromTree(rootElement, rootContext, storeError) { | ||
if (rootContext === void 0) { rootContext = {}; } | ||
@@ -146,17 +146,28 @@ var promises = getPromisesFromTree({ rootElement: rootElement, rootContext: rootContext }); | ||
} | ||
var errors = []; | ||
var mappedPromises = promises.map(function (_a) { | ||
var promise = _a.promise, context = _a.context, instance = _a.instance; | ||
return promise | ||
.then(function (_) { return getDataFromTree(instance.render(), context); }) | ||
.catch(function (e) { return errors.push(e); }); | ||
.then(function (_) { return getDataAndErrorsFromTree(instance.render(), context, storeError); }) | ||
.catch(function (e) { return storeError(e); }); | ||
}); | ||
return Promise.all(mappedPromises).then(function (_) { | ||
if (errors.length > 0) { | ||
var error = errors.length === 1 | ||
? errors[0] | ||
: new Error(errors.length + " errors were thrown when executing your fetchData functions."); | ||
error.queryErrors = errors; | ||
throw error; | ||
} | ||
return Promise.all(mappedPromises); | ||
} | ||
function processErrors(errors) { | ||
switch (errors.length) { | ||
case 0: | ||
break; | ||
case 1: | ||
throw errors.pop(); | ||
default: | ||
var wrapperError = new Error(errors.length + " errors were thrown when executing your fetchData functions."); | ||
wrapperError.queryErrors = errors; | ||
throw wrapperError; | ||
} | ||
} | ||
function getDataFromTree(rootElement, rootContext) { | ||
if (rootContext === void 0) { rootContext = {}; } | ||
var errors = []; | ||
var storeError = function (error) { return errors.push(error); }; | ||
return getDataAndErrorsFromTree(rootElement, rootContext, storeError).then(function (_) { | ||
return processErrors(errors); | ||
}); | ||
@@ -324,9 +335,11 @@ } | ||
return; | ||
var current = _this.getQueryResult(); | ||
var initial = _this.getQueryResult(); | ||
_this.querySubscription = _this.queryObservable.subscribe({ | ||
next: function () { | ||
if (current && current.networkStatus === 7) { | ||
current = undefined; | ||
next: function (_a) { | ||
var data = _a.data; | ||
if (initial && initial.networkStatus === 7 && shallowEqual(initial.data, data)) { | ||
initial = undefined; | ||
return; | ||
} | ||
initial = undefined; | ||
_this.updateCurrentData(); | ||
@@ -367,3 +380,3 @@ }, | ||
var currentResult = _this.queryObservable.currentResult(); | ||
var loading = currentResult.loading, networkStatus = currentResult.networkStatus, errors = currentResult.errors; | ||
var loading = currentResult.loading, networkStatus = currentResult.networkStatus, errors = currentResult.errors, loadingState = currentResult.loadingState; | ||
var error = currentResult.error; | ||
@@ -373,3 +386,3 @@ if (errors && errors.length > 0) { | ||
} | ||
Object.assign(data, { loading: loading, networkStatus: networkStatus, error: error }); | ||
Object.assign(data, { loading: loading, networkStatus: networkStatus, error: error, loadingState: loadingState }); | ||
if (loading) { | ||
@@ -563,7 +576,7 @@ Object.assign(data.data, _this.previousData, currentResult.data); | ||
if (options === void 0) { options = {}; } | ||
_this.onStartMutation(); | ||
_this.onMutationStart(); | ||
var mutationId = _this.generateNewMutationId(); | ||
return _this.mutate(options) | ||
.then(function (response) { | ||
_this.onCompletedMutation(response, mutationId); | ||
_this.onMutationCompleted(response, mutationId); | ||
return response; | ||
@@ -595,3 +608,3 @@ }) | ||
}; | ||
_this.onStartMutation = function () { | ||
_this.onMutationStart = function () { | ||
if (!_this.state.loading && !_this.props.ignoreResults) { | ||
@@ -606,3 +619,3 @@ _this.setState({ | ||
}; | ||
_this.onCompletedMutation = function (response, mutationId) { | ||
_this.onMutationCompleted = function (response, mutationId) { | ||
if (_this.hasMounted === false) { | ||
@@ -695,4 +708,3 @@ return; | ||
refetchQueries: PropTypes.oneOfType([ | ||
PropTypes.arrayOf(PropTypes.string), | ||
PropTypes.arrayOf(PropTypes.object), | ||
PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.string, PropTypes.object])), | ||
PropTypes.func, | ||
@@ -699,0 +711,0 @@ ]), |
@@ -139,3 +139,3 @@ (function (global, factory) { | ||
} | ||
function getDataFromTree(rootElement, rootContext) { | ||
function getDataAndErrorsFromTree(rootElement, rootContext, storeError) { | ||
if (rootContext === void 0) { rootContext = {}; } | ||
@@ -146,17 +146,28 @@ var promises = getPromisesFromTree({ rootElement: rootElement, rootContext: rootContext }); | ||
} | ||
var errors = []; | ||
var mappedPromises = promises.map(function (_a) { | ||
var promise = _a.promise, context = _a.context, instance = _a.instance; | ||
return promise | ||
.then(function (_) { return getDataFromTree(instance.render(), context); }) | ||
.catch(function (e) { return errors.push(e); }); | ||
.then(function (_) { return getDataAndErrorsFromTree(instance.render(), context, storeError); }) | ||
.catch(function (e) { return storeError(e); }); | ||
}); | ||
return Promise.all(mappedPromises).then(function (_) { | ||
if (errors.length > 0) { | ||
var error = errors.length === 1 | ||
? errors[0] | ||
: new Error(errors.length + " errors were thrown when executing your fetchData functions."); | ||
error.queryErrors = errors; | ||
throw error; | ||
} | ||
return Promise.all(mappedPromises); | ||
} | ||
function processErrors(errors) { | ||
switch (errors.length) { | ||
case 0: | ||
break; | ||
case 1: | ||
throw errors.pop(); | ||
default: | ||
var wrapperError = new Error(errors.length + " errors were thrown when executing your fetchData functions."); | ||
wrapperError.queryErrors = errors; | ||
throw wrapperError; | ||
} | ||
} | ||
function getDataFromTree(rootElement, rootContext) { | ||
if (rootContext === void 0) { rootContext = {}; } | ||
var errors = []; | ||
var storeError = function (error) { return errors.push(error); }; | ||
return getDataAndErrorsFromTree(rootElement, rootContext, storeError).then(function (_) { | ||
return processErrors(errors); | ||
}); | ||
@@ -324,9 +335,11 @@ } | ||
return; | ||
var current = _this.getQueryResult(); | ||
var initial = _this.getQueryResult(); | ||
_this.querySubscription = _this.queryObservable.subscribe({ | ||
next: function () { | ||
if (current && current.networkStatus === 7) { | ||
current = undefined; | ||
next: function (_a) { | ||
var data = _a.data; | ||
if (initial && initial.networkStatus === 7 && shallowEqual(initial.data, data)) { | ||
initial = undefined; | ||
return; | ||
} | ||
initial = undefined; | ||
_this.updateCurrentData(); | ||
@@ -367,3 +380,3 @@ }, | ||
var currentResult = _this.queryObservable.currentResult(); | ||
var loading = currentResult.loading, networkStatus = currentResult.networkStatus, errors = currentResult.errors; | ||
var loading = currentResult.loading, networkStatus = currentResult.networkStatus, errors = currentResult.errors, loadingState = currentResult.loadingState; | ||
var error = currentResult.error; | ||
@@ -373,3 +386,3 @@ if (errors && errors.length > 0) { | ||
} | ||
Object.assign(data, { loading: loading, networkStatus: networkStatus, error: error }); | ||
Object.assign(data, { loading: loading, networkStatus: networkStatus, error: error, loadingState: loadingState }); | ||
if (loading) { | ||
@@ -563,7 +576,7 @@ Object.assign(data.data, _this.previousData, currentResult.data); | ||
if (options === void 0) { options = {}; } | ||
_this.onStartMutation(); | ||
_this.onMutationStart(); | ||
var mutationId = _this.generateNewMutationId(); | ||
return _this.mutate(options) | ||
.then(function (response) { | ||
_this.onCompletedMutation(response, mutationId); | ||
_this.onMutationCompleted(response, mutationId); | ||
return response; | ||
@@ -595,3 +608,3 @@ }) | ||
}; | ||
_this.onStartMutation = function () { | ||
_this.onMutationStart = function () { | ||
if (!_this.state.loading && !_this.props.ignoreResults) { | ||
@@ -606,3 +619,3 @@ _this.setState({ | ||
}; | ||
_this.onCompletedMutation = function (response, mutationId) { | ||
_this.onMutationCompleted = function (response, mutationId) { | ||
if (_this.hasMounted === false) { | ||
@@ -695,4 +708,3 @@ return; | ||
refetchQueries: PropTypes.oneOfType([ | ||
PropTypes.arrayOf(PropTypes.string), | ||
PropTypes.arrayOf(PropTypes.object), | ||
PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.string, PropTypes.object])), | ||
PropTypes.func, | ||
@@ -699,0 +711,0 @@ ]), |
@@ -74,3 +74,3 @@ # [React Apollo](http://dev.apollodata.com/react/) [![npm version](https://badge.fury.io/js/react-apollo.svg)](https://badge.fury.io/js/react-apollo) [![Get on Slack](https://img.shields.io/badge/slack-join-orange.svg)](http://www.apollostack.com/#slack) | ||
> Migrating from 1.x? See the [2.0 migration guide](https://www.apollographql.com/docs/react/2.0-migration.html). | ||
> Migrating from 1.x? See the [2.0 migration guide](https://www.apollographql.com/docs/react/recipes/2.0-migration.html). | ||
@@ -77,0 +77,0 @@ Next you will want to add a [`<ApolloProvider/>`][] component to the root of your React component tree. This component [provides](https://reactjs.org/docs/context.html) the React Apollo functionality to all the other components in the application without passing it explicitly. To use an [`<ApolloProvider/>`][] with your newly constructed client see the following: |
@@ -14,2 +14,3 @@ var __extends = (this && this.__extends) || (function () { | ||
import { addTypenameToDocument } from 'apollo-utilities'; | ||
import { isEqual } from 'lodash'; | ||
var MockLink = (function (_super) { | ||
@@ -40,11 +41,20 @@ __extends(MockLink, _super); | ||
var key = requestToKey(operation, this.addTypename); | ||
var responses = this.mockedResponsesByKey[key]; | ||
if (!responses || responses.length === 0) { | ||
var responseIndex; | ||
var response = (this.mockedResponsesByKey[key] || []).find(function (res, index) { | ||
var requestVariables = operation.variables || {}; | ||
var mockedResponseVariables = res.request.variables || {}; | ||
if (!isEqual(requestVariables, mockedResponseVariables)) { | ||
return false; | ||
} | ||
responseIndex = index; | ||
return true; | ||
}); | ||
if (!response || typeof responseIndex === 'undefined') { | ||
throw new Error("No more mocked responses for the query: " + print(operation.query) + ", variables: " + JSON.stringify(operation.variables)); | ||
} | ||
var original = this.mockedResponsesByKey[key].slice(); | ||
var _a = this.mockedResponsesByKey[key].shift() || {}, result = _a.result, error = _a.error, delay = _a.delay, newData = _a.newData; | ||
this.mockedResponsesByKey[key].splice(responseIndex, 1); | ||
var result = response.result, error = response.error, delay = response.delay, newData = response.newData; | ||
if (newData) { | ||
original[0].result = newData(); | ||
this.mockedResponsesByKey[key].push(original[0]); | ||
response.result = newData(); | ||
this.mockedResponsesByKey[key].push(response); | ||
} | ||
@@ -114,6 +124,3 @@ if (!result && !error) { | ||
var queryString = request.query && print(addTypename ? addTypenameToDocument(request.query) : request.query); | ||
var requestKey = { | ||
variables: request.variables || {}, | ||
query: queryString, | ||
}; | ||
var requestKey = { query: queryString }; | ||
return JSON.stringify(requestKey); | ||
@@ -120,0 +127,0 @@ } |
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('prop-types'), require('apollo-client'), require('react-dom/server'), require('apollo-link'), require('graphql/language/printer'), require('apollo-utilities'), require('apollo-cache-inmemory')) : | ||
typeof define === 'function' && define.amd ? define(['exports', 'react', 'prop-types', 'apollo-client', 'react-dom/server', 'apollo-link', 'graphql/language/printer', 'apollo-utilities', 'apollo-cache-inmemory'], factory) : | ||
(factory((global['react-apollo'] = {}),global.React,global.PropTypes,global.ApolloClient,global.ReactDOM,global.apolloLink,global.printer,global.apolloUtilities,global.apolloCacheInmemory)); | ||
}(this, (function (exports,React,PropTypes,ApolloClient,ReactDOM,apolloLink,printer,apolloUtilities,apolloCacheInmemory) { 'use strict'; | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('prop-types'), require('apollo-client'), require('react-dom/server'), require('apollo-link'), require('graphql/language/printer'), require('apollo-utilities'), require('lodash'), require('apollo-cache-inmemory')) : | ||
typeof define === 'function' && define.amd ? define(['exports', 'react', 'prop-types', 'apollo-client', 'react-dom/server', 'apollo-link', 'graphql/language/printer', 'apollo-utilities', 'lodash', 'apollo-cache-inmemory'], factory) : | ||
(factory((global['react-apollo'] = {}),global.React,global.PropTypes,global.ApolloClient,global.ReactDOM,global.apolloLink,global.printer,global.apolloUtilities,global.lodash,global.apolloCacheInmemory)); | ||
}(this, (function (exports,React,PropTypes,ApolloClient,ReactDOM,apolloLink,printer,apolloUtilities,lodash,apolloCacheInmemory) { 'use strict'; | ||
@@ -168,9 +168,11 @@ var ApolloClient__default = 'default' in ApolloClient ? ApolloClient['default'] : ApolloClient; | ||
return; | ||
var current = _this.getQueryResult(); | ||
var initial = _this.getQueryResult(); | ||
_this.querySubscription = _this.queryObservable.subscribe({ | ||
next: function () { | ||
if (current && current.networkStatus === 7) { | ||
current = undefined; | ||
next: function (_a) { | ||
var data = _a.data; | ||
if (initial && initial.networkStatus === 7 && shallowEqual(initial.data, data)) { | ||
initial = undefined; | ||
return; | ||
} | ||
initial = undefined; | ||
_this.updateCurrentData(); | ||
@@ -211,3 +213,3 @@ }, | ||
var currentResult = _this.queryObservable.currentResult(); | ||
var loading = currentResult.loading, networkStatus = currentResult.networkStatus, errors = currentResult.errors; | ||
var loading = currentResult.loading, networkStatus = currentResult.networkStatus, errors = currentResult.errors, loadingState = currentResult.loadingState; | ||
var error = currentResult.error; | ||
@@ -217,3 +219,3 @@ if (errors && errors.length > 0) { | ||
} | ||
Object.assign(data, { loading: loading, networkStatus: networkStatus, error: error }); | ||
Object.assign(data, { loading: loading, networkStatus: networkStatus, error: error, loadingState: loadingState }); | ||
if (loading) { | ||
@@ -407,7 +409,7 @@ Object.assign(data.data, _this.previousData, currentResult.data); | ||
if (options === void 0) { options = {}; } | ||
_this.onStartMutation(); | ||
_this.onMutationStart(); | ||
var mutationId = _this.generateNewMutationId(); | ||
return _this.mutate(options) | ||
.then(function (response) { | ||
_this.onCompletedMutation(response, mutationId); | ||
_this.onMutationCompleted(response, mutationId); | ||
return response; | ||
@@ -439,3 +441,3 @@ }) | ||
}; | ||
_this.onStartMutation = function () { | ||
_this.onMutationStart = function () { | ||
if (!_this.state.loading && !_this.props.ignoreResults) { | ||
@@ -450,3 +452,3 @@ _this.setState({ | ||
}; | ||
_this.onCompletedMutation = function (response, mutationId) { | ||
_this.onMutationCompleted = function (response, mutationId) { | ||
if (_this.hasMounted === false) { | ||
@@ -539,4 +541,3 @@ return; | ||
refetchQueries: PropTypes.oneOfType([ | ||
PropTypes.arrayOf(PropTypes.string), | ||
PropTypes.arrayOf(PropTypes.object), | ||
PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.string, PropTypes.object])), | ||
PropTypes.func, | ||
@@ -828,11 +829,20 @@ ]), | ||
var key = requestToKey(operation, this.addTypename); | ||
var responses = this.mockedResponsesByKey[key]; | ||
if (!responses || responses.length === 0) { | ||
var responseIndex; | ||
var response = (this.mockedResponsesByKey[key] || []).find(function (res, index) { | ||
var requestVariables = operation.variables || {}; | ||
var mockedResponseVariables = res.request.variables || {}; | ||
if (!lodash.isEqual(requestVariables, mockedResponseVariables)) { | ||
return false; | ||
} | ||
responseIndex = index; | ||
return true; | ||
}); | ||
if (!response || typeof responseIndex === 'undefined') { | ||
throw new Error("No more mocked responses for the query: " + printer.print(operation.query) + ", variables: " + JSON.stringify(operation.variables)); | ||
} | ||
var original = this.mockedResponsesByKey[key].slice(); | ||
var _a = this.mockedResponsesByKey[key].shift() || {}, result = _a.result, error = _a.error, delay = _a.delay, newData = _a.newData; | ||
this.mockedResponsesByKey[key].splice(responseIndex, 1); | ||
var result = response.result, error = response.error, delay = response.delay, newData = response.newData; | ||
if (newData) { | ||
original[0].result = newData(); | ||
this.mockedResponsesByKey[key].push(original[0]); | ||
response.result = newData(); | ||
this.mockedResponsesByKey[key].push(response); | ||
} | ||
@@ -900,6 +910,3 @@ if (!result && !error) { | ||
var queryString = request.query && printer.print(addTypename ? apolloUtilities.addTypenameToDocument(request.query) : request.query); | ||
var requestKey = { | ||
variables: request.variables || {}, | ||
query: queryString, | ||
}; | ||
var requestKey = { query: queryString }; | ||
return JSON.stringify(requestKey); | ||
@@ -951,2 +958,5 @@ } | ||
MockedProvider.prototype.componentWillUnmount = function () { | ||
if (!this.state.client.queryManager) { | ||
return; | ||
} | ||
var scheduler = this.state.client.queryManager.scheduler; | ||
@@ -953,0 +963,0 @@ Object.keys(scheduler.registeredQueries).forEach(function (queryId) { |
@@ -5,7 +5,7 @@ import ApolloClient, { ApolloQueryResult, ApolloError, FetchPolicy, ErrorPolicy, FetchMoreOptions, UpdateQueryOptions, FetchMoreQueryOptions, SubscribeToMoreOptions, PureQueryOptions, MutationUpdaterFn } from 'apollo-client'; | ||
}; | ||
export declare type RefetchQueriesProviderFn = (...args: any[]) => string[] | PureQueryOptions[]; | ||
export declare type RefetchQueriesProviderFn = (...args: any[]) => Array<string | PureQueryOptions>; | ||
export interface MutationOpts<TData = any, TGraphQLVariables = OperationVariables> { | ||
variables?: TGraphQLVariables; | ||
optimisticResponse?: TData; | ||
refetchQueries?: string[] | PureQueryOptions[] | RefetchQueriesProviderFn; | ||
refetchQueries?: Array<string | PureQueryOptions> | RefetchQueriesProviderFn; | ||
errorPolicy?: ErrorPolicy; | ||
@@ -58,3 +58,3 @@ update?: MutationUpdaterFn; | ||
options?: QueryOpts<TGraphQLVariables> | MutationOpts<TData, TGraphQLVariables> | ((props: TProps) => QueryOpts<TGraphQLVariables> | MutationOpts<TData, TGraphQLVariables>); | ||
props?: (props: OptionProps<TProps, TData>, lastProps?: TChildProps | void) => TChildProps; | ||
props?: (props: OptionProps<TProps, TData, TGraphQLVariables>, lastProps?: TChildProps | void) => TChildProps; | ||
skip?: boolean | ((props: any) => boolean); | ||
@@ -61,0 +61,0 @@ name?: string; |
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
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
418340
5272
2