apollo-client
Advanced tools
Comparing version 2.5.0-beta.0 to 2.5.0-beta.1
@@ -0,0 +0,0 @@ import { ApolloLink, FetchResult, GraphQLRequest } from 'apollo-link'; |
@@ -1,8 +0,11 @@ | ||
import * as tslib_1 from "tslib"; | ||
import { ApolloLink, execute, } from 'apollo-link'; | ||
import { isProduction, removeConnectionDirectiveFromDocument, } from 'apollo-utilities'; | ||
import { QueryManager } from './core/QueryManager'; | ||
import { LocalState } from './core/LocalState'; | ||
import { DataStore } from './data/store'; | ||
import { version } from './version'; | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var tslib_1 = require("tslib"); | ||
var apollo_link_1 = require("apollo-link"); | ||
var apollo_utilities_1 = require("apollo-utilities"); | ||
var ts_invariant_1 = require("ts-invariant"); | ||
var QueryManager_1 = require("./core/QueryManager"); | ||
var LocalState_1 = require("./core/LocalState"); | ||
var store_1 = require("./data/store"); | ||
var version_1 = require("./version"); | ||
var hasSuggestedDevtools = false; | ||
@@ -19,12 +22,12 @@ var ApolloClient = (function () { | ||
if (!link && resolvers) { | ||
link = ApolloLink.empty(); | ||
link = apollo_link_1.ApolloLink.empty(); | ||
} | ||
if (!link || !cache) { | ||
throw new Error("\n In order to initialize Apollo Client, you must specify link & cache properties on the config object.\n This is part of the required upgrade when migrating from Apollo Client 1.0 to Apollo Client 2.0.\n For more information, please visit:\n https://www.apollographql.com/docs/react/basics/setup.html\n to help you get started.\n "); | ||
throw new ts_invariant_1.InvariantError("\n In order to initialize Apollo Client, you must specify link & cache properties on the config object.\n This is part of the required upgrade when migrating from Apollo Client 1.0 to Apollo Client 2.0.\n For more information, please visit:\n https://www.apollographql.com/docs/react/basics/setup.html\n to help you get started.\n "); | ||
} | ||
var supportedCache = new Map(); | ||
var supportedDirectives = new ApolloLink(function (operation, forward) { | ||
var supportedDirectives = new apollo_link_1.ApolloLink(function (operation, forward) { | ||
var result = supportedCache.get(operation.query); | ||
if (!result) { | ||
result = removeConnectionDirectiveFromDocument(operation.query); | ||
result = apollo_utilities_1.removeConnectionDirectiveFromDocument(operation.query); | ||
supportedCache.set(operation.query, result); | ||
@@ -38,3 +41,3 @@ supportedCache.set(result, result); | ||
this.cache = cache; | ||
this.store = new DataStore(cache); | ||
this.store = new store_1.DataStore(cache); | ||
this.disableNetworkFetches = ssrMode || ssrForceFetchDelay > 0; | ||
@@ -52,3 +55,3 @@ this.queryDeduplication = queryDeduplication; | ||
this.reFetchObservableQueries = this.reFetchObservableQueries.bind(this); | ||
var defaultConnectToDevTools = !isProduction() && | ||
var defaultConnectToDevTools = process.env.NODE_ENV !== 'production' && | ||
typeof window !== 'undefined' && | ||
@@ -61,3 +64,3 @@ !window.__APOLLO_CLIENT__; | ||
} | ||
if (!hasSuggestedDevtools && !isProduction()) { | ||
if (!hasSuggestedDevtools && process.env.NODE_ENV !== 'production') { | ||
hasSuggestedDevtools = true; | ||
@@ -78,3 +81,3 @@ if (typeof window !== 'undefined' && | ||
} | ||
this.version = version; | ||
this.version = version_1.version; | ||
if (clientAwarenessName) { | ||
@@ -86,3 +89,3 @@ this.clientAwareness.name = clientAwarenessName; | ||
} | ||
this.localState = new LocalState({ | ||
this.localState = new LocalState_1.LocalState({ | ||
cache: cache, | ||
@@ -115,5 +118,3 @@ client: this, | ||
} | ||
if (options.fetchPolicy === 'cache-and-network') { | ||
throw new Error('cache-and-network fetchPolicy can only be used with watchQuery'); | ||
} | ||
ts_invariant_1.invariant(options.fetchPolicy !== 'cache-and-network', 'cache-and-network fetchPolicy can only be used with watchQuery'); | ||
if (this.disableNetworkFetches && options.fetchPolicy === 'network-only') { | ||
@@ -160,3 +161,3 @@ options = tslib_1.__assign({}, options, { fetchPolicy: 'cache-first' }); | ||
ApolloClient.prototype.__requestRaw = function (payload) { | ||
return execute(this.link, payload); | ||
return apollo_link_1.execute(this.link, payload); | ||
}; | ||
@@ -166,3 +167,3 @@ ApolloClient.prototype.initQueryManager = function () { | ||
if (!this.queryManager) { | ||
this.queryManager = new QueryManager({ | ||
this.queryManager = new QueryManager_1.QueryManager({ | ||
link: this.link, | ||
@@ -264,3 +265,3 @@ store: this.store, | ||
}()); | ||
export default ApolloClient; | ||
exports.default = ApolloClient; | ||
//# sourceMappingURL=ApolloClient.js.map |
@@ -0,0 +0,0 @@ import { ExecutionResult, DocumentNode, FieldNode, ASTNode } from 'graphql'; |
@@ -1,6 +0,9 @@ | ||
import * as tslib_1 from "tslib"; | ||
import { print } from 'graphql/language/printer'; | ||
import { visit, BREAK } from 'graphql/language/visitor'; | ||
import { getMainDefinition, buildQueryFromSelectionSet, hasDirectives, removeClientSetsFromDocument, mergeDeep, mergeDeepArray, argumentsObjectFromField, resultKeyNameFromField, getFragmentDefinitions, createFragmentMap, shouldInclude, isField, isInlineFragment, } from 'apollo-utilities'; | ||
import { capitalizeFirstLetter } from '../util/capitalizeFirstLetter'; | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var tslib_1 = require("tslib"); | ||
var printer_1 = require("graphql/language/printer"); | ||
var visitor_1 = require("graphql/language/visitor"); | ||
var apollo_utilities_1 = require("apollo-utilities"); | ||
var ts_invariant_1 = require("ts-invariant"); | ||
var capitalizeFirstLetter_1 = require("../util/capitalizeFirstLetter"); | ||
var LocalState = (function () { | ||
@@ -28,7 +31,7 @@ function LocalState(_a) { | ||
resolvers.forEach(function (resolverGroup) { | ||
_this.resolvers = mergeDeep(_this.resolvers, resolverGroup); | ||
_this.resolvers = apollo_utilities_1.mergeDeep(_this.resolvers, resolverGroup); | ||
}); | ||
} | ||
else { | ||
this.resolvers = mergeDeep(this.resolvers, resolvers); | ||
this.resolvers = apollo_utilities_1.mergeDeep(this.resolvers, resolvers); | ||
} | ||
@@ -57,3 +60,3 @@ }; | ||
} | ||
return [2, this.resolveDocument(document, mergeDeepArray(toMerge), context, variables, this.fragmentMatcher, onlyRunForcedResolvers).then(function (localResult) { return (tslib_1.__assign({}, remoteResult, { data: localResult.result })); })]; | ||
return [2, this.resolveDocument(document, apollo_utilities_1.mergeDeepArray(toMerge), context, variables, this.fragmentMatcher, onlyRunForcedResolvers).then(function (localResult) { return (tslib_1.__assign({}, remoteResult, { data: localResult.result })); })]; | ||
} | ||
@@ -77,6 +80,6 @@ return [2, remoteResult]; | ||
LocalState.prototype.clientQuery = function (document) { | ||
return hasDirectives(['client'], document) ? document : null; | ||
return apollo_utilities_1.hasDirectives(['client'], document) ? document : null; | ||
}; | ||
LocalState.prototype.serverQuery = function (document) { | ||
return removeClientSetsFromDocument(document); | ||
return apollo_utilities_1.removeClientSetsFromDocument(document); | ||
}; | ||
@@ -97,3 +100,3 @@ LocalState.prototype.prepareContext = function (context) { | ||
else { | ||
throw new Error('To use context.getCacheKey, you need to use a cache that has ' + | ||
ts_invariant_1.invariant(false, 'To use context.getCacheKey, you need to use a cache that has ' + | ||
'a configurable dataIdFromObject, like apollo-cache-inmemory.'); | ||
@@ -118,3 +121,3 @@ } | ||
var forceResolvers = false; | ||
visit(document, { | ||
visitor_1.visit(document, { | ||
Directive: { | ||
@@ -129,3 +132,3 @@ enter: function (node) { | ||
if (forceResolvers) { | ||
return BREAK; | ||
return visitor_1.BREAK; | ||
} | ||
@@ -143,3 +146,3 @@ } | ||
return this.cache.diff({ | ||
query: buildQueryFromSelectionSet(document), | ||
query: apollo_utilities_1.buildQueryFromSelectionSet(document), | ||
variables: variables, | ||
@@ -152,3 +155,3 @@ optimistic: false, | ||
return defs | ||
.map(function (typeDef) { return (typeof typeDef === 'string' ? typeDef : print(typeDef)); }) | ||
.map(function (typeDef) { return (typeof typeDef === 'string' ? typeDef : printer_1.print(typeDef)); }) | ||
.map(function (str) { return str.trim(); }) | ||
@@ -165,9 +168,9 @@ .join('\n'); | ||
return tslib_1.__generator(this, function (_b) { | ||
mainDefinition = getMainDefinition(document); | ||
fragments = getFragmentDefinitions(document); | ||
fragmentMap = createFragmentMap(fragments); | ||
mainDefinition = apollo_utilities_1.getMainDefinition(document); | ||
fragments = apollo_utilities_1.getFragmentDefinitions(document); | ||
fragmentMap = apollo_utilities_1.createFragmentMap(fragments); | ||
definitionOperation = mainDefinition | ||
.operation; | ||
defaultOperationType = definitionOperation | ||
? capitalizeFirstLetter(definitionOperation) | ||
? capitalizeFirstLetter_1.capitalizeFirstLetter(definitionOperation) | ||
: 'Query'; | ||
@@ -202,6 +205,6 @@ _a = this, cache = _a.cache, client = _a.client; | ||
return tslib_1.__generator(this, function (_a) { | ||
if (!shouldInclude(selection, variables)) { | ||
if (!apollo_utilities_1.shouldInclude(selection, variables)) { | ||
return [2]; | ||
} | ||
if (isField(selection)) { | ||
if (apollo_utilities_1.isField(selection)) { | ||
return [2, this.resolveField(selection, rootValue, execContext).then(function (fieldResult) { | ||
@@ -211,3 +214,3 @@ var _a; | ||
resultsToMerge.push((_a = {}, | ||
_a[resultKeyNameFromField(selection)] = fieldResult, | ||
_a[apollo_utilities_1.resultKeyNameFromField(selection)] = fieldResult, | ||
_a)); | ||
@@ -217,3 +220,3 @@ } | ||
} | ||
if (isInlineFragment(selection)) { | ||
if (apollo_utilities_1.isInlineFragment(selection)) { | ||
fragment = selection; | ||
@@ -223,5 +226,3 @@ } | ||
fragment = fragmentMap[selection.name.value]; | ||
if (!fragment) { | ||
throw new Error("No fragment named " + selection.name.value); | ||
} | ||
ts_invariant_1.invariant(fragment, "No fragment named " + selection.name.value); | ||
} | ||
@@ -240,3 +241,3 @@ if (fragment && fragment.typeCondition) { | ||
return [2, Promise.all(selectionSet.selections.map(execute)).then(function () { | ||
return mergeDeepArray(resultsToMerge); | ||
return apollo_utilities_1.mergeDeepArray(resultsToMerge); | ||
})]; | ||
@@ -253,3 +254,3 @@ }); | ||
fieldName = field.name.value; | ||
aliasedFieldName = resultKeyNameFromField(field); | ||
aliasedFieldName = apollo_utilities_1.resultKeyNameFromField(field); | ||
aliasUsed = fieldName !== aliasedFieldName; | ||
@@ -265,3 +266,3 @@ defaultResult = rootValue[aliasedFieldName] || rootValue[fieldName]; | ||
if (resolve) { | ||
resultPromise = Promise.resolve(resolve(rootValue, argumentsObjectFromField(field, variables), execContext.context, { field: field })); | ||
resultPromise = Promise.resolve(resolve(rootValue, apollo_utilities_1.argumentsObjectFromField(field, variables), execContext.context, { field: field })); | ||
} | ||
@@ -315,3 +316,3 @@ } | ||
}()); | ||
export { LocalState }; | ||
exports.LocalState = LocalState; | ||
//# sourceMappingURL=LocalState.js.map |
@@ -0,0 +0,0 @@ export declare enum NetworkStatus { |
@@ -1,2 +0,4 @@ | ||
export var NetworkStatus; | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var NetworkStatus; | ||
(function (NetworkStatus) { | ||
@@ -10,6 +12,7 @@ NetworkStatus[NetworkStatus["loading"] = 1] = "loading"; | ||
NetworkStatus[NetworkStatus["error"] = 8] = "error"; | ||
})(NetworkStatus || (NetworkStatus = {})); | ||
export function isNetworkRequestInFlight(networkStatus) { | ||
})(NetworkStatus = exports.NetworkStatus || (exports.NetworkStatus = {})); | ||
function isNetworkRequestInFlight(networkStatus) { | ||
return networkStatus < 7; | ||
} | ||
exports.isNetworkRequestInFlight = isNetworkRequestInFlight; | ||
//# sourceMappingURL=networkStatus.js.map |
@@ -0,0 +0,0 @@ import { GraphQLError } from 'graphql'; |
@@ -1,8 +0,11 @@ | ||
import * as tslib_1 from "tslib"; | ||
import { isEqual, tryFunctionOrLogError, cloneDeep } from 'apollo-utilities'; | ||
import { NetworkStatus, isNetworkRequestInFlight } from './networkStatus'; | ||
import { Observable } from '../util/Observable'; | ||
import { ApolloError } from '../errors/ApolloError'; | ||
import { FetchType } from './types'; | ||
export var hasError = function (storeValue, policy) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var tslib_1 = require("tslib"); | ||
var apollo_utilities_1 = require("apollo-utilities"); | ||
var networkStatus_1 = require("./networkStatus"); | ||
var Observable_1 = require("../util/Observable"); | ||
var ApolloError_1 = require("../errors/ApolloError"); | ||
var types_1 = require("./types"); | ||
var ts_invariant_1 = require("ts-invariant"); | ||
exports.hasError = function (storeValue, policy) { | ||
if (policy === void 0) { policy = 'none'; } | ||
@@ -70,7 +73,7 @@ return storeValue && | ||
loading: false, | ||
networkStatus: NetworkStatus.error, | ||
networkStatus: networkStatus_1.NetworkStatus.error, | ||
}; | ||
} | ||
var queryStoreValue = this.queryManager.queryStore.get(this.queryId); | ||
if (hasError(queryStoreValue, this.options.errorPolicy)) { | ||
if (exports.hasError(queryStoreValue, this.options.errorPolicy)) { | ||
return { | ||
@@ -80,3 +83,3 @@ data: undefined, | ||
networkStatus: queryStoreValue.networkStatus, | ||
error: new ApolloError({ | ||
error: new ApolloError_1.ApolloError({ | ||
graphQLErrors: queryStoreValue.graphQLErrors, | ||
@@ -92,3 +95,3 @@ networkError: queryStoreValue.networkError, | ||
var queryLoading = !queryStoreValue || | ||
queryStoreValue.networkStatus === NetworkStatus.loading; | ||
queryStoreValue.networkStatus === networkStatus_1.NetworkStatus.loading; | ||
var loading = (this.options.fetchPolicy === 'network-only' && queryLoading) || | ||
@@ -101,7 +104,7 @@ (partial && this.options.fetchPolicy !== 'cache-only'); | ||
else { | ||
networkStatus = loading ? NetworkStatus.loading : NetworkStatus.ready; | ||
networkStatus = loading ? networkStatus_1.NetworkStatus.loading : networkStatus_1.NetworkStatus.ready; | ||
} | ||
var result = { | ||
data: data, | ||
loading: isNetworkRequestInFlight(networkStatus), | ||
loading: networkStatus_1.isNetworkRequestInFlight(networkStatus), | ||
networkStatus: networkStatus, | ||
@@ -116,3 +119,3 @@ }; | ||
this.lastResult = tslib_1.__assign({}, result, { stale: false }); | ||
this.lastResultSnapshot = cloneDeep(this.lastResult); | ||
this.lastResultSnapshot = apollo_utilities_1.cloneDeep(this.lastResult); | ||
} | ||
@@ -127,3 +130,3 @@ return tslib_1.__assign({}, result, { partial: partial }); | ||
snapshot.stale === newResult.stale && | ||
isEqual(snapshot.data, newResult.data)); | ||
apollo_utilities_1.isEqual(snapshot.data, newResult.data)); | ||
}; | ||
@@ -147,6 +150,6 @@ ObservableQuery.prototype.getLastResult = function () { | ||
} | ||
if (!isEqual(this.variables, variables)) { | ||
if (!apollo_utilities_1.isEqual(this.variables, variables)) { | ||
this.variables = Object.assign({}, this.variables, variables); | ||
} | ||
if (!isEqual(this.options.variables, this.variables)) { | ||
if (!apollo_utilities_1.isEqual(this.options.variables, this.variables)) { | ||
this.options.variables = Object.assign({}, this.options.variables, this.variables); | ||
@@ -157,3 +160,3 @@ } | ||
return this.queryManager | ||
.fetchQuery(this.queryId, combinedOptions, FetchType.refetch) | ||
.fetchQuery(this.queryId, combinedOptions, types_1.FetchType.refetch) | ||
.then(function (result) { return result; }); | ||
@@ -163,5 +166,3 @@ }; | ||
var _this = this; | ||
if (!fetchMoreOptions.updateQuery) { | ||
throw new Error('updateQuery option is required. This function defines how to update the query data with the new results.'); | ||
} | ||
ts_invariant_1.invariant(fetchMoreOptions.updateQuery, 'updateQuery option is required. This function defines how to update the query data with the new results.'); | ||
var combinedOptions; | ||
@@ -178,3 +179,3 @@ return Promise.resolve() | ||
combinedOptions.fetchPolicy = 'network-only'; | ||
return _this.queryManager.fetchQuery(qid, combinedOptions, FetchType.normal, _this.queryId); | ||
return _this.queryManager.fetchQuery(qid, combinedOptions, types_1.FetchType.normal, _this.queryId); | ||
}) | ||
@@ -250,3 +251,3 @@ .then(function (fetchMoreResult) { | ||
var newVariables = variables ? variables : this.variables; | ||
if (isEqual(newVariables, this.variables) && !tryFetch) { | ||
if (apollo_utilities_1.isEqual(newVariables, this.variables) && !tryFetch) { | ||
if (this.observers.length === 0 || !fetchResults) { | ||
@@ -270,3 +271,3 @@ return new Promise(function (resolve) { return resolve(); }); | ||
var _a = this.queryManager.getQueryWithPreviousResult(this.queryId), previousResult = _a.previousResult, variables = _a.variables, document = _a.document; | ||
var newResult = tryFunctionOrLogError(function () { | ||
var newResult = apollo_utilities_1.tryFunctionOrLogError(function () { | ||
return mapFn(previousResult, { variables: variables }); | ||
@@ -284,6 +285,3 @@ }); | ||
ObservableQuery.prototype.startPolling = function (pollInterval) { | ||
if (this.options.fetchPolicy === 'cache-first' || | ||
this.options.fetchPolicy === 'cache-only') { | ||
throw new Error('Queries that specify the cache-first and cache-only fetchPolicies cannot also be polling queries.'); | ||
} | ||
assertNotCacheFirstOrOnly(this); | ||
this.options.pollInterval = pollInterval; | ||
@@ -321,6 +319,3 @@ this.queryManager.startPollingQuery(this.options, this.queryId); | ||
if (!!this.options.pollInterval) { | ||
if (this.options.fetchPolicy === 'cache-first' || | ||
this.options.fetchPolicy === 'cache-only') { | ||
throw new Error('Queries that specify the cache-first and cache-only fetchPolicies cannot also be polling queries.'); | ||
} | ||
assertNotCacheFirstOrOnly(this); | ||
this.queryManager.startPollingQuery(this.options, this.queryId); | ||
@@ -331,3 +326,3 @@ } | ||
_this.lastResult = result; | ||
_this.lastResultSnapshot = cloneDeep(result); | ||
_this.lastResultSnapshot = apollo_utilities_1.cloneDeep(result); | ||
_this.observers.forEach(function (obs) { return obs.next && obs.next(result); }); | ||
@@ -352,4 +347,8 @@ }, | ||
return ObservableQuery; | ||
}(Observable)); | ||
export { ObservableQuery }; | ||
}(Observable_1.Observable)); | ||
exports.ObservableQuery = ObservableQuery; | ||
function assertNotCacheFirstOrOnly(obsQuery) { | ||
var fetchPolicy = obsQuery.options.fetchPolicy; | ||
ts_invariant_1.invariant(fetchPolicy !== 'cache-first' && fetchPolicy !== 'cache-only', 'Queries that specify the cache-first and cache-only fetchPolicies cannot also be polling queries.'); | ||
} | ||
//# sourceMappingURL=ObservableQuery.js.map |
@@ -0,0 +0,0 @@ import { ApolloLink, FetchResult } from 'apollo-link'; |
@@ -1,22 +0,25 @@ | ||
import * as tslib_1 from "tslib"; | ||
import { execute, ApolloLink } from 'apollo-link'; | ||
import { DedupLink as Deduplicator } from 'apollo-link-dedup'; | ||
import { assign, getDefaultValues, getMutationDefinition, getOperationDefinition, getOperationName, getQueryDefinition, isProduction, hasDirectives, graphQLResultHasError, hasClientExports, } from 'apollo-utilities'; | ||
import { isApolloError, ApolloError } from '../errors/ApolloError'; | ||
import { Observable } from '../util/Observable'; | ||
import { MutationStore } from '../data/mutations'; | ||
import { QueryStore } from '../data/queries'; | ||
import { ObservableQuery } from './ObservableQuery'; | ||
import { NetworkStatus, isNetworkRequestInFlight } from './networkStatus'; | ||
import { FetchType, } from './types'; | ||
import { LocalState } from './LocalState'; | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var tslib_1 = require("tslib"); | ||
var apollo_link_1 = require("apollo-link"); | ||
var apollo_link_dedup_1 = require("apollo-link-dedup"); | ||
var apollo_utilities_1 = require("apollo-utilities"); | ||
var ts_invariant_1 = require("ts-invariant"); | ||
var ApolloError_1 = require("../errors/ApolloError"); | ||
var Observable_1 = require("../util/Observable"); | ||
var mutations_1 = require("../data/mutations"); | ||
var queries_1 = require("../data/queries"); | ||
var ObservableQuery_1 = require("./ObservableQuery"); | ||
var networkStatus_1 = require("./networkStatus"); | ||
var types_1 = require("./types"); | ||
var LocalState_1 = require("./LocalState"); | ||
var QueryManager = (function () { | ||
function QueryManager(_a) { | ||
var link = _a.link, _b = _a.queryDeduplication, queryDeduplication = _b === void 0 ? false : _b, store = _a.store, _c = _a.onBroadcast, onBroadcast = _c === void 0 ? function () { return undefined; } : _c, _d = _a.ssrMode, ssrMode = _d === void 0 ? false : _d, _e = _a.clientAwareness, clientAwareness = _e === void 0 ? {} : _e, localState = _a.localState; | ||
this.mutationStore = new MutationStore(); | ||
this.queryStore = new QueryStore(); | ||
this.mutationStore = new mutations_1.MutationStore(); | ||
this.queryStore = new queries_1.QueryStore(); | ||
this.clientAwareness = {}; | ||
this.idCounter = 1; | ||
this.queries = new Map(); | ||
this.fetchQueryRejectFns = new Set(); | ||
this.fetchQueryRejectFns = new Map(); | ||
this.queryIdsByName = {}; | ||
@@ -26,3 +29,3 @@ this.pollingInfoByQueryId = new Map(); | ||
this.link = link; | ||
this.deduplicator = ApolloLink.from([new Deduplicator(), link]); | ||
this.deduplicator = apollo_link_1.ApolloLink.from([new apollo_link_dedup_1.DedupLink(), link]); | ||
this.queryDeduplication = queryDeduplication; | ||
@@ -32,3 +35,3 @@ this.dataStore = store; | ||
this.clientAwareness = clientAwareness; | ||
this.localState = localState || new LocalState({ cache: store.getCache() }); | ||
this.localState = localState || new LocalState_1.LocalState({ cache: store.getCache() }); | ||
this.ssrMode = ssrMode; | ||
@@ -53,12 +56,8 @@ } | ||
case 0: | ||
if (!mutation) { | ||
throw new Error('mutation option is required. You must specify your GraphQL document in the mutation option.'); | ||
} | ||
if (fetchPolicy && fetchPolicy !== 'no-cache') { | ||
throw new Error("fetchPolicy for mutations currently only supports the 'no-cache' policy"); | ||
} | ||
ts_invariant_1.invariant(mutation, 'mutation option is required. You must specify your GraphQL document in the mutation option.'); | ||
ts_invariant_1.invariant(!fetchPolicy || fetchPolicy === 'no-cache', "fetchPolicy for mutations currently only supports the 'no-cache' policy"); | ||
mutationId = this.generateQueryId(); | ||
cache = this.dataStore.getCache(); | ||
(mutation = cache.transformDocument(mutation)), | ||
(variables = assign({}, getDefaultValues(getMutationDefinition(mutation)), variables)); | ||
(variables = apollo_utilities_1.assign({}, apollo_utilities_1.getDefaultValues(apollo_utilities_1.getMutationDefinition(mutation)), variables)); | ||
this.setQuery(mutationId, function () { return ({ document: mutation }); }); | ||
@@ -79,3 +78,3 @@ generateUpdateQueriesInfo = function () { | ||
}; | ||
if (!hasClientExports(mutation)) return [3, 2]; | ||
if (!apollo_utilities_1.hasClientExports(mutation)) return [3, 2]; | ||
return [4, this.localState.addExportedVariables(mutation, variables, context)]; | ||
@@ -143,3 +142,3 @@ case 1: | ||
storeResult && | ||
graphQLResultHasError(storeResult)) { | ||
apollo_utilities_1.graphQLResultHasError(storeResult)) { | ||
delete storeResult.errors; | ||
@@ -156,4 +155,4 @@ } | ||
var obs = serverQuery | ||
? execute(_this.link, operation) | ||
: Observable.of({ | ||
? apollo_link_1.execute(_this.link, operation) | ||
: Observable_1.Observable.of({ | ||
data: {}, | ||
@@ -171,5 +170,5 @@ }); | ||
handlingNext = true; | ||
if (graphQLResultHasError(result) && errorPolicy === 'none') { | ||
if (apollo_utilities_1.graphQLResultHasError(result) && errorPolicy === 'none') { | ||
handlingNext = false; | ||
error = new ApolloError({ | ||
error = new ApolloError_1.ApolloError({ | ||
graphQLErrors: result.errors, | ||
@@ -182,3 +181,3 @@ }); | ||
context = operation.context, variables = operation.variables; | ||
if (!(clientQuery && hasDirectives(['client'], clientQuery))) return [3, 2]; | ||
if (!(clientQuery && apollo_utilities_1.hasDirectives(['client'], clientQuery))) return [3, 2]; | ||
return [4, self.localState | ||
@@ -227,3 +226,3 @@ .runResolvers({ | ||
self.setQuery(mutationId, function () { return ({ document: null }); }); | ||
reject(new ApolloError({ | ||
reject(new ApolloError_1.ApolloError({ | ||
networkError: err, | ||
@@ -254,3 +253,3 @@ })); | ||
query = cache.transformDocument(options.query); | ||
if (!hasClientExports(query)) return [3, 2]; | ||
if (!apollo_utilities_1.hasClientExports(query)) return [3, 2]; | ||
return [4, this.localState.addExportedVariables(query, variables, context)]; | ||
@@ -267,3 +266,3 @@ case 1: | ||
needToFetch = fetchPolicy === 'network-only' || fetchPolicy === 'no-cache'; | ||
if (fetchType !== FetchType.refetch && | ||
if (fetchType !== types_1.FetchType.refetch && | ||
fetchPolicy !== 'network-only' && | ||
@@ -281,3 +280,3 @@ fetchPolicy !== 'no-cache') { | ||
shouldFetch = needToFetch && fetchPolicy !== 'cache-only' && fetchPolicy !== 'standby'; | ||
if (hasDirectives(['live'], query)) | ||
if (apollo_utilities_1.hasDirectives(['live'], query)) | ||
shouldFetch = true; | ||
@@ -298,4 +297,4 @@ requestId = this.generateRequestId(); | ||
variables: updatedVariables, | ||
isPoll: fetchType === FetchType.poll, | ||
isRefetch: fetchType === FetchType.refetch, | ||
isPoll: fetchType === types_1.FetchType.poll, | ||
isRefetch: fetchType === types_1.FetchType.refetch, | ||
metadata: metadata, | ||
@@ -319,3 +318,3 @@ fetchMoreForQueryId: fetchMoreForQueryId, | ||
}).catch(function (error) { | ||
if (isApolloError(error)) { | ||
if (ApolloError_1.isApolloError(error)) { | ||
throw error; | ||
@@ -330,3 +329,3 @@ } | ||
} | ||
throw new ApolloError({ networkError: error }); | ||
throw new ApolloError_1.ApolloError({ networkError: error }); | ||
} | ||
@@ -379,3 +378,3 @@ }); | ||
errorPolicy !== 'none'; | ||
if (!(!isNetworkRequestInFlight(queryStoreValue.networkStatus) || | ||
if (!(!networkStatus_1.isNetworkRequestInFlight(queryStoreValue.networkStatus) || | ||
(networkStatusChanged && options.notifyOnNetworkStatusChange) || | ||
@@ -387,3 +386,3 @@ shouldNotifyIfLoading)) return [3, 8]; | ||
queryStoreValue.networkError) { | ||
apolloError_1 = new ApolloError({ | ||
apolloError_1 = new ApolloError_1.ApolloError({ | ||
graphQLErrors: queryStoreValue.graphQLErrors, | ||
@@ -407,3 +406,3 @@ networkError: queryStoreValue.networkError, | ||
}, 0); | ||
if (!isProduction()) { | ||
if (process.env.NODE_ENV !== 'production') { | ||
console.info('An unhandled error was thrown because no error handler is registered ' + | ||
@@ -449,3 +448,3 @@ 'for the query ' + | ||
data: lastResult && lastResult.data, | ||
loading: isNetworkRequestInFlight(queryStoreValue.networkStatus), | ||
loading: networkStatus_1.isNetworkRequestInFlight(queryStoreValue.networkStatus), | ||
networkStatus: queryStoreValue.networkStatus, | ||
@@ -458,3 +457,3 @@ stale: true, | ||
data: data, | ||
loading: isNetworkRequestInFlight(queryStoreValue.networkStatus), | ||
loading: networkStatus_1.isNetworkRequestInFlight(queryStoreValue.networkStatus), | ||
networkStatus: queryStoreValue.networkStatus, | ||
@@ -505,3 +504,3 @@ stale: false, | ||
if (observer.error) | ||
observer.error(new ApolloError({ networkError: error_1 })); | ||
observer.error(new ApolloError_1.ApolloError({ networkError: error_1 })); | ||
return [2]; | ||
@@ -515,10 +514,8 @@ case 8: return [2]; | ||
if (shouldSubscribe === void 0) { shouldSubscribe = true; } | ||
if (options.fetchPolicy === 'standby') { | ||
throw new Error('client.watchQuery cannot be called with fetchPolicy set to "standby"'); | ||
} | ||
var queryDefinition = getQueryDefinition(options.query); | ||
ts_invariant_1.invariant(options.fetchPolicy !== 'standby', 'client.watchQuery cannot be called with fetchPolicy set to "standby"'); | ||
var queryDefinition = apollo_utilities_1.getQueryDefinition(options.query); | ||
if (queryDefinition.variableDefinitions && | ||
queryDefinition.variableDefinitions.length) { | ||
var defaultValues = getDefaultValues(queryDefinition); | ||
options.variables = assign({}, defaultValues, options.variables); | ||
var defaultValues = apollo_utilities_1.getDefaultValues(queryDefinition); | ||
options.variables = apollo_utilities_1.assign({}, defaultValues, options.variables); | ||
} | ||
@@ -529,3 +526,3 @@ if (typeof options.notifyOnNetworkStatusChange === 'undefined') { | ||
var transformedOptions = tslib_1.__assign({}, options); | ||
return new ObservableQuery({ | ||
return new ObservableQuery_1.ObservableQuery({ | ||
queryManager: this, | ||
@@ -538,21 +535,16 @@ options: transformedOptions, | ||
var _this = this; | ||
if (!options.query) { | ||
throw new Error('query option is required. You must specify your GraphQL document ' + | ||
'in the query option.'); | ||
} | ||
if (options.query.kind !== 'Document') { | ||
throw new Error('You must wrap the query string in a "gql" tag.'); | ||
} | ||
if (options.returnPartialData) { | ||
throw new Error('returnPartialData option only supported on watchQuery.'); | ||
} | ||
if (options.pollInterval) { | ||
throw new Error('pollInterval option only supported on watchQuery.'); | ||
} | ||
ts_invariant_1.invariant(options.query, 'query option is required. You must specify your GraphQL document ' + | ||
'in the query option.'); | ||
ts_invariant_1.invariant(options.query.kind === 'Document', 'You must wrap the query string in a "gql" tag.'); | ||
ts_invariant_1.invariant(!options.returnPartialData, 'returnPartialData option only supported on watchQuery.'); | ||
ts_invariant_1.invariant(!options.pollInterval, 'pollInterval option only supported on watchQuery.'); | ||
return new Promise(function (resolve, reject) { | ||
_this.fetchQueryRejectFns.add(reject); | ||
_this.watchQuery(options, false) | ||
var watchedQuery = _this.watchQuery(options, false); | ||
_this.fetchQueryRejectFns.set("query:" + watchedQuery.queryId, reject); | ||
watchedQuery | ||
.result() | ||
.then(resolve, reject) | ||
.then(function () { return _this.fetchQueryRejectFns.delete(reject); }); | ||
.then(function () { | ||
return _this.fetchQueryRejectFns.delete("query:" + watchedQuery.queryId); | ||
}); | ||
}); | ||
@@ -611,3 +603,3 @@ }; | ||
this.setQuery(queryId, function () { return ({ observableQuery: observableQuery }); }); | ||
var queryDef = getQueryDefinition(observableQuery.options.query); | ||
var queryDef = apollo_utilities_1.getQueryDefinition(observableQuery.options.query); | ||
if (queryDef.name && queryDef.name.value) { | ||
@@ -625,3 +617,3 @@ var queryName = queryDef.name.value; | ||
return; | ||
var definition = getQueryDefinition(observableQuery.options.query); | ||
var definition = apollo_utilities_1.getQueryDefinition(observableQuery.options.query); | ||
var queryName = definition.name ? definition.name.value : null; | ||
@@ -673,3 +665,3 @@ this.setQuery(queryId, function () { return ({ observableQuery: null }); }); | ||
var transformedDoc = cache.transformDocument(query); | ||
var variables = assign({}, getDefaultValues(getOperationDefinition(query)), options.variables); | ||
var variables = apollo_utilities_1.assign({}, apollo_utilities_1.getDefaultValues(apollo_utilities_1.getOperationDefinition(query)), options.variables); | ||
var updatedVariables = variables; | ||
@@ -679,3 +671,3 @@ var sub; | ||
var clientQuery = this.localState.clientQuery(transformedDoc); | ||
return new Observable(function (observer) { | ||
return new Observable_1.Observable(function (observer) { | ||
observers.push(observer); | ||
@@ -693,3 +685,3 @@ if (observers.length === 1) { | ||
updatedResult = result; | ||
if (!(clientQuery && hasDirectives(['client'], clientQuery))) return [3, 2]; | ||
if (!(clientQuery && apollo_utilities_1.hasDirectives(['client'], clientQuery))) return [3, 2]; | ||
return [4, this.localState.runResolvers({ | ||
@@ -710,4 +702,4 @@ document: clientQuery, | ||
observers.forEach(function (obs) { | ||
if (graphQLResultHasError(updatedResult) && obs.error) { | ||
obs.error(new ApolloError({ | ||
if (apollo_utilities_1.graphQLResultHasError(updatedResult) && obs.error) { | ||
obs.error(new ApolloError_1.ApolloError({ | ||
graphQLErrors: updatedResult.errors, | ||
@@ -751,3 +743,3 @@ })); | ||
case 0: | ||
if (!hasClientExports(transformedDoc)) return [3, 2]; | ||
if (!apollo_utilities_1.hasClientExports(transformedDoc)) return [3, 2]; | ||
return [4, this.localState.addExportedVariables(transformedDoc, variables)]; | ||
@@ -765,6 +757,6 @@ case 1: | ||
operation = this.buildOperationForLink(serverQuery, updatedVariables); | ||
sub = execute(this.link, operation).subscribe(handler_1); | ||
sub = apollo_link_1.execute(this.link, operation).subscribe(handler_1); | ||
} | ||
else { | ||
sub = Observable.of({ data: {} }).subscribe(handler_1); | ||
sub = Observable_1.Observable.of({ data: {} }).subscribe(handler_1); | ||
} | ||
@@ -794,2 +786,4 @@ return [2]; | ||
var subscriptions = this.getQuery(queryId).subscriptions; | ||
this.fetchQueryRejectFns.delete("query:" + queryId); | ||
this.fetchQueryRejectFns.delete("fetchRequest:" + queryId); | ||
subscriptions.forEach(function (x) { return x.unsubscribe(); }); | ||
@@ -825,5 +819,3 @@ this.queries.delete(queryId); | ||
var foundObserveableQuery = this.getQuery(queryIdOrObservable).observableQuery; | ||
if (!foundObserveableQuery) { | ||
throw new Error("ObservableQuery with this id doesn't exist: " + queryIdOrObservable); | ||
} | ||
ts_invariant_1.invariant(foundObserveableQuery, "ObservableQuery with this id doesn't exist: " + queryIdOrObservable); | ||
observableQuery = foundObserveableQuery; | ||
@@ -883,3 +875,2 @@ } | ||
var errorsFromStore; | ||
var rejectFetchPromise; | ||
return new Promise(function (resolve, reject) { | ||
@@ -893,9 +884,9 @@ var obs; | ||
updatedContext = operation.context; | ||
obs = execute(_this.deduplicator, operation); | ||
obs = apollo_link_1.execute(_this.deduplicator, operation); | ||
} | ||
else { | ||
updatedContext = _this.prepareContext(context); | ||
obs = Observable.of({ data: {} }); | ||
obs = Observable_1.Observable.of({ data: {} }); | ||
} | ||
_this.fetchQueryRejectFns.add((rejectFetchPromise = reject)); | ||
_this.fetchQueryRejectFns.set("fetchRequest:" + queryId, reject); | ||
var complete = false; | ||
@@ -913,3 +904,3 @@ var handlingNext = true; | ||
if (!(requestId >= (lastRequestId || 1))) return [3, 3]; | ||
if (!(clientQuery && hasDirectives(['client'], clientQuery))) return [3, 2]; | ||
if (!(clientQuery && apollo_utilities_1.hasDirectives(['client'], clientQuery))) return [3, 2]; | ||
return [4, this.localState | ||
@@ -953,3 +944,3 @@ .runResolvers({ | ||
handlingNext = false; | ||
reject(new ApolloError({ | ||
reject(new ApolloError_1.ApolloError({ | ||
graphQLErrors: updatedResult.errors, | ||
@@ -984,3 +975,3 @@ })); | ||
error: function (error) { | ||
_this.fetchQueryRejectFns.delete(reject); | ||
_this.fetchQueryRejectFns.delete("fetchRequest:" + queryId); | ||
_this.setQuery(queryId, function (_a) { | ||
@@ -996,3 +987,3 @@ var subscriptions = _a.subscriptions; | ||
if (!handlingNext) { | ||
_this.fetchQueryRejectFns.delete(reject); | ||
_this.fetchQueryRejectFns.delete("fetchRequest:" + queryId); | ||
_this.setQuery(queryId, function (_a) { | ||
@@ -1008,3 +999,3 @@ var subscriptions = _a.subscriptions; | ||
loading: false, | ||
networkStatus: NetworkStatus.ready, | ||
networkStatus: networkStatus_1.NetworkStatus.ready, | ||
stale: false, | ||
@@ -1024,3 +1015,3 @@ }); | ||
}).catch(function (error) { | ||
_this.fetchQueryRejectFns.delete(rejectFetchPromise); | ||
_this.fetchQueryRejectFns.delete("fetchRequest:" + queryId); | ||
throw error; | ||
@@ -1074,3 +1065,3 @@ }); | ||
variables: variables, | ||
operationName: getOperationName(document) || undefined, | ||
operationName: apollo_utilities_1.getOperationName(document) || undefined, | ||
context: this.prepareContext(extraContext), | ||
@@ -1087,10 +1078,8 @@ }; | ||
return (query && | ||
query.networkStatus !== NetworkStatus.ready && | ||
query.networkStatus !== NetworkStatus.error); | ||
query.networkStatus !== networkStatus_1.NetworkStatus.ready && | ||
query.networkStatus !== networkStatus_1.NetworkStatus.error); | ||
}; | ||
QueryManager.prototype.startPollingQuery = function (options, queryId, listener) { | ||
var pollInterval = options.pollInterval; | ||
if (!pollInterval) { | ||
throw new Error('Attempted to start a polling query without a polling interval.'); | ||
} | ||
ts_invariant_1.invariant(pollInterval, 'Attempted to start a polling query without a polling interval.'); | ||
if (!this.ssrMode) { | ||
@@ -1137,3 +1126,3 @@ this.pollingInfoByQueryId.set(queryId, { | ||
}; | ||
_this.fetchQuery(queryId, info.options, FetchType.poll).then(updateLastPollTime, updateLastPollTime); | ||
_this.fetchQuery(queryId, info.options, types_1.FetchType.poll).then(updateLastPollTime, updateLastPollTime); | ||
} | ||
@@ -1150,3 +1139,3 @@ } | ||
}()); | ||
export { QueryManager }; | ||
exports.QueryManager = QueryManager; | ||
//# sourceMappingURL=QueryManager.js.map |
@@ -0,0 +0,0 @@ import { FetchResult } from 'apollo-link'; |
@@ -1,2 +0,4 @@ | ||
export var FetchType; | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var FetchType; | ||
(function (FetchType) { | ||
@@ -6,3 +8,3 @@ FetchType[FetchType["normal"] = 1] = "normal"; | ||
FetchType[FetchType["poll"] = 3] = "poll"; | ||
})(FetchType || (FetchType = {})); | ||
})(FetchType = exports.FetchType || (exports.FetchType = {})); | ||
//# sourceMappingURL=types.js.map |
@@ -0,0 +0,0 @@ import { DocumentNode, ExecutionResult } from 'graphql'; |
@@ -0,1 +1,3 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
//# sourceMappingURL=watchQueryOptions.js.map |
@@ -0,0 +0,0 @@ import { DocumentNode } from 'graphql'; |
@@ -0,1 +1,3 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var MutationStore = (function () { | ||
@@ -40,3 +42,3 @@ function MutationStore() { | ||
}()); | ||
export { MutationStore }; | ||
exports.MutationStore = MutationStore; | ||
//# sourceMappingURL=mutations.js.map |
@@ -0,0 +0,0 @@ import { DocumentNode, GraphQLError, ExecutionResult } from 'graphql'; |
@@ -1,4 +0,7 @@ | ||
import * as tslib_1 from "tslib"; | ||
import { isEqual } from 'apollo-utilities'; | ||
import { NetworkStatus } from '../core/networkStatus'; | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var tslib_1 = require("tslib"); | ||
var apollo_utilities_1 = require("apollo-utilities"); | ||
var ts_invariant_1 = require("ts-invariant"); | ||
var networkStatus_1 = require("../core/networkStatus"); | ||
var QueryStore = (function () { | ||
@@ -18,4 +21,4 @@ function QueryStore() { | ||
previousQuery.document !== query.document && | ||
!isEqual(previousQuery.document, query.document)) { | ||
throw new Error('Internal Error: may not update existing query string in store'); | ||
!apollo_utilities_1.isEqual(previousQuery.document, query.document)) { | ||
throw new ts_invariant_1.InvariantError('Internal Error: may not update existing query string in store'); | ||
} | ||
@@ -26,4 +29,4 @@ var isSetVariables = false; | ||
previousQuery && | ||
previousQuery.networkStatus !== NetworkStatus.loading) { | ||
if (!isEqual(previousQuery.variables, query.variables)) { | ||
previousQuery.networkStatus !== networkStatus_1.NetworkStatus.loading) { | ||
if (!apollo_utilities_1.isEqual(previousQuery.variables, query.variables)) { | ||
isSetVariables = true; | ||
@@ -35,12 +38,12 @@ previousVariables = previousQuery.variables; | ||
if (isSetVariables) { | ||
networkStatus = NetworkStatus.setVariables; | ||
networkStatus = networkStatus_1.NetworkStatus.setVariables; | ||
} | ||
else if (query.isPoll) { | ||
networkStatus = NetworkStatus.poll; | ||
networkStatus = networkStatus_1.NetworkStatus.poll; | ||
} | ||
else if (query.isRefetch) { | ||
networkStatus = NetworkStatus.refetch; | ||
networkStatus = networkStatus_1.NetworkStatus.refetch; | ||
} | ||
else { | ||
networkStatus = NetworkStatus.loading; | ||
networkStatus = networkStatus_1.NetworkStatus.loading; | ||
} | ||
@@ -63,3 +66,3 @@ var graphQLErrors = []; | ||
this.store[query.fetchMoreForQueryId].networkStatus = | ||
NetworkStatus.fetchMore; | ||
networkStatus_1.NetworkStatus.fetchMore; | ||
} | ||
@@ -74,6 +77,6 @@ }; | ||
this.store[queryId].previousVariables = null; | ||
this.store[queryId].networkStatus = NetworkStatus.ready; | ||
this.store[queryId].networkStatus = networkStatus_1.NetworkStatus.ready; | ||
if (typeof fetchMoreForQueryId === 'string' && | ||
this.store[fetchMoreForQueryId]) { | ||
this.store[fetchMoreForQueryId].networkStatus = NetworkStatus.ready; | ||
this.store[fetchMoreForQueryId].networkStatus = networkStatus_1.NetworkStatus.ready; | ||
} | ||
@@ -85,3 +88,3 @@ }; | ||
this.store[queryId].networkError = error; | ||
this.store[queryId].networkStatus = NetworkStatus.error; | ||
this.store[queryId].networkStatus = networkStatus_1.NetworkStatus.error; | ||
if (typeof fetchMoreForQueryId === 'string') { | ||
@@ -97,4 +100,4 @@ this.markQueryResultClient(fetchMoreForQueryId, true); | ||
this.store[queryId].networkStatus = complete | ||
? NetworkStatus.ready | ||
: NetworkStatus.loading; | ||
? networkStatus_1.NetworkStatus.ready | ||
: networkStatus_1.NetworkStatus.loading; | ||
}; | ||
@@ -111,3 +114,3 @@ QueryStore.prototype.stopQuery = function (queryId) { | ||
.reduce(function (res, key) { | ||
res[key] = tslib_1.__assign({}, _this.store[key], { networkStatus: NetworkStatus.loading }); | ||
res[key] = tslib_1.__assign({}, _this.store[key], { networkStatus: networkStatus_1.NetworkStatus.loading }); | ||
return res; | ||
@@ -118,3 +121,3 @@ }, {}); | ||
}()); | ||
export { QueryStore }; | ||
exports.QueryStore = QueryStore; | ||
//# sourceMappingURL=queries.js.map |
@@ -0,0 +0,0 @@ import { ExecutionResult, DocumentNode } from 'graphql'; |
@@ -1,2 +0,4 @@ | ||
import { getOperationName, tryFunctionOrLogError, graphQLResultHasError, } from 'apollo-utilities'; | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var apollo_utilities_1 = require("apollo-utilities"); | ||
var DataStore = (function () { | ||
@@ -11,4 +13,4 @@ function DataStore(initialCache) { | ||
if (ignoreErrors === void 0) { ignoreErrors = false; } | ||
var writeWithErrors = !graphQLResultHasError(result); | ||
if (ignoreErrors && graphQLResultHasError(result) && result.data) { | ||
var writeWithErrors = !apollo_utilities_1.graphQLResultHasError(result); | ||
if (ignoreErrors && apollo_utilities_1.graphQLResultHasError(result) && result.data) { | ||
writeWithErrors = true; | ||
@@ -26,3 +28,3 @@ } | ||
DataStore.prototype.markSubscriptionResult = function (result, document, variables) { | ||
if (!graphQLResultHasError(result)) { | ||
if (!apollo_utilities_1.graphQLResultHasError(result)) { | ||
this.cache.write({ | ||
@@ -70,3 +72,3 @@ result: result.data, | ||
var _this = this; | ||
if (!graphQLResultHasError(mutation.result)) { | ||
if (!apollo_utilities_1.graphQLResultHasError(mutation.result)) { | ||
var cacheWrites_1 = []; | ||
@@ -93,6 +95,6 @@ cacheWrites_1.push({ | ||
} | ||
var nextQueryResult = tryFunctionOrLogError(function () { | ||
var nextQueryResult = apollo_utilities_1.tryFunctionOrLogError(function () { | ||
return updater(currentQueryResult, { | ||
mutationResult: mutation.result, | ||
queryName: getOperationName(query.document) || undefined, | ||
queryName: apollo_utilities_1.getOperationName(query.document) || undefined, | ||
queryVariables: query.variables, | ||
@@ -117,3 +119,3 @@ }); | ||
this.cache.performTransaction(function (c) { | ||
tryFunctionOrLogError(function () { return update_1(c, mutation.result); }); | ||
apollo_utilities_1.tryFunctionOrLogError(function () { return update_1(c, mutation.result); }); | ||
}); | ||
@@ -142,3 +144,3 @@ } | ||
}()); | ||
export { DataStore }; | ||
exports.DataStore = DataStore; | ||
//# sourceMappingURL=store.js.map |
@@ -0,0 +0,0 @@ import { GraphQLError } from 'graphql'; |
@@ -1,5 +0,8 @@ | ||
import * as tslib_1 from "tslib"; | ||
export function isApolloError(err) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var tslib_1 = require("tslib"); | ||
function isApolloError(err) { | ||
return err.hasOwnProperty('graphQLErrors'); | ||
} | ||
exports.isApolloError = isApolloError; | ||
var generateErrorMessage = function (err) { | ||
@@ -40,3 +43,3 @@ var message = ''; | ||
}(Error)); | ||
export { ApolloError }; | ||
exports.ApolloError = ApolloError; | ||
//# sourceMappingURL=ApolloError.js.map |
@@ -0,0 +0,0 @@ export { ObservableQuery, FetchMoreOptions, UpdateQueryOptions, ApolloCurrentResult, ApolloCurrentQueryResult, } from './core/ObservableQuery'; |
21
index.js
@@ -1,8 +0,15 @@ | ||
export { ObservableQuery, } from './core/ObservableQuery'; | ||
export { NetworkStatus } from './core/networkStatus'; | ||
export * from './core/types'; | ||
export { isApolloError, ApolloError } from './errors/ApolloError'; | ||
import ApolloClient from './ApolloClient'; | ||
export { ApolloClient }; | ||
export default ApolloClient; | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var tslib_1 = require("tslib"); | ||
var ObservableQuery_1 = require("./core/ObservableQuery"); | ||
exports.ObservableQuery = ObservableQuery_1.ObservableQuery; | ||
var networkStatus_1 = require("./core/networkStatus"); | ||
exports.NetworkStatus = networkStatus_1.NetworkStatus; | ||
tslib_1.__exportStar(require("./core/types"), exports); | ||
var ApolloError_1 = require("./errors/ApolloError"); | ||
exports.isApolloError = ApolloError_1.isApolloError; | ||
exports.ApolloError = ApolloError_1.ApolloError; | ||
var ApolloClient_1 = tslib_1.__importDefault(require("./ApolloClient")); | ||
exports.ApolloClient = ApolloClient_1.default; | ||
exports.default = ApolloClient_1.default; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "apollo-client", | ||
"version": "2.5.0-beta.0", | ||
"version": "2.5.0-beta.1", | ||
"description": "A simple yet functional GraphQL client.", | ||
"main": "bundle.umd.js", | ||
"module": "index.js", | ||
"jsnext:main": "index.js", | ||
"module": "bundle.esm.js", | ||
"typings": "index.d.ts", | ||
@@ -28,7 +27,8 @@ "sideEffects": false, | ||
"@types/zen-observable": "^0.8.0", | ||
"apollo-cache": "1.2.0-beta.0", | ||
"apollo-cache": "1.2.0-beta.1", | ||
"apollo-link": "^1.0.0", | ||
"apollo-link-dedup": "^1.0.0", | ||
"apollo-utilities": "1.2.0-beta.0", | ||
"apollo-utilities": "1.2.0-beta.1", | ||
"symbol-observable": "^1.0.2", | ||
"ts-invariant": "^0.2.1", | ||
"tslib": "^1.9.3", | ||
@@ -35,0 +35,0 @@ "zen-observable": "^0.8.0" |
export declare function capitalizeFirstLetter(str: string): string; | ||
//# sourceMappingURL=capitalizeFirstLetter.d.ts.map |
@@ -1,4 +0,7 @@ | ||
export function capitalizeFirstLetter(str) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
function capitalizeFirstLetter(str) { | ||
return str.charAt(0).toUpperCase() + str.slice(1); | ||
} | ||
exports.capitalizeFirstLetter = capitalizeFirstLetter; | ||
//# sourceMappingURL=capitalizeFirstLetter.js.map |
@@ -0,0 +0,0 @@ /// <reference types="zen-observable" /> |
@@ -1,4 +0,6 @@ | ||
import * as tslib_1 from "tslib"; | ||
import { Observable as LinkObservable } from 'apollo-link'; | ||
import $$observable from 'symbol-observable'; | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var tslib_1 = require("tslib"); | ||
var apollo_link_1 = require("apollo-link"); | ||
var symbol_observable_1 = tslib_1.__importDefault(require("symbol-observable")); | ||
var Observable = (function (_super) { | ||
@@ -9,3 +11,3 @@ tslib_1.__extends(Observable, _super); | ||
} | ||
Observable.prototype[$$observable] = function () { | ||
Observable.prototype[symbol_observable_1.default] = function () { | ||
return this; | ||
@@ -17,4 +19,4 @@ }; | ||
return Observable; | ||
}(LinkObservable)); | ||
export { Observable }; | ||
}(apollo_link_1.Observable)); | ||
exports.Observable = Observable; | ||
//# sourceMappingURL=Observable.js.map |
@@ -0,0 +0,0 @@ import { ObservableQuery } from '../../src/core/ObservableQuery'; |
@@ -1,2 +0,4 @@ | ||
export function observableToPromiseAndSubscription(_a) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
function observableToPromiseAndSubscription(_a) { | ||
var observable = _a.observable, _b = _a.shouldResolve, shouldResolve = _b === void 0 ? true : _b, _c = _a.wait, wait = _c === void 0 ? -1 : _c, _d = _a.errorCallbacks, errorCallbacks = _d === void 0 ? [] : _d; | ||
@@ -67,3 +69,4 @@ var cbs = []; | ||
} | ||
export default function (options) { | ||
exports.observableToPromiseAndSubscription = observableToPromiseAndSubscription; | ||
function default_1(options) { | ||
var cbs = []; | ||
@@ -75,2 +78,3 @@ for (var _i = 1; _i < arguments.length; _i++) { | ||
} | ||
exports.default = default_1; | ||
//# sourceMappingURL=observableToPromise.js.map |
@@ -0,0 +0,0 @@ /// <reference types="jest" /> |
@@ -1,2 +0,4 @@ | ||
export default function subscribeAndCount(done, observable, cb) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
function subscribeAndCount(done, observable, cb) { | ||
var handleCount = 0; | ||
@@ -20,2 +22,3 @@ var subscription = observable.subscribe({ | ||
} | ||
exports.default = subscribeAndCount; | ||
//# sourceMappingURL=subscribeAndCount.js.map |
@@ -0,0 +0,0 @@ /// <reference types="jest" /> |
@@ -1,2 +0,4 @@ | ||
export default (function (done, cb) { return function () { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.default = (function (done, cb) { return function () { | ||
var args = []; | ||
@@ -13,3 +15,3 @@ for (var _i = 0; _i < arguments.length; _i++) { | ||
}; }); | ||
export function withWarning(func, regex) { | ||
function withWarning(func, regex) { | ||
var message = null; | ||
@@ -24,3 +26,4 @@ var oldWarn = console.warn; | ||
} | ||
export function withError(func, regex) { | ||
exports.withWarning = withWarning; | ||
function withError(func, regex) { | ||
var message = null; | ||
@@ -38,2 +41,3 @@ var oldError = console.error; | ||
} | ||
exports.withError = withError; | ||
//# sourceMappingURL=wrap.js.map |
@@ -1,2 +0,2 @@ | ||
export declare const version = "2.5.0-beta.0"; | ||
export declare const version = "2.5.0-beta.1"; | ||
//# sourceMappingURL=version.d.ts.map |
@@ -1,1 +0,1 @@ | ||
exports.version = "2.5.0-beta.0" | ||
exports.version = "2.5.0-beta.1" |
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 too big to display
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
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
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
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
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
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
1274108
86
0
10222
10
3
60
+ Addedts-invariant@^0.2.1
+ Addedapollo-cache@1.2.0-beta.1(transitive)
+ Addedapollo-utilities@1.2.0-beta.1(transitive)
+ Addedts-invariant@0.2.1(transitive)
- Removedapollo-cache@1.2.0-beta.0(transitive)
- Removedapollo-utilities@1.2.0-beta.0(transitive)
Updatedapollo-cache@1.2.0-beta.1