@apollo/client 3.4.5 → 3.4.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/apollo-client.cjs.js +1010 -114
- package/apollo-client.cjs.js.map +1 -1
- package/apollo-core.cjs.js +5772 -0
- package/apollo-core.cjs.js.map +1 -0
- package/apollo-core.cjs.min.js +1 -0
- package/cache/cache.cjs.js +22 -19
- package/cache/cache.cjs.js.map +1 -1
- package/cache/index.d.ts.map +1 -1
- package/cache/index.js +2 -3
- package/cache/index.js.map +1 -1
- package/cache/inmemory/entityStore.js +1 -1
- package/cache/inmemory/policies.js +12 -9
- package/cache/inmemory/policies.js.map +1 -1
- package/cache/inmemory/readFromStore.js +3 -3
- package/cache/inmemory/writeToStore.d.ts +1 -1
- package/cache/inmemory/writeToStore.d.ts.map +1 -1
- package/cache/inmemory/writeToStore.js +4 -4
- package/cache/inmemory/writeToStore.js.map +1 -1
- package/core/ApolloClient.js +2 -2
- package/core/LocalState.js +1 -1
- package/core/ObservableQuery.d.ts +9 -6
- package/core/ObservableQuery.d.ts.map +1 -1
- package/core/ObservableQuery.js +70 -45
- package/core/ObservableQuery.js.map +1 -1
- package/core/QueryManager.d.ts +3 -3
- package/core/QueryManager.d.ts.map +1 -1
- package/core/QueryManager.js +20 -19
- package/core/QueryManager.js.map +1 -1
- package/core/core.cjs.js +94 -66
- package/core/core.cjs.js.map +1 -1
- package/core/index.d.ts.map +1 -1
- package/core/index.js +2 -1
- package/core/index.js.map +1 -1
- package/core/watchQueryOptions.d.ts +2 -1
- package/core/watchQueryOptions.d.ts.map +1 -1
- package/core/watchQueryOptions.js.map +1 -1
- package/errors/errors.cjs.js +1 -2
- package/errors/errors.cjs.js.map +1 -1
- package/errors/index.d.ts.map +1 -1
- package/errors/index.js +2 -3
- package/errors/index.js.map +1 -1
- package/invariantErrorCodes.js +59 -82
- package/link/core/ApolloLink.js +1 -1
- package/link/core/core.cjs.js +3 -3
- package/link/core/core.cjs.js.map +1 -1
- package/link/core/index.d.ts.map +1 -1
- package/link/core/index.js +2 -3
- package/link/core/index.js.map +1 -1
- package/link/http/checkFetcher.js +1 -1
- package/link/http/createHttpLink.d.ts.map +1 -1
- package/link/http/createHttpLink.js +7 -5
- package/link/http/createHttpLink.js.map +1 -1
- package/link/http/http.cjs.js +11 -8
- package/link/http/http.cjs.js.map +1 -1
- package/link/http/index.d.ts.map +1 -1
- package/link/http/index.js +2 -0
- package/link/http/index.js.map +1 -1
- package/link/http/serializeFetchParameter.js +1 -1
- package/link/persisted-queries/index.d.ts.map +1 -1
- package/link/persisted-queries/index.js +4 -2
- package/link/persisted-queries/index.js.map +1 -1
- package/link/persisted-queries/persisted-queries.cjs.js +4 -3
- package/link/persisted-queries/persisted-queries.cjs.js.map +1 -1
- package/link/utils/index.d.ts.map +1 -1
- package/link/utils/index.js +2 -0
- package/link/utils/index.js.map +1 -1
- package/link/utils/utils.cjs.js +3 -1
- package/link/utils/utils.cjs.js.map +1 -1
- package/link/utils/validateOperation.js +1 -1
- package/package.json +8 -8
- package/react/context/ApolloConsumer.js +1 -1
- package/react/context/ApolloProvider.js +1 -1
- package/react/context/context.cjs.js +5 -3
- package/react/context/context.cjs.js.map +1 -1
- package/react/context/index.d.ts.map +1 -1
- package/react/context/index.js +2 -0
- package/react/context/index.js.map +1 -1
- package/react/data/OperationData.js +2 -2
- package/react/data/QueryData.d.ts.map +1 -1
- package/react/data/QueryData.js +8 -8
- package/react/data/QueryData.js.map +1 -1
- package/react/data/data.cjs.js +13 -10
- package/react/data/data.cjs.js.map +1 -1
- package/react/data/index.d.ts.map +1 -1
- package/react/data/index.js +2 -0
- package/react/data/index.js.map +1 -1
- package/react/hoc/hoc-utils.js +1 -1
- package/react/hoc/hoc.cjs.js +5 -2
- package/react/hoc/hoc.cjs.js.map +1 -1
- package/react/hoc/index.d.ts.map +1 -1
- package/react/hoc/index.js +2 -0
- package/react/hoc/index.js.map +1 -1
- package/react/hoc/withApollo.js +1 -1
- package/react/hooks/hooks.cjs.js +4 -1
- package/react/hooks/hooks.cjs.js.map +1 -1
- package/react/hooks/index.d.ts.map +1 -1
- package/react/hooks/index.js +2 -0
- package/react/hooks/index.js.map +1 -1
- package/react/hooks/useApolloClient.js +1 -1
- package/react/index.d.ts.map +1 -1
- package/react/index.js +2 -3
- package/react/index.js.map +1 -1
- package/react/parser/index.d.ts.map +1 -1
- package/react/parser/index.js +6 -4
- package/react/parser/index.js.map +1 -1
- package/react/parser/parser.cjs.js +6 -4
- package/react/parser/parser.cjs.js.map +1 -1
- package/react/react.cjs.js +1 -2
- package/react/react.cjs.js.map +1 -1
- package/testing/index.js +2 -3
- package/testing/index.js.map +1 -1
- package/testing/testing.cjs.js +3 -3
- package/testing/testing.cjs.js.map +1 -1
- package/utilities/globals/index.d.ts +1 -0
- package/utilities/globals/index.d.ts.map +1 -1
- package/utilities/globals/index.js +4 -0
- package/utilities/globals/index.js.map +1 -1
- package/utilities/graphql/directives.js +4 -4
- package/utilities/graphql/fragments.js +3 -3
- package/utilities/graphql/getFromAST.js +8 -8
- package/utilities/graphql/storeUtils.js +1 -1
- package/utilities/index.d.ts +3 -2
- package/utilities/index.d.ts.map +1 -1
- package/utilities/index.js +4 -4
- package/utilities/index.js.map +1 -1
- package/utilities/observables/Concast.js +1 -1
- package/utilities/observables/Concast.js.map +1 -1
- package/utilities/testing/mocking/mockLink.js +1 -1
- package/utilities/utilities.cjs.js +23 -18
- package/utilities/utilities.cjs.js.map +1 -1
- package/version.js +1 -1
- package/apollo-client.cjs.min.js +0 -1
package/utilities/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utilities/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utilities/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAC1C,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wB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AACtC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,wBAAwB,CAAC;AACvC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,uBAAuB,CAAC;AACtC,cAAc,8BAA8B,CAAC;AAE7C,cAAc,uBAAuB,CAAC"}
|
package/utilities/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export { DEV };
|
|
1
|
+
import { DEV, checkDEV } from "./globals/index.js";
|
|
2
|
+
export { DEV, checkDEV };
|
|
3
|
+
checkDEV();
|
|
5
4
|
export { shouldInclude, hasDirectives, hasClientExports, getDirectiveNames, getInclusionDirectives, } from "./graphql/directives.js";
|
|
6
5
|
export { createFragmentMap, getFragmentQueryDocument, getFragmentFromSelection, } from "./graphql/fragments.js";
|
|
7
6
|
export { checkDocument, getOperationDefinition, getOperationName, getFragmentDefinitions, getQueryDefinition, getFragmentDefinition, getMainDefinition, getDefaultValues, } from "./graphql/getFromAST.js";
|
|
@@ -12,6 +11,7 @@ export { Observable } from "./observables/Observable.js";
|
|
|
12
11
|
export * from "./common/mergeDeep.js";
|
|
13
12
|
export * from "./common/cloneDeep.js";
|
|
14
13
|
export * from "./common/maybeDeepFreeze.js";
|
|
14
|
+
export * from "./common/maybe.js";
|
|
15
15
|
export * from "./observables/iteration.js";
|
|
16
16
|
export * from "./observables/asyncMap.js";
|
|
17
17
|
export * from "./observables/Concast.js";
|
package/utilities/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utilities/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utilities/index.ts"],"names":[],"mappings":"AAAA,OAA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AiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,uBAAuB,CAAC;AACtC,cAAc,8BAA8B,CAAC;AAE7C,cAAc,uBAAuB,CAAC","sourcesContent":["import { DEV, checkDEV } from \"./globals\";\nexport { DEV, checkDEV }\ncheckDEV();\n\nexport {\n DirectiveInfo,\n InclusionDirectives,\n shouldInclude,\n hasDirectives,\n hasClientExports,\n getDirectiveNames,\n getInclusionDirectives,\n} from './graphql/directives';\n\nexport {\n FragmentMap,\n createFragmentMap,\n getFragmentQueryDocument,\n getFragmentFromSelection,\n} from './graphql/fragments';\n\nexport {\n checkDocument,\n getOperationDefinition,\n getOperationName,\n getFragmentDefinitions,\n getQueryDefinition,\n getFragmentDefinition,\n getMainDefinition,\n getDefaultValues,\n} from './graphql/getFromAST';\n\nexport {\n StoreObject,\n Reference,\n StoreValue,\n Directives,\n VariableValue,\n makeReference,\n isDocumentNode,\n isReference,\n isField,\n isInlineFragment,\n valueToObjectRepresentation,\n storeKeyNameFromField,\n argumentsObjectFromField,\n resultKeyNameFromField,\n getStoreKeyName,\n getTypenameFromResult,\n} from './graphql/storeUtils';\n\nexport {\n RemoveNodeConfig,\n GetNodeConfig,\n RemoveDirectiveConfig,\n GetDirectiveConfig,\n RemoveArgumentsConfig,\n GetFragmentSpreadConfig,\n RemoveFragmentSpreadConfig,\n RemoveFragmentDefinitionConfig,\n RemoveVariableDefinitionConfig,\n addTypenameToDocument,\n buildQueryFromSelectionSet,\n removeDirectivesFromDocument,\n removeConnectionDirectiveFromDocument,\n removeArgumentsFromDocument,\n removeFragmentSpreadFromDocument,\n removeClientSetsFromDocument,\n} from './graphql/transform';\n\nexport {\n concatPagination,\n offsetLimitPagination,\n relayStylePagination,\n} from './policies/pagination';\n\nexport {\n Observable,\n Observer,\n ObservableSubscription\n} from './observables/Observable';\n\nexport * from './common/mergeDeep';\nexport * from './common/cloneDeep';\nexport * from './common/maybeDeepFreeze';\nexport * from './common/maybe';\nexport * from './observables/iteration';\nexport * from './observables/asyncMap';\nexport * from './observables/Concast';\nexport * from './observables/subclassing';\nexport * from './common/arrays';\nexport * from './common/objects';\nexport * from './common/errorHandling';\nexport * from './common/canUse';\nexport * from './common/compact';\nexport * from './common/makeUniqueId';\nexport * from './common/stringifyForDisplay';\n\nexport * from './types/IsStrictlyAny';\n"]}
|
|
@@ -29,7 +29,7 @@ var Concast = (function (_super) {
|
|
|
29
29
|
var sub = _this.sub;
|
|
30
30
|
if (sub !== null) {
|
|
31
31
|
if (sub)
|
|
32
|
-
|
|
32
|
+
setTimeout(function () { return sub.unsubscribe(); });
|
|
33
33
|
_this.sub = null;
|
|
34
34
|
_this.latest = ["error", error];
|
|
35
35
|
_this.reject(error);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Concast.js","sourceRoot":"","sources":["../../../src/utilities/observables/Concast.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAgD,MAAM,cAAc,CAAC;AACxF,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAItD,SAAS,aAAa,CAAI,KAAoB;IAC5C,OAAO,KAAK,IAAI,OAAQ,KAAa,CAAC,IAAI,KAAK,UAAU,CAAC;AAC5D,CAAC;AAoCD;IAAgC,2BAAa;IAc3C,iBAAY,OAA8D;QAA1E,YACE,kBAAM,UAAA,QAAQ;YACZ,KAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;YAC3B,OAAO,cAAM,OAAA,KAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,EAA7B,CAA6B,CAAC;QAC7C,CAAC,CAAC,SAsBH;QApCO,eAAS,GAAG,IAAI,GAAG,EAAe,CAAC;QA4EnC,cAAQ,GAAG,CAAC,CAAC;QA+BL,aAAO,GAAG,IAAI,OAAO,CAAI,UAAC,OAAO,EAAE,MAAM;YACvD,KAAI,CAAC,OAAO,GAAG,OAAO,CAAC;YACvB,K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G;YACX,IAAI,CAAC,MAAM,EAAE;gBACX,MAAM,GAAG,IAAI,CAAC;gBAId,KAAI,CAAC,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;gBAChC,QAAQ,EAAE,CAAC;aACZ;QACH,CAAC,CAAA;QACD,IAAM,QAAQ,GAAG;YACf,IAAI,EAAE,IAAI;YACV,KAAK,EAAE,IAAI;YACX,QAAQ,EAAE,IAAI;SACf,CAAC;QACF,IAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC;QAC5B,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;QAI3B,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC;IACxB,CAAC;IAQH,cAAC;AAAD,CAAC,AA1MD,CAAgC,UAAU,GA0MzC;;AAID,qBAAqB,CAAC,OAAO,CAAC,CAAC","sourcesContent":["import { Observable, Observer, ObservableSubscription, Subscriber } from \"./Observable\";\nimport { iterateObserversSafely } from \"./iteration\";\nimport { fixObservableSubclass } from \"./subclassing\";\n\ntype MaybeAsync<T> = T | PromiseLike<T>;\n\nfunction isPromiseLike<T>(value: MaybeAsync<T>): value is PromiseLike<T> {\n return value && typeof (value as any).then === \"function\";\n}\n\n// Any individual Source<T> can be an Observable<T> or a promise for one.\ntype Source<T> = MaybeAsync<Observable<T>>;\n\nexport type ConcastSourcesIterable<T> = Iterable<Source<T>>;\n\n// A Concast<T> observable concatenates the given sources into a single\n// non-overlapping sequence of Ts, automatically unwrapping any promises,\n// and broadcasts the T elements of that sequence to any number of\n// subscribers, all without creating a bunch of intermediary Observable\n// wrapper objects.\n//\n// Even though any number of observers can subscribe to the Concast, each\n// source observable is guaranteed to receive at most one subscribe call,\n// and the results are multicast to all observers.\n//\n// In addition to broadcasting every next/error message to this.observers,\n// the Concast stores the most recent message using this.latest, so any\n// new observers can immediately receive the latest message, even if it\n// was originally delivered in the past. This behavior means we can assume\n// every active observer in this.observers has received the same most\n// recent message.\n//\n// With the exception of this.latest replay, a Concast is a \"hot\"\n// observable in the sense that it does not replay past results from the\n// beginning of time for each new observer.\n//\n// Could we have used some existing RxJS class instead? Concast<T> is\n// similar to a BehaviorSubject<T>, because it is multicast and redelivers\n// the latest next/error message to new subscribers. Unlike Subject<T>,\n// Concast<T> does not expose an Observer<T> interface (this.handlers is\n// intentionally private), since Concast<T> gets its inputs from the\n// concatenated sources. If we ever switch to RxJS, there may be some\n// value in reusing their code, but for now we use zen-observable, which\n// does not contain any Subject implementations.\nexport class Concast<T> extends Observable<T> {\n // Active observers receiving broadcast messages. Thanks to this.latest,\n // we can assume all observers in this Set have received the same most\n // recent message, though possibly at different times in the past.\n private observers = new Set<Observer<T>>();\n\n // This property starts off undefined to indicate the initial\n // subscription has not yet begun, then points to each source\n // subscription in turn, and finally becomes null after the sources have\n // been exhausted. After that, it stays null.\n private sub?: ObservableSubscription | null;\n\n // Not only can the individual elements of the iterable be promises, but\n // also the iterable itself can be wrapped in a promise.\n constructor(sources: MaybeAsync<ConcastSourcesIterable<T>> | Subscriber<T>) {\n super(observer => {\n this.addObserver(observer);\n return () => this.removeObserver(observer);\n });\n\n // Suppress rejection warnings for this.promise, since it's perfectly\n // acceptable to pay no attention to this.promise if you're consuming\n // the results through the normal observable API.\n this.promise.catch(_ => {});\n\n // If someone accidentally tries to create a Concast using a subscriber\n // function, recover by creating an Observable from that subscriber and\n // using it as the source.\n if (typeof sources === \"function\") {\n sources = [new Observable(sources)];\n }\n\n if (isPromiseLike(sources)) {\n sources.then(\n iterable => this.start(iterable),\n this.handlers.error,\n );\n } else {\n this.start(sources);\n }\n }\n\n // A consumable array of source observables, incrementally consumed\n // each time this.handlers.complete is called.\n private sources: Source<T>[];\n\n private start(sources: ConcastSourcesIterable<T>) {\n if (this.sub !== void 0) return;\n\n // In practice, sources is most often simply an Array of observables.\n // TODO Consider using sources[Symbol.iterator]() to take advantage\n // of the laziness of non-Array iterables.\n this.sources = Array.from(sources);\n\n // Calling this.handlers.complete() kicks off consumption of the first\n // source observable. It's tempting to do this step lazily in\n // addObserver, but this.promise can be accessed without calling\n // addObserver, so consumption needs to begin eagerly.\n this.handlers.complete();\n }\n\n private deliverLastMessage(observer: Observer<T>) {\n if (this.latest) {\n const nextOrError = this.latest[0];\n const method = observer[nextOrError];\n if (method) {\n method.call(observer, this.latest[1]);\n }\n // If the subscription is already closed, and the last message was\n // a 'next' message, simulate delivery of the final 'complete'\n // message again.\n if (this.sub === null &&\n nextOrError === \"next\" &&\n observer.complete) {\n observer.complete();\n }\n }\n }\n\n // Note: cleanup observers do not count towards this total.\n private addCount = 0;\n\n public addObserver(observer: Observer<T>) {\n if (!this.observers.has(observer)) {\n // Immediately deliver the most recent message, so we can always\n // be sure all observers have the latest information.\n this.deliverLastMessage(observer);\n this.observers.add(observer);\n ++this.addCount;\n }\n }\n\n public removeObserver(\n observer: Observer<T>,\n quietly?: boolean,\n ) {\n if (this.observers.delete(observer) &&\n --this.addCount < 1 &&\n !quietly) {\n // In case there are still any cleanup observers in this.observers,\n // and no error or completion has been broadcast yet, make sure\n // those observers receive an error that terminates them.\n this.handlers.error(new Error(\"Observable cancelled prematurely\"));\n }\n }\n\n // Any Concast object can be trivially converted to a Promise, without\n // having to create a new wrapper Observable. This promise provides an\n // easy way to observe the final state of the Concast.\n private resolve: (result?: T | PromiseLike<T>) => void;\n private reject: (reason: any) => void;\n public readonly promise = new Promise<T>((resolve, reject) => {\n this.resolve = resolve;\n this.reject = reject;\n });\n\n // Name and argument of the most recently invoked observer method, used\n // to deliver latest results immediately to new observers.\n private latest?: [\"next\" | \"error\", any];\n\n // Bound handler functions that can be reused for every internal\n // subscription.\n private handlers = {\n next: (result: T) => {\n if (this.sub !== null) {\n this.latest = [\"next\", result];\n iterateObserversSafely(this.observers, \"next\", result);\n }\n },\n\n error: (error: any) => {\n const { sub } = this;\n if (sub !== null) {\n // Delay unsubscribing from the underlying subscription slightly,\n // so that immediately subscribing another observer can keep the\n // subscription active.\n if (sub) Promise.resolve().then(() => sub.unsubscribe());\n this.sub = null;\n this.latest = [\"error\", error];\n this.reject(error);\n iterateObserversSafely(this.observers, \"error\", error);\n }\n },\n\n complete: () => {\n if (this.sub !== null) {\n const value = this.sources.shift();\n if (!value) {\n this.sub = null;\n if (this.latest &&\n this.latest[0] === \"next\") {\n this.resolve(this.latest[1]);\n } else {\n this.resolve();\n }\n // We do not store this.latest = [\"complete\"], because doing so\n // discards useful information about the previous next (or\n // error) message. Instead, if new observers subscribe after\n // this Concast has completed, they will receive the final\n // 'next' message (unless there was an error) immediately\n // followed by a 'complete' message (see addObserver).\n iterateObserversSafely(this.observers, \"complete\");\n } else if (isPromiseLike(value)) {\n value.then(obs => this.sub = obs.subscribe(this.handlers));\n } else {\n this.sub = value.subscribe(this.handlers);\n }\n }\n },\n };\n\n public cleanup(callback: () => any) {\n let called = false;\n const once = () => {\n if (!called) {\n called = true;\n // Removing a cleanup observer should not unsubscribe from the\n // underlying Observable, so the only removeObserver behavior we\n // need here is to delete observer from this.observers.\n this.observers.delete(observer);\n callback();\n }\n }\n const observer = {\n next: once,\n error: once,\n complete: once,\n };\n const count = this.addCount;\n this.addObserver(observer);\n // Normally addObserver increments this.addCount, but we can \"hide\"\n // cleanup observers by restoring this.addCount to its previous value\n // after adding any cleanup observer.\n this.addCount = count;\n }\n\n // A public way to abort observation and broadcast.\n public cancel = (reason: any) => {\n this.reject(reason);\n this.sources = [];\n this.handlers.complete();\n }\n}\n\n// Necessary because the Concast constructor has a different signature\n// than the Observable constructor.\nfixObservableSubclass(Concast);\n"]}
|
|
1
|
+
{"version":3,"file":"Concast.js","sourceRoot":"","sources":["../../../src/utilities/observables/Concast.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAgD,MAAM,cAAc,CAAC;AACxF,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAItD,SAAS,aAAa,CAAI,KAAoB;IAC5C,OAAO,KAAK,IAAI,OAAQ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C7B,EAAE,IAAI,CAAC,QAAQ,CAAC;SACjB;IACH,CAAC;IAEM,gCAAc,GAArB,UACE,QAAqB,EACrB,OAAiB;QAEjB,IAAI,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC;YAC/B,EAAE,IAAI,CAAC,QAAQ,GAAG,CAAC;YACnB,CAAC,OAAO,EAAE;YAIZ,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC,CAAC;SACpE;IACH,CAAC;IAmEM,yBAAO,GAAd,UAAe,QAAmB;QAAlC,iBAuBC;QAtBC,IAAI,MAAM,GAAG,KAAK,CAAC;QACnB,IAAM,IAAI,GAAG;YACX,IAAI,CAAC,MAAM,EAAE;gBACX,MAAM,GAAG,IAAI,CAAC;gBAId,KAAI,CAAC,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;gBAChC,QAAQ,EAAE,CAAC;aACZ;QACH,CAAC,CAAA;QACD,IAAM,QAAQ,GAAG;YACf,IAAI,EAAE,IAAI;YACV,KAAK,EAAE,IAAI;YACX,QAAQ,EAAE,IAAI;SACf,CAAC;QACF,IAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC;QAC5B,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;QAI3B,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC;IACxB,CAAC;IAQH,cAAC;AAAD,CAAC,AA1MD,CAAgC,UAAU,GA0MzC;;AAID,qBAAqB,CAAC,OAAO,CAAC,CAAC","sourcesContent":["import { Observable, Observer, ObservableSubscription, Subscriber } from \"./Observable\";\nimport { iterateObserversSafely } from \"./iteration\";\nimport { fixObservableSubclass } from \"./subclassing\";\n\ntype MaybeAsync<T> = T | PromiseLike<T>;\n\nfunction isPromiseLike<T>(value: MaybeAsync<T>): value is PromiseLike<T> {\n return value && typeof (value as any).then === \"function\";\n}\n\n// Any individual Source<T> can be an Observable<T> or a promise for one.\ntype Source<T> = MaybeAsync<Observable<T>>;\n\nexport type ConcastSourcesIterable<T> = Iterable<Source<T>>;\n\n// A Concast<T> observable concatenates the given sources into a single\n// non-overlapping sequence of Ts, automatically unwrapping any promises,\n// and broadcasts the T elements of that sequence to any number of\n// subscribers, all without creating a bunch of intermediary Observable\n// wrapper objects.\n//\n// Even though any number of observers can subscribe to the Concast, each\n// source observable is guaranteed to receive at most one subscribe call,\n// and the results are multicast to all observers.\n//\n// In addition to broadcasting every next/error message to this.observers,\n// the Concast stores the most recent message using this.latest, so any\n// new observers can immediately receive the latest message, even if it\n// was originally delivered in the past. This behavior means we can assume\n// every active observer in this.observers has received the same most\n// recent message.\n//\n// With the exception of this.latest replay, a Concast is a \"hot\"\n// observable in the sense that it does not replay past results from the\n// beginning of time for each new observer.\n//\n// Could we have used some existing RxJS class instead? Concast<T> is\n// similar to a BehaviorSubject<T>, because it is multicast and redelivers\n// the latest next/error message to new subscribers. Unlike Subject<T>,\n// Concast<T> does not expose an Observer<T> interface (this.handlers is\n// intentionally private), since Concast<T> gets its inputs from the\n// concatenated sources. If we ever switch to RxJS, there may be some\n// value in reusing their code, but for now we use zen-observable, which\n// does not contain any Subject implementations.\nexport class Concast<T> extends Observable<T> {\n // Active observers receiving broadcast messages. Thanks to this.latest,\n // we can assume all observers in this Set have received the same most\n // recent message, though possibly at different times in the past.\n private observers = new Set<Observer<T>>();\n\n // This property starts off undefined to indicate the initial\n // subscription has not yet begun, then points to each source\n // subscription in turn, and finally becomes null after the sources have\n // been exhausted. After that, it stays null.\n private sub?: ObservableSubscription | null;\n\n // Not only can the individual elements of the iterable be promises, but\n // also the iterable itself can be wrapped in a promise.\n constructor(sources: MaybeAsync<ConcastSourcesIterable<T>> | Subscriber<T>) {\n super(observer => {\n this.addObserver(observer);\n return () => this.removeObserver(observer);\n });\n\n // Suppress rejection warnings for this.promise, since it's perfectly\n // acceptable to pay no attention to this.promise if you're consuming\n // the results through the normal observable API.\n this.promise.catch(_ => {});\n\n // If someone accidentally tries to create a Concast using a subscriber\n // function, recover by creating an Observable from that subscriber and\n // using it as the source.\n if (typeof sources === \"function\") {\n sources = [new Observable(sources)];\n }\n\n if (isPromiseLike(sources)) {\n sources.then(\n iterable => this.start(iterable),\n this.handlers.error,\n );\n } else {\n this.start(sources);\n }\n }\n\n // A consumable array of source observables, incrementally consumed\n // each time this.handlers.complete is called.\n private sources: Source<T>[];\n\n private start(sources: ConcastSourcesIterable<T>) {\n if (this.sub !== void 0) return;\n\n // In practice, sources is most often simply an Array of observables.\n // TODO Consider using sources[Symbol.iterator]() to take advantage\n // of the laziness of non-Array iterables.\n this.sources = Array.from(sources);\n\n // Calling this.handlers.complete() kicks off consumption of the first\n // source observable. It's tempting to do this step lazily in\n // addObserver, but this.promise can be accessed without calling\n // addObserver, so consumption needs to begin eagerly.\n this.handlers.complete();\n }\n\n private deliverLastMessage(observer: Observer<T>) {\n if (this.latest) {\n const nextOrError = this.latest[0];\n const method = observer[nextOrError];\n if (method) {\n method.call(observer, this.latest[1]);\n }\n // If the subscription is already closed, and the last message was\n // a 'next' message, simulate delivery of the final 'complete'\n // message again.\n if (this.sub === null &&\n nextOrError === \"next\" &&\n observer.complete) {\n observer.complete();\n }\n }\n }\n\n // Note: cleanup observers do not count towards this total.\n private addCount = 0;\n\n public addObserver(observer: Observer<T>) {\n if (!this.observers.has(observer)) {\n // Immediately deliver the most recent message, so we can always\n // be sure all observers have the latest information.\n this.deliverLastMessage(observer);\n this.observers.add(observer);\n ++this.addCount;\n }\n }\n\n public removeObserver(\n observer: Observer<T>,\n quietly?: boolean,\n ) {\n if (this.observers.delete(observer) &&\n --this.addCount < 1 &&\n !quietly) {\n // In case there are still any cleanup observers in this.observers,\n // and no error or completion has been broadcast yet, make sure\n // those observers receive an error that terminates them.\n this.handlers.error(new Error(\"Observable cancelled prematurely\"));\n }\n }\n\n // Any Concast object can be trivially converted to a Promise, without\n // having to create a new wrapper Observable. This promise provides an\n // easy way to observe the final state of the Concast.\n private resolve: (result?: T | PromiseLike<T>) => void;\n private reject: (reason: any) => void;\n public readonly promise = new Promise<T>((resolve, reject) => {\n this.resolve = resolve;\n this.reject = reject;\n });\n\n // Name and argument of the most recently invoked observer method, used\n // to deliver latest results immediately to new observers.\n private latest?: [\"next\" | \"error\", any];\n\n // Bound handler functions that can be reused for every internal\n // subscription.\n private handlers = {\n next: (result: T) => {\n if (this.sub !== null) {\n this.latest = [\"next\", result];\n iterateObserversSafely(this.observers, \"next\", result);\n }\n },\n\n error: (error: any) => {\n const { sub } = this;\n if (sub !== null) {\n // Delay unsubscribing from the underlying subscription slightly,\n // so that immediately subscribing another observer can keep the\n // subscription active.\n if (sub) setTimeout(() => sub.unsubscribe());\n this.sub = null;\n this.latest = [\"error\", error];\n this.reject(error);\n iterateObserversSafely(this.observers, \"error\", error);\n }\n },\n\n complete: () => {\n if (this.sub !== null) {\n const value = this.sources.shift();\n if (!value) {\n this.sub = null;\n if (this.latest &&\n this.latest[0] === \"next\") {\n this.resolve(this.latest[1]);\n } else {\n this.resolve();\n }\n // We do not store this.latest = [\"complete\"], because doing so\n // discards useful information about the previous next (or\n // error) message. Instead, if new observers subscribe after\n // this Concast has completed, they will receive the final\n // 'next' message (unless there was an error) immediately\n // followed by a 'complete' message (see addObserver).\n iterateObserversSafely(this.observers, \"complete\");\n } else if (isPromiseLike(value)) {\n value.then(obs => this.sub = obs.subscribe(this.handlers));\n } else {\n this.sub = value.subscribe(this.handlers);\n }\n }\n },\n };\n\n public cleanup(callback: () => any) {\n let called = false;\n const once = () => {\n if (!called) {\n called = true;\n // Removing a cleanup observer should not unsubscribe from the\n // underlying Observable, so the only removeObserver behavior we\n // need here is to delete observer from this.observers.\n this.observers.delete(observer);\n callback();\n }\n }\n const observer = {\n next: once,\n error: once,\n complete: once,\n };\n const count = this.addCount;\n this.addObserver(observer);\n // Normally addObserver increments this.addCount, but we can \"hide\"\n // cleanup observers by restoring this.addCount to its previous value\n // after adding any cleanup observer.\n this.addCount = count;\n }\n\n // A public way to abort observation and broadcast.\n public cancel = (reason: any) => {\n this.reject(reason);\n this.sources = [];\n this.handlers.complete();\n }\n}\n\n// Necessary because the Concast constructor has a different signature\n// than the Observable constructor.\nfixObservableSubclass(Concast);\n"]}
|
|
@@ -102,7 +102,7 @@ var MockLink = (function (_super) {
|
|
|
102
102
|
MockLink.prototype.normalizeMockedResponse = function (mockedResponse) {
|
|
103
103
|
var newMockedResponse = cloneDeep(mockedResponse);
|
|
104
104
|
var queryWithoutConnection = removeConnectionDirectiveFromDocument(newMockedResponse.request.query);
|
|
105
|
-
__DEV__ ? invariant(queryWithoutConnection, "query is required") : invariant(queryWithoutConnection,
|
|
105
|
+
__DEV__ ? invariant(queryWithoutConnection, "query is required") : invariant(queryWithoutConnection, 55);
|
|
106
106
|
newMockedResponse.request.query = queryWithoutConnection;
|
|
107
107
|
var query = removeClientSetsFromDocument(newMockedResponse.request.query);
|
|
108
108
|
if (query) {
|
|
@@ -45,6 +45,9 @@ function removeTemporaryGlobals() {
|
|
|
45
45
|
return process$1.remove();
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
+
function checkDEV() {
|
|
49
|
+
__DEV__ ? tsInvariant.invariant("boolean" === typeof DEV, DEV) : tsInvariant.invariant("boolean" === typeof DEV, 38);
|
|
50
|
+
}
|
|
48
51
|
removeTemporaryGlobals();
|
|
49
52
|
|
|
50
53
|
function shouldInclude(_a, variables) {
|
|
@@ -57,7 +60,7 @@ function shouldInclude(_a, variables) {
|
|
|
57
60
|
var evaledValue = false;
|
|
58
61
|
if (ifArgument.value.kind === 'Variable') {
|
|
59
62
|
evaledValue = variables && variables[ifArgument.value.name.value];
|
|
60
|
-
__DEV__ ? tsInvariant.invariant(evaledValue !== void 0, "Invalid variable referenced in @" + directive.name.value + " directive.") : tsInvariant.invariant(evaledValue !== void 0,
|
|
63
|
+
__DEV__ ? tsInvariant.invariant(evaledValue !== void 0, "Invalid variable referenced in @" + directive.name.value + " directive.") : tsInvariant.invariant(evaledValue !== void 0, 39);
|
|
61
64
|
}
|
|
62
65
|
else {
|
|
63
66
|
evaledValue = ifArgument.value.value;
|
|
@@ -94,13 +97,13 @@ function getInclusionDirectives(directives) {
|
|
|
94
97
|
return;
|
|
95
98
|
var directiveArguments = directive.arguments;
|
|
96
99
|
var directiveName = directive.name.value;
|
|
97
|
-
__DEV__ ? tsInvariant.invariant(directiveArguments && directiveArguments.length === 1, "Incorrect number of arguments for the @" + directiveName + " directive.") : tsInvariant.invariant(directiveArguments && directiveArguments.length === 1,
|
|
100
|
+
__DEV__ ? tsInvariant.invariant(directiveArguments && directiveArguments.length === 1, "Incorrect number of arguments for the @" + directiveName + " directive.") : tsInvariant.invariant(directiveArguments && directiveArguments.length === 1, 40);
|
|
98
101
|
var ifArgument = directiveArguments[0];
|
|
99
|
-
__DEV__ ? tsInvariant.invariant(ifArgument.name && ifArgument.name.value === 'if', "Invalid argument for the @" + directiveName + " directive.") : tsInvariant.invariant(ifArgument.name && ifArgument.name.value === 'if',
|
|
102
|
+
__DEV__ ? tsInvariant.invariant(ifArgument.name && ifArgument.name.value === 'if', "Invalid argument for the @" + directiveName + " directive.") : tsInvariant.invariant(ifArgument.name && ifArgument.name.value === 'if', 41);
|
|
100
103
|
var ifValue = ifArgument.value;
|
|
101
104
|
__DEV__ ? tsInvariant.invariant(ifValue &&
|
|
102
105
|
(ifValue.kind === 'Variable' || ifValue.kind === 'BooleanValue'), "Argument for the @" + directiveName + " directive must be a variable or a boolean value.") : tsInvariant.invariant(ifValue &&
|
|
103
|
-
(ifValue.kind === 'Variable' || ifValue.kind === 'BooleanValue'),
|
|
106
|
+
(ifValue.kind === 'Variable' || ifValue.kind === 'BooleanValue'), 42);
|
|
104
107
|
result.push({ directive: directive, ifArgument: ifArgument });
|
|
105
108
|
});
|
|
106
109
|
}
|
|
@@ -113,14 +116,14 @@ function getFragmentQueryDocument(document, fragmentName) {
|
|
|
113
116
|
document.definitions.forEach(function (definition) {
|
|
114
117
|
if (definition.kind === 'OperationDefinition') {
|
|
115
118
|
throw __DEV__ ? new tsInvariant.InvariantError("Found a " + definition.operation + " operation" + (definition.name ? " named '" + definition.name.value + "'" : '') + ". " +
|
|
116
|
-
'No operations are allowed when using a fragment as a query. Only fragments are allowed.') : new tsInvariant.InvariantError(
|
|
119
|
+
'No operations are allowed when using a fragment as a query. Only fragments are allowed.') : new tsInvariant.InvariantError(43);
|
|
117
120
|
}
|
|
118
121
|
if (definition.kind === 'FragmentDefinition') {
|
|
119
122
|
fragments.push(definition);
|
|
120
123
|
}
|
|
121
124
|
});
|
|
122
125
|
if (typeof actualFragmentName === 'undefined') {
|
|
123
|
-
__DEV__ ? tsInvariant.invariant(fragments.length === 1, "Found " + fragments.length + " fragments. `fragmentName` must be provided when there is not exactly 1 fragment.") : tsInvariant.invariant(fragments.length === 1,
|
|
126
|
+
__DEV__ ? tsInvariant.invariant(fragments.length === 1, "Found " + fragments.length + " fragments. `fragmentName` must be provided when there is not exactly 1 fragment.") : tsInvariant.invariant(fragments.length === 1, 44);
|
|
124
127
|
actualFragmentName = fragments[0].name.value;
|
|
125
128
|
}
|
|
126
129
|
var query = tslib.__assign(tslib.__assign({}, document), { definitions: tslib.__spreadArray([
|
|
@@ -157,7 +160,7 @@ function getFragmentFromSelection(selection, fragmentMap) {
|
|
|
157
160
|
return selection;
|
|
158
161
|
case 'FragmentSpread': {
|
|
159
162
|
var fragment = fragmentMap && fragmentMap[selection.name.value];
|
|
160
|
-
__DEV__ ? tsInvariant.invariant(fragment, "No fragment named " + selection.name.value + ".") : tsInvariant.invariant(fragment,
|
|
163
|
+
__DEV__ ? tsInvariant.invariant(fragment, "No fragment named " + selection.name.value + ".") : tsInvariant.invariant(fragment, 45);
|
|
161
164
|
return fragment;
|
|
162
165
|
}
|
|
163
166
|
default:
|
|
@@ -241,7 +244,7 @@ function valueToObjectRepresentation(argObj, name, value, variables) {
|
|
|
241
244
|
else {
|
|
242
245
|
throw __DEV__ ? new tsInvariant.InvariantError("The inline argument \"" + name.value + "\" of kind \"" + value.kind + "\"" +
|
|
243
246
|
'is not supported. Use variables instead of inline arguments to ' +
|
|
244
|
-
'overcome this limitation.') : new tsInvariant.InvariantError(
|
|
247
|
+
'overcome this limitation.') : new tsInvariant.InvariantError(54);
|
|
245
248
|
}
|
|
246
249
|
}
|
|
247
250
|
function storeKeyNameFromField(field, variables) {
|
|
@@ -375,16 +378,16 @@ function isInlineFragment(selection) {
|
|
|
375
378
|
}
|
|
376
379
|
|
|
377
380
|
function checkDocument(doc) {
|
|
378
|
-
__DEV__ ? tsInvariant.invariant(doc && doc.kind === 'Document', "Expecting a parsed GraphQL document. Perhaps you need to wrap the query string in a \"gql\" tag? http://docs.apollostack.com/apollo-client/core.html#gql") : tsInvariant.invariant(doc && doc.kind === 'Document',
|
|
381
|
+
__DEV__ ? tsInvariant.invariant(doc && doc.kind === 'Document', "Expecting a parsed GraphQL document. Perhaps you need to wrap the query string in a \"gql\" tag? http://docs.apollostack.com/apollo-client/core.html#gql") : tsInvariant.invariant(doc && doc.kind === 'Document', 46);
|
|
379
382
|
var operations = doc.definitions
|
|
380
383
|
.filter(function (d) { return d.kind !== 'FragmentDefinition'; })
|
|
381
384
|
.map(function (definition) {
|
|
382
385
|
if (definition.kind !== 'OperationDefinition') {
|
|
383
|
-
throw __DEV__ ? new tsInvariant.InvariantError("Schema type definitions not allowed in queries. Found: \"" + definition.kind + "\"") : new tsInvariant.InvariantError(
|
|
386
|
+
throw __DEV__ ? new tsInvariant.InvariantError("Schema type definitions not allowed in queries. Found: \"" + definition.kind + "\"") : new tsInvariant.InvariantError(47);
|
|
384
387
|
}
|
|
385
388
|
return definition;
|
|
386
389
|
});
|
|
387
|
-
__DEV__ ? tsInvariant.invariant(operations.length <= 1, "Ambiguous GraphQL document: contains " + operations.length + " operations") : tsInvariant.invariant(operations.length <= 1,
|
|
390
|
+
__DEV__ ? tsInvariant.invariant(operations.length <= 1, "Ambiguous GraphQL document: contains " + operations.length + " operations") : tsInvariant.invariant(operations.length <= 1, 48);
|
|
388
391
|
return doc;
|
|
389
392
|
}
|
|
390
393
|
function getOperationDefinition(doc) {
|
|
@@ -403,14 +406,14 @@ function getFragmentDefinitions(doc) {
|
|
|
403
406
|
}
|
|
404
407
|
function getQueryDefinition(doc) {
|
|
405
408
|
var queryDef = getOperationDefinition(doc);
|
|
406
|
-
__DEV__ ? tsInvariant.invariant(queryDef && queryDef.operation === 'query', 'Must contain a query definition.') : tsInvariant.invariant(queryDef && queryDef.operation === 'query',
|
|
409
|
+
__DEV__ ? tsInvariant.invariant(queryDef && queryDef.operation === 'query', 'Must contain a query definition.') : tsInvariant.invariant(queryDef && queryDef.operation === 'query', 49);
|
|
407
410
|
return queryDef;
|
|
408
411
|
}
|
|
409
412
|
function getFragmentDefinition(doc) {
|
|
410
|
-
__DEV__ ? tsInvariant.invariant(doc.kind === 'Document', "Expecting a parsed GraphQL document. Perhaps you need to wrap the query string in a \"gql\" tag? http://docs.apollostack.com/apollo-client/core.html#gql") : tsInvariant.invariant(doc.kind === 'Document',
|
|
411
|
-
__DEV__ ? tsInvariant.invariant(doc.definitions.length <= 1, 'Fragment must have exactly one definition.') : tsInvariant.invariant(doc.definitions.length <= 1,
|
|
413
|
+
__DEV__ ? tsInvariant.invariant(doc.kind === 'Document', "Expecting a parsed GraphQL document. Perhaps you need to wrap the query string in a \"gql\" tag? http://docs.apollostack.com/apollo-client/core.html#gql") : tsInvariant.invariant(doc.kind === 'Document', 50);
|
|
414
|
+
__DEV__ ? tsInvariant.invariant(doc.definitions.length <= 1, 'Fragment must have exactly one definition.') : tsInvariant.invariant(doc.definitions.length <= 1, 51);
|
|
412
415
|
var fragmentDef = doc.definitions[0];
|
|
413
|
-
__DEV__ ? tsInvariant.invariant(fragmentDef.kind === 'FragmentDefinition', 'Must be a fragment definition.') : tsInvariant.invariant(fragmentDef.kind === 'FragmentDefinition',
|
|
416
|
+
__DEV__ ? tsInvariant.invariant(fragmentDef.kind === 'FragmentDefinition', 'Must be a fragment definition.') : tsInvariant.invariant(fragmentDef.kind === 'FragmentDefinition', 52);
|
|
414
417
|
return fragmentDef;
|
|
415
418
|
}
|
|
416
419
|
function getMainDefinition(queryDoc) {
|
|
@@ -433,7 +436,7 @@ function getMainDefinition(queryDoc) {
|
|
|
433
436
|
if (fragmentDefinition) {
|
|
434
437
|
return fragmentDefinition;
|
|
435
438
|
}
|
|
436
|
-
throw __DEV__ ? new tsInvariant.InvariantError('Expected a parsed GraphQL query with a query, mutation, subscription, or a fragment.') : new tsInvariant.InvariantError(
|
|
439
|
+
throw __DEV__ ? new tsInvariant.InvariantError('Expected a parsed GraphQL query with a query, mutation, subscription, or a fragment.') : new tsInvariant.InvariantError(53);
|
|
437
440
|
}
|
|
438
441
|
function getDefaultValues(definition) {
|
|
439
442
|
var defaultValues = Object.create(null);
|
|
@@ -1073,7 +1076,7 @@ var Concast = (function (_super) {
|
|
|
1073
1076
|
var sub = _this.sub;
|
|
1074
1077
|
if (sub !== null) {
|
|
1075
1078
|
if (sub)
|
|
1076
|
-
|
|
1079
|
+
setTimeout(function () { return sub.unsubscribe(); });
|
|
1077
1080
|
_this.sub = null;
|
|
1078
1081
|
_this.latest = ["error", error];
|
|
1079
1082
|
_this.reject(error);
|
|
@@ -1222,7 +1225,7 @@ function stringifyForDisplay(value) {
|
|
|
1222
1225
|
}).split(JSON.stringify(undefId)).join("<undefined>");
|
|
1223
1226
|
}
|
|
1224
1227
|
|
|
1225
|
-
|
|
1228
|
+
checkDEV();
|
|
1226
1229
|
|
|
1227
1230
|
exports.Observable = zenObservableTs.Observable;
|
|
1228
1231
|
exports.Concast = Concast;
|
|
@@ -1234,6 +1237,7 @@ exports.asyncMap = asyncMap;
|
|
|
1234
1237
|
exports.buildQueryFromSelectionSet = buildQueryFromSelectionSet;
|
|
1235
1238
|
exports.canUseWeakMap = canUseWeakMap;
|
|
1236
1239
|
exports.canUseWeakSet = canUseWeakSet;
|
|
1240
|
+
exports.checkDEV = checkDEV;
|
|
1237
1241
|
exports.checkDocument = checkDocument;
|
|
1238
1242
|
exports.cloneDeep = cloneDeep;
|
|
1239
1243
|
exports.compact = compact;
|
|
@@ -1265,6 +1269,7 @@ exports.isReference = isReference;
|
|
|
1265
1269
|
exports.iterateObserversSafely = iterateObserversSafely;
|
|
1266
1270
|
exports.makeReference = makeReference;
|
|
1267
1271
|
exports.makeUniqueId = makeUniqueId;
|
|
1272
|
+
exports.maybe = maybe;
|
|
1268
1273
|
exports.maybeDeepFreeze = maybeDeepFreeze;
|
|
1269
1274
|
exports.mergeDeep = mergeDeep;
|
|
1270
1275
|
exports.mergeDeepArray = mergeDeepArray;
|