@apollo/client 0.0.0-pr-10521-20230206180228
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/LICENSE +22 -0
- package/README.md +45 -0
- package/apollo-client.cjs +7614 -0
- package/apollo-client.cjs.map +1 -0
- package/apollo-client.min.cjs +1 -0
- package/cache/cache.cjs +2425 -0
- package/cache/cache.cjs.map +1 -0
- package/cache/cache.cjs.native.js +2425 -0
- package/cache/core/cache.d.ts +32 -0
- package/cache/core/cache.d.ts.map +1 -0
- package/cache/core/cache.js +84 -0
- package/cache/core/cache.js.map +1 -0
- package/cache/core/types/Cache.d.ts +55 -0
- package/cache/core/types/Cache.d.ts.map +1 -0
- package/cache/core/types/Cache.js +4 -0
- package/cache/core/types/Cache.js.map +1 -0
- package/cache/core/types/DataProxy.d.ts +52 -0
- package/cache/core/types/DataProxy.d.ts.map +1 -0
- package/cache/core/types/DataProxy.js +2 -0
- package/cache/core/types/DataProxy.js.map +1 -0
- package/cache/core/types/common.d.ts +47 -0
- package/cache/core/types/common.d.ts.map +1 -0
- package/cache/core/types/common.js +26 -0
- package/cache/core/types/common.js.map +1 -0
- package/cache/index.d.ts +15 -0
- package/cache/index.d.ts.map +1 -0
- package/cache/index.js +14 -0
- package/cache/index.js.map +1 -0
- package/cache/inmemory/__mocks__/optimism.d.ts +2 -0
- package/cache/inmemory/__mocks__/optimism.d.ts.map +1 -0
- package/cache/inmemory/__mocks__/optimism.js +14 -0
- package/cache/inmemory/__mocks__/optimism.js.map +1 -0
- package/cache/inmemory/entityStore.d.ts +83 -0
- package/cache/inmemory/entityStore.d.ts.map +1 -0
- package/cache/inmemory/entityStore.js +467 -0
- package/cache/inmemory/entityStore.js.map +1 -0
- package/cache/inmemory/fixPolyfills.d.ts +1 -0
- package/cache/inmemory/fixPolyfills.d.ts.map +1 -0
- package/cache/inmemory/fixPolyfills.js +1 -0
- package/cache/inmemory/fixPolyfills.js.map +1 -0
- package/cache/inmemory/fixPolyfills.native.d.ts +2 -0
- package/cache/inmemory/fixPolyfills.native.d.ts.map +1 -0
- package/cache/inmemory/fixPolyfills.native.js +48 -0
- package/cache/inmemory/fixPolyfills.native.js.map +1 -0
- package/cache/inmemory/fragmentRegistry.d.ts +8 -0
- package/cache/inmemory/fragmentRegistry.d.ts.map +1 -0
- package/cache/inmemory/fragmentRegistry.js +113 -0
- package/cache/inmemory/fragmentRegistry.js.map +1 -0
- package/cache/inmemory/helpers.d.ts +27 -0
- package/cache/inmemory/helpers.d.ts.map +1 -0
- package/cache/inmemory/helpers.js +85 -0
- package/cache/inmemory/helpers.js.map +1 -0
- package/cache/inmemory/inMemoryCache.d.ts +52 -0
- package/cache/inmemory/inMemoryCache.d.ts.map +1 -0
- package/cache/inmemory/inMemoryCache.js +316 -0
- package/cache/inmemory/inMemoryCache.js.map +1 -0
- package/cache/inmemory/key-extractor.d.ts +9 -0
- package/cache/inmemory/key-extractor.d.ts.map +1 -0
- package/cache/inmemory/key-extractor.js +118 -0
- package/cache/inmemory/key-extractor.js.map +1 -0
- package/cache/inmemory/object-canon.d.ts +17 -0
- package/cache/inmemory/object-canon.d.ts.map +1 -0
- package/cache/inmemory/object-canon.js +120 -0
- package/cache/inmemory/object-canon.js.map +1 -0
- package/cache/inmemory/policies.d.ts +96 -0
- package/cache/inmemory/policies.d.ts.map +1 -0
- package/cache/inmemory/policies.js +416 -0
- package/cache/inmemory/policies.js.map +1 -0
- package/cache/inmemory/reactiveVars.d.ts +18 -0
- package/cache/inmemory/reactiveVars.d.ts.map +1 -0
- package/cache/inmemory/reactiveVars.js +65 -0
- package/cache/inmemory/reactiveVars.js.map +1 -0
- package/cache/inmemory/readFromStore.d.ts +36 -0
- package/cache/inmemory/readFromStore.d.ts.map +1 -0
- package/cache/inmemory/readFromStore.js +267 -0
- package/cache/inmemory/readFromStore.js.map +1 -0
- package/cache/inmemory/types.d.ts +81 -0
- package/cache/inmemory/types.d.ts.map +1 -0
- package/cache/inmemory/types.js +4 -0
- package/cache/inmemory/types.js.map +1 -0
- package/cache/inmemory/writeToStore.d.ts +37 -0
- package/cache/inmemory/writeToStore.d.ts.map +1 -0
- package/cache/inmemory/writeToStore.js +394 -0
- package/cache/inmemory/writeToStore.js.map +1 -0
- package/cache/package.json +8 -0
- package/config/jest/setup.d.ts +2 -0
- package/config/jest/setup.d.ts.map +1 -0
- package/config/jest/setup.js +5 -0
- package/config/jest/setup.js.map +1 -0
- package/core/ApolloClient.d.ts +76 -0
- package/core/ApolloClient.d.ts.map +1 -0
- package/core/ApolloClient.js +240 -0
- package/core/ApolloClient.js.map +1 -0
- package/core/LocalState.d.ts +69 -0
- package/core/LocalState.d.ts.map +1 -0
- package/core/LocalState.js +321 -0
- package/core/LocalState.js.map +1 -0
- package/core/ObservableQuery.d.ts +74 -0
- package/core/ObservableQuery.d.ts.map +1 -0
- package/core/ObservableQuery.js +507 -0
- package/core/ObservableQuery.js.map +1 -0
- package/core/QueryInfo.d.ts +62 -0
- package/core/QueryInfo.d.ts.map +1 -0
- package/core/QueryInfo.js +287 -0
- package/core/QueryInfo.js.map +1 -0
- package/core/QueryManager.d.ts +120 -0
- package/core/QueryManager.d.ts.map +1 -0
- package/core/QueryManager.js +890 -0
- package/core/QueryManager.js.map +1 -0
- package/core/core.cjs +2349 -0
- package/core/core.cjs.map +1 -0
- package/core/core.cjs.native.js +2349 -0
- package/core/index.d.ts +17 -0
- package/core/index.d.ts.map +1 -0
- package/core/index.js +17 -0
- package/core/index.js.map +1 -0
- package/core/networkStatus.d.ts +11 -0
- package/core/networkStatus.d.ts.map +1 -0
- package/core/networkStatus.js +14 -0
- package/core/networkStatus.js.map +1 -0
- package/core/package.json +8 -0
- package/core/types.d.ts +74 -0
- package/core/types.d.ts.map +1 -0
- package/core/types.js +3 -0
- package/core/types.js.map +1 -0
- package/core/watchQueryOptions.d.ts +78 -0
- package/core/watchQueryOptions.d.ts.map +1 -0
- package/core/watchQueryOptions.js +2 -0
- package/core/watchQueryOptions.js.map +1 -0
- package/errors/errors.cjs +49 -0
- package/errors/errors.cjs.map +1 -0
- package/errors/errors.cjs.native.js +49 -0
- package/errors/index.d.ts +23 -0
- package/errors/index.d.ts.map +1 -0
- package/errors/index.js +42 -0
- package/errors/index.js.map +1 -0
- package/errors/package.json +8 -0
- package/index.d.ts +3 -0
- package/index.d.ts.map +1 -0
- package/index.js +3 -0
- package/index.js.map +1 -0
- package/invariantErrorCodes.js +339 -0
- package/link/batch/batch.cjs +159 -0
- package/link/batch/batch.cjs.map +1 -0
- package/link/batch/batch.cjs.native.js +159 -0
- package/link/batch/batchLink.d.ts +19 -0
- package/link/batch/batchLink.d.ts.map +1 -0
- package/link/batch/batchLink.js +31 -0
- package/link/batch/batchLink.js.map +1 -0
- package/link/batch/batching.d.ts +27 -0
- package/link/batch/batching.d.ts.map +1 -0
- package/link/batch/batching.js +125 -0
- package/link/batch/batching.js.map +1 -0
- package/link/batch/index.d.ts +2 -0
- package/link/batch/index.d.ts.map +1 -0
- package/link/batch/index.js +2 -0
- package/link/batch/index.js.map +1 -0
- package/link/batch/package.json +8 -0
- package/link/batch-http/batch-http.cjs +137 -0
- package/link/batch-http/batch-http.cjs.map +1 -0
- package/link/batch-http/batch-http.cjs.native.js +137 -0
- package/link/batch-http/batchHttpLink.d.ts +16 -0
- package/link/batch-http/batchHttpLink.d.ts.map +1 -0
- package/link/batch-http/batchHttpLink.js +131 -0
- package/link/batch-http/batchHttpLink.js.map +1 -0
- package/link/batch-http/index.d.ts +2 -0
- package/link/batch-http/index.d.ts.map +1 -0
- package/link/batch-http/index.js +2 -0
- package/link/batch-http/index.js.map +1 -0
- package/link/batch-http/package.json +8 -0
- package/link/context/context.cjs +38 -0
- package/link/context/context.cjs.map +1 -0
- package/link/context/context.cjs.native.js +38 -0
- package/link/context/index.d.ts +5 -0
- package/link/context/index.d.ts.map +1 -0
- package/link/context/index.js +31 -0
- package/link/context/index.js.map +1 -0
- package/link/context/package.json +8 -0
- package/link/core/ApolloLink.d.ts +16 -0
- package/link/core/ApolloLink.d.ts.map +1 -0
- package/link/core/ApolloLink.js +100 -0
- package/link/core/ApolloLink.js.map +1 -0
- package/link/core/concat.d.ts +3 -0
- package/link/core/concat.d.ts.map +1 -0
- package/link/core/concat.js +3 -0
- package/link/core/concat.js.map +1 -0
- package/link/core/core.cjs +121 -0
- package/link/core/core.cjs.map +1 -0
- package/link/core/core.cjs.native.js +121 -0
- package/link/core/empty.d.ts +3 -0
- package/link/core/empty.d.ts.map +1 -0
- package/link/core/empty.js +3 -0
- package/link/core/empty.js.map +1 -0
- package/link/core/execute.d.ts +3 -0
- package/link/core/execute.d.ts.map +1 -0
- package/link/core/execute.js +3 -0
- package/link/core/execute.js.map +1 -0
- package/link/core/from.d.ts +3 -0
- package/link/core/from.d.ts.map +1 -0
- package/link/core/from.js +3 -0
- package/link/core/from.js.map +1 -0
- package/link/core/index.d.ts +9 -0
- package/link/core/index.d.ts.map +1 -0
- package/link/core/index.js +9 -0
- package/link/core/index.js.map +1 -0
- package/link/core/package.json +8 -0
- package/link/core/split.d.ts +3 -0
- package/link/core/split.d.ts.map +1 -0
- package/link/core/split.js +3 -0
- package/link/core/split.js.map +1 -0
- package/link/core/types.d.ts +52 -0
- package/link/core/types.d.ts.map +1 -0
- package/link/core/types.js +2 -0
- package/link/core/types.js.map +1 -0
- package/link/error/error.cjs +90 -0
- package/link/error/error.cjs.map +1 -0
- package/link/error/error.cjs.native.js +90 -0
- package/link/error/index.d.ts +24 -0
- package/link/error/index.d.ts.map +1 -0
- package/link/error/index.js +83 -0
- package/link/error/index.js.map +1 -0
- package/link/error/package.json +8 -0
- package/link/http/HttpLink.d.ts +8 -0
- package/link/http/HttpLink.d.ts.map +1 -0
- package/link/http/HttpLink.js +15 -0
- package/link/http/HttpLink.js.map +1 -0
- package/link/http/checkFetcher.d.ts +2 -0
- package/link/http/checkFetcher.d.ts.map +1 -0
- package/link/http/checkFetcher.js +7 -0
- package/link/http/checkFetcher.js.map +1 -0
- package/link/http/createHttpLink.d.ts +4 -0
- package/link/http/createHttpLink.d.ts.map +1 -0
- package/link/http/createHttpLink.js +127 -0
- package/link/http/createHttpLink.js.map +1 -0
- package/link/http/createSignalIfSupported.d.ts +8 -0
- package/link/http/createSignalIfSupported.d.ts.map +1 -0
- package/link/http/createSignalIfSupported.js +8 -0
- package/link/http/createSignalIfSupported.js.map +1 -0
- package/link/http/http.cjs +593 -0
- package/link/http/http.cjs.map +1 -0
- package/link/http/http.cjs.native.js +593 -0
- package/link/http/index.d.ts +11 -0
- package/link/http/index.d.ts.map +1 -0
- package/link/http/index.js +11 -0
- package/link/http/index.js.map +1 -0
- package/link/http/iterators/async.d.ts +2 -0
- package/link/http/iterators/async.d.ts.map +1 -0
- package/link/http/iterators/async.js +14 -0
- package/link/http/iterators/async.js.map +1 -0
- package/link/http/iterators/nodeStream.d.ts +4 -0
- package/link/http/iterators/nodeStream.d.ts.map +1 -0
- package/link/http/iterators/nodeStream.js +71 -0
- package/link/http/iterators/nodeStream.js.map +1 -0
- package/link/http/iterators/promise.d.ts +2 -0
- package/link/http/iterators/promise.d.ts.map +1 -0
- package/link/http/iterators/promise.js +28 -0
- package/link/http/iterators/promise.js.map +1 -0
- package/link/http/iterators/reader.d.ts +2 -0
- package/link/http/iterators/reader.d.ts.map +1 -0
- package/link/http/iterators/reader.js +15 -0
- package/link/http/iterators/reader.js.map +1 -0
- package/link/http/package.json +8 -0
- package/link/http/parseAndCheckHttpResponse.d.ts +14 -0
- package/link/http/parseAndCheckHttpResponse.d.ts.map +1 -0
- package/link/http/parseAndCheckHttpResponse.js +148 -0
- package/link/http/parseAndCheckHttpResponse.js.map +1 -0
- package/link/http/responseIterator.d.ts +3 -0
- package/link/http/responseIterator.d.ts.map +1 -0
- package/link/http/responseIterator.js +23 -0
- package/link/http/responseIterator.js.map +1 -0
- package/link/http/rewriteURIForGET.d.ts +9 -0
- package/link/http/rewriteURIForGET.d.ts.map +1 -0
- package/link/http/rewriteURIForGET.js +43 -0
- package/link/http/rewriteURIForGET.js.map +1 -0
- package/link/http/selectHttpOptionsAndBody.d.ts +57 -0
- package/link/http/selectHttpOptionsAndBody.d.ts.map +1 -0
- package/link/http/selectHttpOptionsAndBody.js +78 -0
- package/link/http/selectHttpOptionsAndBody.js.map +1 -0
- package/link/http/selectURI.d.ts +3 -0
- package/link/http/selectURI.d.ts.map +1 -0
- package/link/http/selectURI.js +14 -0
- package/link/http/selectURI.js.map +1 -0
- package/link/http/serializeFetchParameter.d.ts +6 -0
- package/link/http/serializeFetchParameter.d.ts.map +1 -0
- package/link/http/serializeFetchParameter.js +14 -0
- package/link/http/serializeFetchParameter.js.map +1 -0
- package/link/persisted-queries/index.d.ts +31 -0
- package/link/persisted-queries/index.d.ts.map +1 -0
- package/link/persisted-queries/index.js +170 -0
- package/link/persisted-queries/index.js.map +1 -0
- package/link/persisted-queries/package.json +8 -0
- package/link/persisted-queries/persisted-queries.cjs +174 -0
- package/link/persisted-queries/persisted-queries.cjs.map +1 -0
- package/link/persisted-queries/persisted-queries.cjs.native.js +174 -0
- package/link/retry/delayFunction.d.ts +11 -0
- package/link/retry/delayFunction.d.ts.map +1 -0
- package/link/retry/delayFunction.js +12 -0
- package/link/retry/delayFunction.js.map +1 -0
- package/link/retry/index.d.ts +2 -0
- package/link/retry/index.d.ts.map +1 -0
- package/link/retry/index.js +2 -0
- package/link/retry/index.js.map +1 -0
- package/link/retry/package.json +8 -0
- package/link/retry/retry.cjs +170 -0
- package/link/retry/retry.cjs.map +1 -0
- package/link/retry/retry.cjs.native.js +170 -0
- package/link/retry/retryFunction.d.ts +10 -0
- package/link/retry/retryFunction.d.ts.map +1 -0
- package/link/retry/retryFunction.js +9 -0
- package/link/retry/retryFunction.js.map +1 -0
- package/link/retry/retryLink.d.ts +17 -0
- package/link/retry/retryLink.d.ts.map +1 -0
- package/link/retry/retryLink.js +145 -0
- package/link/retry/retryLink.js.map +1 -0
- package/link/schema/index.d.ts +22 -0
- package/link/schema/index.d.ts.map +1 -0
- package/link/schema/index.js +50 -0
- package/link/schema/index.js.map +1 -0
- package/link/schema/package.json +8 -0
- package/link/schema/schema.cjs +56 -0
- package/link/schema/schema.cjs.map +1 -0
- package/link/schema/schema.cjs.native.js +56 -0
- package/link/subscriptions/index.d.ts +9 -0
- package/link/subscriptions/index.d.ts.map +1 -0
- package/link/subscriptions/index.js +39 -0
- package/link/subscriptions/index.js.map +1 -0
- package/link/subscriptions/package.json +8 -0
- package/link/subscriptions/subscriptions.cjs +45 -0
- package/link/subscriptions/subscriptions.cjs.map +1 -0
- package/link/subscriptions/subscriptions.cjs.native.js +45 -0
- package/link/utils/createOperation.d.ts +3 -0
- package/link/utils/createOperation.d.ts.map +1 -0
- package/link/utils/createOperation.js +23 -0
- package/link/utils/createOperation.js.map +1 -0
- package/link/utils/fromError.d.ts +3 -0
- package/link/utils/fromError.d.ts.map +1 -0
- package/link/utils/fromError.js +7 -0
- package/link/utils/fromError.js.map +1 -0
- package/link/utils/fromPromise.d.ts +3 -0
- package/link/utils/fromPromise.d.ts.map +1 -0
- package/link/utils/fromPromise.js +12 -0
- package/link/utils/fromPromise.js.map +1 -0
- package/link/utils/index.d.ts +9 -0
- package/link/utils/index.d.ts.map +1 -0
- package/link/utils/index.js +9 -0
- package/link/utils/index.js.map +1 -0
- package/link/utils/package.json +8 -0
- package/link/utils/throwServerError.d.ts +7 -0
- package/link/utils/throwServerError.d.ts.map +1 -0
- package/link/utils/throwServerError.js +9 -0
- package/link/utils/throwServerError.js.map +1 -0
- package/link/utils/toPromise.d.ts +3 -0
- package/link/utils/toPromise.d.ts.map +1 -0
- package/link/utils/toPromise.js +19 -0
- package/link/utils/toPromise.js.map +1 -0
- package/link/utils/transformOperation.d.ts +3 -0
- package/link/utils/transformOperation.d.ts.map +1 -0
- package/link/utils/transformOperation.js +17 -0
- package/link/utils/transformOperation.js.map +1 -0
- package/link/utils/utils.cjs +115 -0
- package/link/utils/utils.cjs.map +1 -0
- package/link/utils/utils.cjs.native.js +115 -0
- package/link/utils/validateOperation.d.ts +3 -0
- package/link/utils/validateOperation.d.ts.map +1 -0
- package/link/utils/validateOperation.js +18 -0
- package/link/utils/validateOperation.js.map +1 -0
- package/link/ws/index.d.ts +17 -0
- package/link/ws/index.d.ts.map +1 -0
- package/link/ws/index.js +22 -0
- package/link/ws/index.js.map +1 -0
- package/link/ws/package.json +8 -0
- package/link/ws/ws.cjs +28 -0
- package/link/ws/ws.cjs.map +1 -0
- package/link/ws/ws.cjs.native.js +28 -0
- package/main.cjs +16 -0
- package/main.cjs.map +1 -0
- package/main.cjs.native.js +16 -0
- package/package.json +141 -0
- package/react/cache/SuspenseCache.d.ts +18 -0
- package/react/cache/SuspenseCache.d.ts.map +1 -0
- package/react/cache/SuspenseCache.js +49 -0
- package/react/cache/SuspenseCache.js.map +1 -0
- package/react/cache/index.d.ts +2 -0
- package/react/cache/index.d.ts.map +1 -0
- package/react/cache/index.js +2 -0
- package/react/cache/index.js.map +1 -0
- package/react/components/Mutation.d.ts +12 -0
- package/react/components/Mutation.d.ts.map +1 -0
- package/react/components/Mutation.js +22 -0
- package/react/components/Mutation.js.map +1 -0
- package/react/components/Query.d.ts +12 -0
- package/react/components/Query.d.ts.map +1 -0
- package/react/components/Query.js +23 -0
- package/react/components/Query.js.map +1 -0
- package/react/components/Subscription.d.ts +12 -0
- package/react/components/Subscription.d.ts.map +1 -0
- package/react/components/Subscription.js +17 -0
- package/react/components/Subscription.js.map +1 -0
- package/react/components/components.cjs +81 -0
- package/react/components/components.cjs.map +1 -0
- package/react/components/components.cjs.native.js +81 -0
- package/react/components/index.d.ts +5 -0
- package/react/components/index.d.ts.map +1 -0
- package/react/components/index.js +5 -0
- package/react/components/index.js.map +1 -0
- package/react/components/package.json +8 -0
- package/react/components/types.d.ts +18 -0
- package/react/components/types.d.ts.map +1 -0
- package/react/components/types.js +2 -0
- package/react/components/types.js.map +1 -0
- package/react/context/ApolloConsumer.d.ts +7 -0
- package/react/context/ApolloConsumer.d.ts.map +1 -0
- package/react/context/ApolloConsumer.js +12 -0
- package/react/context/ApolloConsumer.js.map +1 -0
- package/react/context/ApolloContext.d.ts +12 -0
- package/react/context/ApolloContext.d.ts.map +1 -0
- package/react/context/ApolloContext.js +20 -0
- package/react/context/ApolloContext.js.map +1 -0
- package/react/context/ApolloProvider.d.ts +10 -0
- package/react/context/ApolloProvider.d.ts.map +1 -0
- package/react/context/ApolloProvider.js +20 -0
- package/react/context/ApolloProvider.js.map +1 -0
- package/react/context/context.cjs +70 -0
- package/react/context/context.cjs.map +1 -0
- package/react/context/context.cjs.native.js +70 -0
- package/react/context/index.d.ts +5 -0
- package/react/context/index.d.ts.map +1 -0
- package/react/context/index.js +5 -0
- package/react/context/index.js.map +1 -0
- package/react/context/package.json +8 -0
- package/react/hoc/graphql.d.ts +6 -0
- package/react/hoc/graphql.d.ts.map +1 -0
- package/react/hoc/graphql.js +17 -0
- package/react/hoc/graphql.js.map +1 -0
- package/react/hoc/hoc-utils.d.ts +17 -0
- package/react/hoc/hoc-utils.d.ts.map +1 -0
- package/react/hoc/hoc-utils.js +47 -0
- package/react/hoc/hoc-utils.js.map +1 -0
- package/react/hoc/hoc.cjs +325 -0
- package/react/hoc/hoc.cjs.map +1 -0
- package/react/hoc/hoc.cjs.native.js +325 -0
- package/react/hoc/index.d.ts +8 -0
- package/react/hoc/index.d.ts.map +1 -0
- package/react/hoc/index.js +8 -0
- package/react/hoc/index.js.map +1 -0
- package/react/hoc/mutation-hoc.d.ts +7 -0
- package/react/hoc/mutation-hoc.d.ts.map +1 -0
- package/react/hoc/mutation-hoc.js +63 -0
- package/react/hoc/mutation-hoc.js.map +1 -0
- package/react/hoc/package.json +8 -0
- package/react/hoc/query-hoc.d.ts +5 -0
- package/react/hoc/query-hoc.d.ts.map +1 -0
- package/react/hoc/query-hoc.js +70 -0
- package/react/hoc/query-hoc.js.map +1 -0
- package/react/hoc/subscription-hoc.d.ts +5 -0
- package/react/hoc/subscription-hoc.d.ts.map +1 -0
- package/react/hoc/subscription-hoc.js +80 -0
- package/react/hoc/subscription-hoc.js.map +1 -0
- package/react/hoc/types.d.ts +43 -0
- package/react/hoc/types.d.ts.map +1 -0
- package/react/hoc/types.js +2 -0
- package/react/hoc/types.js.map +1 -0
- package/react/hoc/withApollo.d.ts +4 -0
- package/react/hoc/withApollo.d.ts.map +1 -0
- package/react/hoc/withApollo.js +45 -0
- package/react/hoc/withApollo.js.map +1 -0
- package/react/hooks/compareResults.d.ts +3 -0
- package/react/hooks/compareResults.d.ts.map +1 -0
- package/react/hooks/compareResults.js +63 -0
- package/react/hooks/compareResults.js.map +1 -0
- package/react/hooks/hooks.cjs +913 -0
- package/react/hooks/hooks.cjs.map +1 -0
- package/react/hooks/hooks.cjs.native.js +913 -0
- package/react/hooks/index.d.ts +10 -0
- package/react/hooks/index.d.ts.map +1 -0
- package/react/hooks/index.js +10 -0
- package/react/hooks/index.js.map +1 -0
- package/react/hooks/internal/index.d.ts +3 -0
- package/react/hooks/internal/index.d.ts.map +1 -0
- package/react/hooks/internal/index.js +3 -0
- package/react/hooks/internal/index.js.map +1 -0
- package/react/hooks/internal/useDeepMemo.d.ts +3 -0
- package/react/hooks/internal/useDeepMemo.d.ts.map +1 -0
- package/react/hooks/internal/useDeepMemo.js +10 -0
- package/react/hooks/internal/useDeepMemo.js.map +1 -0
- package/react/hooks/internal/useIsomorphicLayoutEffect.d.ts +3 -0
- package/react/hooks/internal/useIsomorphicLayoutEffect.d.ts.map +1 -0
- package/react/hooks/internal/useIsomorphicLayoutEffect.js +6 -0
- package/react/hooks/internal/useIsomorphicLayoutEffect.js.map +1 -0
- package/react/hooks/package.json +8 -0
- package/react/hooks/useApolloClient.d.ts +3 -0
- package/react/hooks/useApolloClient.d.ts.map +1 -0
- package/react/hooks/useApolloClient.js +12 -0
- package/react/hooks/useApolloClient.js.map +1 -0
- package/react/hooks/useFragment.d.ts +13 -0
- package/react/hooks/useFragment.d.ts.map +1 -0
- package/react/hooks/useFragment.js +39 -0
- package/react/hooks/useFragment.js.map +1 -0
- package/react/hooks/useLazyQuery.d.ts +6 -0
- package/react/hooks/useLazyQuery.d.ts.map +1 -0
- package/react/hooks/useLazyQuery.js +71 -0
- package/react/hooks/useLazyQuery.js.map +1 -0
- package/react/hooks/useMutation.d.ts +6 -0
- package/react/hooks/useMutation.d.ts.map +1 -0
- package/react/hooks/useMutation.js +100 -0
- package/react/hooks/useMutation.js.map +1 -0
- package/react/hooks/useQuery.d.ts +41 -0
- package/react/hooks/useQuery.d.ts.map +1 -0
- package/react/hooks/useQuery.js +302 -0
- package/react/hooks/useQuery.js.map +1 -0
- package/react/hooks/useReactiveVar.d.ts +3 -0
- package/react/hooks/useReactiveVar.d.ts.map +1 -0
- package/react/hooks/useReactiveVar.js +16 -0
- package/react/hooks/useReactiveVar.js.map +1 -0
- package/react/hooks/useSubscription.d.ts +6 -0
- package/react/hooks/useSubscription.d.ts.map +1 -0
- package/react/hooks/useSubscription.js +141 -0
- package/react/hooks/useSubscription.js.map +1 -0
- package/react/hooks/useSuspenseCache.d.ts +2 -0
- package/react/hooks/useSuspenseCache.d.ts.map +1 -0
- package/react/hooks/useSuspenseCache.js +10 -0
- package/react/hooks/useSuspenseCache.js.map +1 -0
- package/react/hooks/useSuspenseQuery.d.ts +12 -0
- package/react/hooks/useSuspenseQuery.d.ts.map +1 -0
- package/react/hooks/useSuspenseQuery.js +181 -0
- package/react/hooks/useSuspenseQuery.js.map +1 -0
- package/react/hooks/useSyncExternalStore.d.ts +4 -0
- package/react/hooks/useSyncExternalStore.d.ts.map +1 -0
- package/react/hooks/useSyncExternalStore.js +48 -0
- package/react/hooks/useSyncExternalStore.js.map +1 -0
- package/react/index.d.ts +7 -0
- package/react/index.d.ts.map +1 -0
- package/react/index.js +7 -0
- package/react/index.js.map +1 -0
- package/react/package.json +8 -0
- package/react/parser/index.d.ts +15 -0
- package/react/parser/index.d.ts.map +1 -0
- package/react/parser/index.js +94 -0
- package/react/parser/index.js.map +1 -0
- package/react/parser/package.json +8 -0
- package/react/parser/parser.cjs +103 -0
- package/react/parser/parser.cjs.map +1 -0
- package/react/parser/parser.cjs.native.js +103 -0
- package/react/react.cjs +69 -0
- package/react/react.cjs.map +1 -0
- package/react/react.cjs.native.js +69 -0
- package/react/ssr/RenderPromises.d.ts +22 -0
- package/react/ssr/RenderPromises.d.ts.map +1 -0
- package/react/ssr/RenderPromises.js +90 -0
- package/react/ssr/RenderPromises.js.map +1 -0
- package/react/ssr/getDataFromTree.d.ts +13 -0
- package/react/ssr/getDataFromTree.d.ts.map +1 -0
- package/react/ssr/getDataFromTree.js +32 -0
- package/react/ssr/getDataFromTree.js.map +1 -0
- package/react/ssr/index.d.ts +4 -0
- package/react/ssr/index.d.ts.map +1 -0
- package/react/ssr/index.js +4 -0
- package/react/ssr/index.js.map +1 -0
- package/react/ssr/package.json +8 -0
- package/react/ssr/renderToStringWithData.d.ts +3 -0
- package/react/ssr/renderToStringWithData.d.ts.map +1 -0
- package/react/ssr/renderToStringWithData.js +9 -0
- package/react/ssr/renderToStringWithData.js.map +1 -0
- package/react/ssr/ssr.cjs +151 -0
- package/react/ssr/ssr.cjs.map +1 -0
- package/react/ssr/ssr.cjs.native.js +151 -0
- package/react/types/types.d.ts +130 -0
- package/react/types/types.d.ts.map +1 -0
- package/react/types/types.js +2 -0
- package/react/types/types.js.map +1 -0
- package/testing/core/core.cjs +315 -0
- package/testing/core/core.cjs.map +1 -0
- package/testing/core/core.cjs.native.js +315 -0
- package/testing/core/index.d.ts +8 -0
- package/testing/core/index.d.ts.map +1 -0
- package/testing/core/index.js +8 -0
- package/testing/core/index.js.map +1 -0
- package/testing/core/itAsync.d.ts +6 -0
- package/testing/core/itAsync.d.ts.map +1 -0
- package/testing/core/itAsync.js +19 -0
- package/testing/core/itAsync.js.map +1 -0
- package/testing/core/mocking/mockClient.d.ts +5 -0
- package/testing/core/mocking/mockClient.d.ts.map +1 -0
- package/testing/core/mocking/mockClient.js +14 -0
- package/testing/core/mocking/mockClient.js.map +1 -0
- package/testing/core/mocking/mockFetch.d.ts +24 -0
- package/testing/core/mocking/mockFetch.d.ts.map +1 -0
- package/testing/core/mocking/mockFetch.js +83 -0
- package/testing/core/mocking/mockFetch.js.map +1 -0
- package/testing/core/mocking/mockLink.d.ts +28 -0
- package/testing/core/mocking/mockLink.d.ts.map +1 -0
- package/testing/core/mocking/mockLink.js +139 -0
- package/testing/core/mocking/mockLink.js.map +1 -0
- package/testing/core/mocking/mockQueryManager.d.ts +5 -0
- package/testing/core/mocking/mockQueryManager.d.ts.map +1 -0
- package/testing/core/mocking/mockQueryManager.js +14 -0
- package/testing/core/mocking/mockQueryManager.js.map +1 -0
- package/testing/core/mocking/mockSubscriptionLink.d.ts +24 -0
- package/testing/core/mocking/mockSubscriptionLink.d.ts.map +1 -0
- package/testing/core/mocking/mockSubscriptionLink.js +62 -0
- package/testing/core/mocking/mockSubscriptionLink.js.map +1 -0
- package/testing/core/mocking/mockWatchQuery.d.ts +5 -0
- package/testing/core/mocking/mockWatchQuery.d.ts.map +1 -0
- package/testing/core/mocking/mockWatchQuery.js +15 -0
- package/testing/core/mocking/mockWatchQuery.js.map +1 -0
- package/testing/core/observableToPromise.d.ts +15 -0
- package/testing/core/observableToPromise.d.ts.map +1 -0
- package/testing/core/observableToPromise.js +65 -0
- package/testing/core/observableToPromise.js.map +1 -0
- package/testing/core/package.json +8 -0
- package/testing/core/subscribeAndCount.d.ts +3 -0
- package/testing/core/subscribeAndCount.d.ts.map +1 -0
- package/testing/core/subscribeAndCount.js +16 -0
- package/testing/core/subscribeAndCount.js.map +1 -0
- package/testing/core/wait.d.ts +3 -0
- package/testing/core/wait.d.ts.map +1 -0
- package/testing/core/wait.js +16 -0
- package/testing/core/wait.js.map +1 -0
- package/testing/core/withConsoleSpy.d.ts +4 -0
- package/testing/core/withConsoleSpy.d.ts.map +1 -0
- package/testing/core/withConsoleSpy.js +39 -0
- package/testing/core/withConsoleSpy.js.map +1 -0
- package/testing/core/wrap.d.ts +4 -0
- package/testing/core/wrap.d.ts.map +1 -0
- package/testing/core/wrap.js +26 -0
- package/testing/core/wrap.js.map +1 -0
- package/testing/index.d.ts +4 -0
- package/testing/index.d.ts.map +1 -0
- package/testing/index.js +4 -0
- package/testing/index.js.map +1 -0
- package/testing/package.json +8 -0
- package/testing/react/MockedProvider.d.ts +30 -0
- package/testing/react/MockedProvider.d.ts.map +1 -0
- package/testing/react/MockedProvider.js +39 -0
- package/testing/react/MockedProvider.js.map +1 -0
- package/testing/testing.cjs +109 -0
- package/testing/testing.cjs.map +1 -0
- package/testing/testing.cjs.native.js +109 -0
- package/utilities/common/arrays.d.ts +2 -0
- package/utilities/common/arrays.d.ts.map +1 -0
- package/utilities/common/arrays.js +4 -0
- package/utilities/common/arrays.js.map +1 -0
- package/utilities/common/canUse.d.ts +7 -0
- package/utilities/common/canUse.d.ts.map +1 -0
- package/utilities/common/canUse.js +11 -0
- package/utilities/common/canUse.js.map +1 -0
- package/utilities/common/cloneDeep.d.ts +2 -0
- package/utilities/common/cloneDeep.d.ts.map +1 -0
- package/utilities/common/cloneDeep.js +33 -0
- package/utilities/common/cloneDeep.js.map +1 -0
- package/utilities/common/compact.d.ts +3 -0
- package/utilities/common/compact.d.ts.map +1 -0
- package/utilities/common/compact.js +19 -0
- package/utilities/common/compact.js.map +1 -0
- package/utilities/common/errorHandling.d.ts +4 -0
- package/utilities/common/errorHandling.d.ts.map +1 -0
- package/utilities/common/errorHandling.js +21 -0
- package/utilities/common/errorHandling.js.map +1 -0
- package/utilities/common/filterInPlace.d.ts +2 -0
- package/utilities/common/filterInPlace.d.ts.map +1 -0
- package/utilities/common/filterInPlace.js +11 -0
- package/utilities/common/filterInPlace.js.map +1 -0
- package/utilities/common/incrementalResult.d.ts +6 -0
- package/utilities/common/incrementalResult.d.ts.map +1 -0
- package/utilities/common/incrementalResult.js +32 -0
- package/utilities/common/incrementalResult.js.map +1 -0
- package/utilities/common/makeUniqueId.d.ts +2 -0
- package/utilities/common/makeUniqueId.d.ts.map +1 -0
- package/utilities/common/makeUniqueId.js +7 -0
- package/utilities/common/makeUniqueId.js.map +1 -0
- package/utilities/common/maybeDeepFreeze.d.ts +2 -0
- package/utilities/common/maybeDeepFreeze.d.ts.map +1 -0
- package/utilities/common/maybeDeepFreeze.js +34 -0
- package/utilities/common/maybeDeepFreeze.js.map +1 -0
- package/utilities/common/mergeDeep.d.ts +14 -0
- package/utilities/common/mergeDeep.d.ts.map +1 -0
- package/utilities/common/mergeDeep.js +76 -0
- package/utilities/common/mergeDeep.js.map +1 -0
- package/utilities/common/mergeOptions.d.ts +5 -0
- package/utilities/common/mergeOptions.d.ts.map +1 -0
- package/utilities/common/mergeOptions.js +8 -0
- package/utilities/common/mergeOptions.js.map +1 -0
- package/utilities/common/objects.d.ts +2 -0
- package/utilities/common/objects.d.ts.map +1 -0
- package/utilities/common/objects.js +4 -0
- package/utilities/common/objects.js.map +1 -0
- package/utilities/common/responseIterator.d.ts +10 -0
- package/utilities/common/responseIterator.d.ts.map +1 -0
- package/utilities/common/responseIterator.js +21 -0
- package/utilities/common/responseIterator.js.map +1 -0
- package/utilities/common/stringifyForDisplay.d.ts +2 -0
- package/utilities/common/stringifyForDisplay.d.ts.map +1 -0
- package/utilities/common/stringifyForDisplay.js +8 -0
- package/utilities/common/stringifyForDisplay.js.map +1 -0
- package/utilities/globals/DEV.d.ts +3 -0
- package/utilities/globals/DEV.d.ts.map +1 -0
- package/utilities/globals/DEV.js +9 -0
- package/utilities/globals/DEV.js.map +1 -0
- package/utilities/globals/fix-graphql.d.ts +2 -0
- package/utilities/globals/fix-graphql.d.ts.map +1 -0
- package/utilities/globals/fix-graphql.js +6 -0
- package/utilities/globals/fix-graphql.js.map +1 -0
- package/utilities/globals/global.d.ts +5 -0
- package/utilities/globals/global.d.ts.map +1 -0
- package/utilities/globals/global.js +6 -0
- package/utilities/globals/global.js.map +1 -0
- package/utilities/globals/globals.cjs +42 -0
- package/utilities/globals/globals.cjs.map +1 -0
- package/utilities/globals/globals.cjs.native.js +42 -0
- package/utilities/globals/index.d.ts +8 -0
- package/utilities/globals/index.d.ts.map +1 -0
- package/utilities/globals/index.js +10 -0
- package/utilities/globals/index.js.map +1 -0
- package/utilities/globals/maybe.d.ts +2 -0
- package/utilities/globals/maybe.d.ts.map +1 -0
- package/utilities/globals/maybe.js +7 -0
- package/utilities/globals/maybe.js.map +1 -0
- package/utilities/globals/package.json +8 -0
- package/utilities/graphql/directives.d.ts +18 -0
- package/utilities/graphql/directives.d.ts.map +1 -0
- package/utilities/graphql/directives.js +72 -0
- package/utilities/graphql/directives.js.map +1 -0
- package/utilities/graphql/fragments.d.ts +9 -0
- package/utilities/graphql/fragments.d.ts.map +1 -0
- package/utilities/graphql/fragments.js +64 -0
- package/utilities/graphql/fragments.js.map +1 -0
- package/utilities/graphql/getFromAST.d.ts +10 -0
- package/utilities/graphql/getFromAST.d.ts.map +1 -0
- package/utilities/graphql/getFromAST.js +76 -0
- package/utilities/graphql/getFromAST.js.map +1 -0
- package/utilities/graphql/storeUtils.d.ts +32 -0
- package/utilities/graphql/storeUtils.d.ts.map +1 -0
- package/utilities/graphql/storeUtils.js +208 -0
- package/utilities/graphql/storeUtils.js.map +1 -0
- package/utilities/graphql/transform.d.ts +27 -0
- package/utilities/graphql/transform.d.ts.map +1 -0
- package/utilities/graphql/transform.js +281 -0
- package/utilities/graphql/transform.js.map +1 -0
- package/utilities/index.d.ts +27 -0
- package/utilities/index.d.ts.map +1 -0
- package/utilities/index.js +27 -0
- package/utilities/index.js.map +1 -0
- package/utilities/observables/Concast.d.ts +27 -0
- package/utilities/observables/Concast.d.ts.map +1 -0
- package/utilities/observables/Concast.js +137 -0
- package/utilities/observables/Concast.js.map +1 -0
- package/utilities/observables/Observable.d.ts +5 -0
- package/utilities/observables/Observable.d.ts.map +1 -0
- package/utilities/observables/Observable.js +9 -0
- package/utilities/observables/Observable.js.map +1 -0
- package/utilities/observables/asyncMap.d.ts +3 -0
- package/utilities/observables/asyncMap.d.ts.map +1 -0
- package/utilities/observables/asyncMap.js +49 -0
- package/utilities/observables/asyncMap.js.map +1 -0
- package/utilities/observables/iteration.d.ts +3 -0
- package/utilities/observables/iteration.d.ts.map +1 -0
- package/utilities/observables/iteration.js +6 -0
- package/utilities/observables/iteration.js.map +1 -0
- package/utilities/observables/subclassing.d.ts +3 -0
- package/utilities/observables/subclassing.d.ts.map +1 -0
- package/utilities/observables/subclassing.js +13 -0
- package/utilities/observables/subclassing.js.map +1 -0
- package/utilities/package.json +8 -0
- package/utilities/policies/pagination.d.ts +28 -0
- package/utilities/policies/pagination.d.ts.map +1 -0
- package/utilities/policies/pagination.js +151 -0
- package/utilities/policies/pagination.js.map +1 -0
- package/utilities/types/IsStrictlyAny.d.ts +5 -0
- package/utilities/types/IsStrictlyAny.d.ts.map +1 -0
- package/utilities/types/IsStrictlyAny.js +2 -0
- package/utilities/types/IsStrictlyAny.js.map +1 -0
- package/utilities/utilities.cjs +1371 -0
- package/utilities/utilities.cjs.map +1 -0
- package/utilities/utilities.cjs.native.js +1371 -0
- package/version.d.ts +2 -0
- package/version.d.ts.map +1 -0
- package/version.js +2 -0
- package/version.js.map +1 -0
|
@@ -0,0 +1,325 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var globals = require('../../utilities/globals');
|
|
6
|
+
var parser = require('../parser');
|
|
7
|
+
var tslib = require('tslib');
|
|
8
|
+
var React = require('react');
|
|
9
|
+
var hoistNonReactStatics = require('hoist-non-react-statics');
|
|
10
|
+
var components = require('../components');
|
|
11
|
+
var context = require('../context');
|
|
12
|
+
|
|
13
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e["default"] : e; }
|
|
14
|
+
|
|
15
|
+
function _interopNamespace(e) {
|
|
16
|
+
if (e && e.__esModule) return e;
|
|
17
|
+
var n = Object.create(null);
|
|
18
|
+
if (e) {
|
|
19
|
+
for (var k in e) {
|
|
20
|
+
n[k] = e[k];
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
n["default"] = e;
|
|
24
|
+
return Object.freeze(n);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
28
|
+
var hoistNonReactStatics__default = /*#__PURE__*/_interopDefaultLegacy(hoistNonReactStatics);
|
|
29
|
+
|
|
30
|
+
var defaultMapPropsToOptions = function () { return ({}); };
|
|
31
|
+
var defaultMapPropsToSkip = function () { return false; };
|
|
32
|
+
function getDisplayName$1(WrappedComponent) {
|
|
33
|
+
return WrappedComponent.displayName || WrappedComponent.name || 'Component';
|
|
34
|
+
}
|
|
35
|
+
function calculateVariablesFromProps(operation, props) {
|
|
36
|
+
var variables = {};
|
|
37
|
+
for (var _i = 0, _a = operation.variables; _i < _a.length; _i++) {
|
|
38
|
+
var _b = _a[_i], variable = _b.variable, type = _b.type;
|
|
39
|
+
if (!variable.name || !variable.name.value)
|
|
40
|
+
continue;
|
|
41
|
+
var variableName = variable.name.value;
|
|
42
|
+
var variableProp = props[variableName];
|
|
43
|
+
if (typeof variableProp !== 'undefined') {
|
|
44
|
+
variables[variableName] = variableProp;
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
if (type.kind !== 'NonNullType') {
|
|
48
|
+
variables[variableName] = undefined;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return variables;
|
|
52
|
+
}
|
|
53
|
+
var GraphQLBase = (function (_super) {
|
|
54
|
+
tslib.__extends(GraphQLBase, _super);
|
|
55
|
+
function GraphQLBase(props) {
|
|
56
|
+
var _this = _super.call(this, props) || this;
|
|
57
|
+
_this.withRef = false;
|
|
58
|
+
_this.setWrappedInstance = _this.setWrappedInstance.bind(_this);
|
|
59
|
+
return _this;
|
|
60
|
+
}
|
|
61
|
+
GraphQLBase.prototype.getWrappedInstance = function () {
|
|
62
|
+
globals.__DEV__ ? globals.invariant(this.withRef, "To access the wrapped instance, you need to specify " +
|
|
63
|
+
"{ withRef: true } in the options") : globals.invariant(this.withRef, 30);
|
|
64
|
+
return this.wrappedInstance;
|
|
65
|
+
};
|
|
66
|
+
GraphQLBase.prototype.setWrappedInstance = function (ref) {
|
|
67
|
+
this.wrappedInstance = ref;
|
|
68
|
+
};
|
|
69
|
+
return GraphQLBase;
|
|
70
|
+
}(React__namespace.Component));
|
|
71
|
+
|
|
72
|
+
function withQuery(document, operationOptions) {
|
|
73
|
+
if (operationOptions === void 0) { operationOptions = {}; }
|
|
74
|
+
var operation = parser.parser(document);
|
|
75
|
+
var _a = operationOptions.options, options = _a === void 0 ? defaultMapPropsToOptions : _a, _b = operationOptions.skip, skip = _b === void 0 ? defaultMapPropsToSkip : _b, _c = operationOptions.alias, alias = _c === void 0 ? 'Apollo' : _c;
|
|
76
|
+
var mapPropsToOptions = options;
|
|
77
|
+
if (typeof mapPropsToOptions !== 'function') {
|
|
78
|
+
mapPropsToOptions = function () { return options; };
|
|
79
|
+
}
|
|
80
|
+
var mapPropsToSkip = skip;
|
|
81
|
+
if (typeof mapPropsToSkip !== 'function') {
|
|
82
|
+
mapPropsToSkip = function () { return skip; };
|
|
83
|
+
}
|
|
84
|
+
var lastResultProps;
|
|
85
|
+
return function (WrappedComponent) {
|
|
86
|
+
var graphQLDisplayName = "".concat(alias, "(").concat(getDisplayName$1(WrappedComponent), ")");
|
|
87
|
+
var GraphQL = (function (_super) {
|
|
88
|
+
tslib.__extends(GraphQL, _super);
|
|
89
|
+
function GraphQL() {
|
|
90
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
91
|
+
}
|
|
92
|
+
GraphQL.prototype.render = function () {
|
|
93
|
+
var _this = this;
|
|
94
|
+
var props = this.props;
|
|
95
|
+
var shouldSkip = mapPropsToSkip(props);
|
|
96
|
+
var opts = shouldSkip
|
|
97
|
+
? Object.create(null)
|
|
98
|
+
: tslib.__assign({}, mapPropsToOptions(props));
|
|
99
|
+
if (!shouldSkip && !opts.variables && operation.variables.length > 0) {
|
|
100
|
+
opts.variables = calculateVariablesFromProps(operation, props);
|
|
101
|
+
}
|
|
102
|
+
return (React__namespace.createElement(components.Query, tslib.__assign({}, opts, { displayName: graphQLDisplayName, skip: shouldSkip, query: document }), function (_a) {
|
|
103
|
+
var _b, _c;
|
|
104
|
+
_a.client; var data = _a.data, r = tslib.__rest(_a, ["client", "data"]);
|
|
105
|
+
if (operationOptions.withRef) {
|
|
106
|
+
_this.withRef = true;
|
|
107
|
+
props = Object.assign({}, props, {
|
|
108
|
+
ref: _this.setWrappedInstance
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
if (shouldSkip) {
|
|
112
|
+
return (React__namespace.createElement(WrappedComponent, tslib.__assign({}, props, {})));
|
|
113
|
+
}
|
|
114
|
+
var result = Object.assign(r, data || {});
|
|
115
|
+
var name = operationOptions.name || 'data';
|
|
116
|
+
var childProps = (_b = {}, _b[name] = result, _b);
|
|
117
|
+
if (operationOptions.props) {
|
|
118
|
+
var newResult = (_c = {},
|
|
119
|
+
_c[name] = result,
|
|
120
|
+
_c.ownProps = props,
|
|
121
|
+
_c);
|
|
122
|
+
lastResultProps = operationOptions.props(newResult, lastResultProps);
|
|
123
|
+
childProps = lastResultProps;
|
|
124
|
+
}
|
|
125
|
+
return (React__namespace.createElement(WrappedComponent, tslib.__assign({}, props, childProps)));
|
|
126
|
+
}));
|
|
127
|
+
};
|
|
128
|
+
GraphQL.displayName = graphQLDisplayName;
|
|
129
|
+
GraphQL.WrappedComponent = WrappedComponent;
|
|
130
|
+
return GraphQL;
|
|
131
|
+
}(GraphQLBase));
|
|
132
|
+
return hoistNonReactStatics__default(GraphQL, WrappedComponent, {});
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
function withMutation(document, operationOptions) {
|
|
137
|
+
if (operationOptions === void 0) { operationOptions = {}; }
|
|
138
|
+
var operation = parser.parser(document);
|
|
139
|
+
var _a = operationOptions.options, options = _a === void 0 ? defaultMapPropsToOptions : _a, _b = operationOptions.alias, alias = _b === void 0 ? 'Apollo' : _b;
|
|
140
|
+
var mapPropsToOptions = options;
|
|
141
|
+
if (typeof mapPropsToOptions !== 'function')
|
|
142
|
+
mapPropsToOptions = function () { return options; };
|
|
143
|
+
return function (WrappedComponent) {
|
|
144
|
+
var graphQLDisplayName = "".concat(alias, "(").concat(getDisplayName$1(WrappedComponent), ")");
|
|
145
|
+
var GraphQL = (function (_super) {
|
|
146
|
+
tslib.__extends(GraphQL, _super);
|
|
147
|
+
function GraphQL() {
|
|
148
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
149
|
+
}
|
|
150
|
+
GraphQL.prototype.render = function () {
|
|
151
|
+
var props = this.props;
|
|
152
|
+
var opts = mapPropsToOptions(props);
|
|
153
|
+
if (operationOptions.withRef) {
|
|
154
|
+
this.withRef = true;
|
|
155
|
+
props = Object.assign({}, props, {
|
|
156
|
+
ref: this.setWrappedInstance
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
if (!opts.variables && operation.variables.length > 0) {
|
|
160
|
+
opts.variables = calculateVariablesFromProps(operation, props);
|
|
161
|
+
}
|
|
162
|
+
return (React__namespace.createElement(components.Mutation, tslib.__assign({ ignoreResults: true }, opts, { mutation: document }), function (mutate, _a) {
|
|
163
|
+
var _b, _c;
|
|
164
|
+
var data = _a.data, r = tslib.__rest(_a, ["data"]);
|
|
165
|
+
var result = Object.assign(r, data || {});
|
|
166
|
+
var name = operationOptions.name || 'mutate';
|
|
167
|
+
var resultName = operationOptions.name
|
|
168
|
+
? "".concat(name, "Result")
|
|
169
|
+
: 'result';
|
|
170
|
+
var childProps = (_b = {},
|
|
171
|
+
_b[name] = mutate,
|
|
172
|
+
_b[resultName] = result,
|
|
173
|
+
_b);
|
|
174
|
+
if (operationOptions.props) {
|
|
175
|
+
var newResult = (_c = {},
|
|
176
|
+
_c[name] = mutate,
|
|
177
|
+
_c[resultName] = result,
|
|
178
|
+
_c.ownProps = props,
|
|
179
|
+
_c);
|
|
180
|
+
childProps = operationOptions.props(newResult);
|
|
181
|
+
}
|
|
182
|
+
return React__namespace.createElement(WrappedComponent, tslib.__assign({}, props, childProps));
|
|
183
|
+
}));
|
|
184
|
+
};
|
|
185
|
+
GraphQL.displayName = graphQLDisplayName;
|
|
186
|
+
GraphQL.WrappedComponent = WrappedComponent;
|
|
187
|
+
return GraphQL;
|
|
188
|
+
}(GraphQLBase));
|
|
189
|
+
return hoistNonReactStatics__default(GraphQL, WrappedComponent, {});
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
function withSubscription(document, operationOptions) {
|
|
194
|
+
if (operationOptions === void 0) { operationOptions = {}; }
|
|
195
|
+
var operation = parser.parser(document);
|
|
196
|
+
var _a = operationOptions.options, options = _a === void 0 ? defaultMapPropsToOptions : _a, _b = operationOptions.skip, skip = _b === void 0 ? defaultMapPropsToSkip : _b, _c = operationOptions.alias, alias = _c === void 0 ? 'Apollo' : _c, shouldResubscribe = operationOptions.shouldResubscribe;
|
|
197
|
+
var mapPropsToOptions = options;
|
|
198
|
+
if (typeof mapPropsToOptions !== 'function')
|
|
199
|
+
mapPropsToOptions = function () { return options; };
|
|
200
|
+
var mapPropsToSkip = skip;
|
|
201
|
+
if (typeof mapPropsToSkip !== 'function')
|
|
202
|
+
mapPropsToSkip = function () { return skip; };
|
|
203
|
+
var lastResultProps;
|
|
204
|
+
return function (WrappedComponent) {
|
|
205
|
+
var graphQLDisplayName = "".concat(alias, "(").concat(getDisplayName$1(WrappedComponent), ")");
|
|
206
|
+
var GraphQL = (function (_super) {
|
|
207
|
+
tslib.__extends(GraphQL, _super);
|
|
208
|
+
function GraphQL(props) {
|
|
209
|
+
var _this = _super.call(this, props) || this;
|
|
210
|
+
_this.state = { resubscribe: false };
|
|
211
|
+
return _this;
|
|
212
|
+
}
|
|
213
|
+
GraphQL.prototype.updateResubscribe = function (resubscribe) {
|
|
214
|
+
this.setState({ resubscribe: resubscribe });
|
|
215
|
+
};
|
|
216
|
+
GraphQL.prototype.componentDidUpdate = function (prevProps) {
|
|
217
|
+
var resubscribe = !!(shouldResubscribe &&
|
|
218
|
+
shouldResubscribe(prevProps, this.props));
|
|
219
|
+
if (this.state.resubscribe !== resubscribe) {
|
|
220
|
+
this.updateResubscribe(resubscribe);
|
|
221
|
+
}
|
|
222
|
+
};
|
|
223
|
+
GraphQL.prototype.render = function () {
|
|
224
|
+
var _this = this;
|
|
225
|
+
var props = this.props;
|
|
226
|
+
var shouldSkip = mapPropsToSkip(props);
|
|
227
|
+
var opts = shouldSkip
|
|
228
|
+
? Object.create(null)
|
|
229
|
+
: mapPropsToOptions(props);
|
|
230
|
+
if (!shouldSkip && !opts.variables && operation.variables.length > 0) {
|
|
231
|
+
opts.variables = calculateVariablesFromProps(operation, props);
|
|
232
|
+
}
|
|
233
|
+
return (React__namespace.createElement(components.Subscription, tslib.__assign({}, opts, { displayName: graphQLDisplayName, skip: shouldSkip, subscription: document, shouldResubscribe: this.state.resubscribe }), function (_a) {
|
|
234
|
+
var _b, _c;
|
|
235
|
+
var data = _a.data, r = tslib.__rest(_a, ["data"]);
|
|
236
|
+
if (operationOptions.withRef) {
|
|
237
|
+
_this.withRef = true;
|
|
238
|
+
props = Object.assign({}, props, {
|
|
239
|
+
ref: _this.setWrappedInstance
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
if (shouldSkip) {
|
|
243
|
+
return (React__namespace.createElement(WrappedComponent, tslib.__assign({}, props, {})));
|
|
244
|
+
}
|
|
245
|
+
var result = Object.assign(r, data || {});
|
|
246
|
+
var name = operationOptions.name || 'data';
|
|
247
|
+
var childProps = (_b = {}, _b[name] = result, _b);
|
|
248
|
+
if (operationOptions.props) {
|
|
249
|
+
var newResult = (_c = {},
|
|
250
|
+
_c[name] = result,
|
|
251
|
+
_c.ownProps = props,
|
|
252
|
+
_c);
|
|
253
|
+
lastResultProps = operationOptions.props(newResult, lastResultProps);
|
|
254
|
+
childProps = lastResultProps;
|
|
255
|
+
}
|
|
256
|
+
return (React__namespace.createElement(WrappedComponent, tslib.__assign({}, props, childProps)));
|
|
257
|
+
}));
|
|
258
|
+
};
|
|
259
|
+
GraphQL.displayName = graphQLDisplayName;
|
|
260
|
+
GraphQL.WrappedComponent = WrappedComponent;
|
|
261
|
+
return GraphQL;
|
|
262
|
+
}(GraphQLBase));
|
|
263
|
+
return hoistNonReactStatics__default(GraphQL, WrappedComponent, {});
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
function graphql(document, operationOptions) {
|
|
268
|
+
if (operationOptions === void 0) { operationOptions = {}; }
|
|
269
|
+
switch (parser.parser(document).type) {
|
|
270
|
+
case parser.DocumentType.Mutation:
|
|
271
|
+
return withMutation(document, operationOptions);
|
|
272
|
+
case parser.DocumentType.Subscription:
|
|
273
|
+
return withSubscription(document, operationOptions);
|
|
274
|
+
case parser.DocumentType.Query:
|
|
275
|
+
default:
|
|
276
|
+
return withQuery(document, operationOptions);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
function getDisplayName(WrappedComponent) {
|
|
281
|
+
return WrappedComponent.displayName || WrappedComponent.name || 'Component';
|
|
282
|
+
}
|
|
283
|
+
function withApollo(WrappedComponent, operationOptions) {
|
|
284
|
+
if (operationOptions === void 0) { operationOptions = {}; }
|
|
285
|
+
var withDisplayName = "withApollo(".concat(getDisplayName(WrappedComponent), ")");
|
|
286
|
+
var WithApollo = (function (_super) {
|
|
287
|
+
tslib.__extends(WithApollo, _super);
|
|
288
|
+
function WithApollo(props) {
|
|
289
|
+
var _this = _super.call(this, props) || this;
|
|
290
|
+
_this.setWrappedInstance = _this.setWrappedInstance.bind(_this);
|
|
291
|
+
return _this;
|
|
292
|
+
}
|
|
293
|
+
WithApollo.prototype.getWrappedInstance = function () {
|
|
294
|
+
globals.__DEV__ ? globals.invariant(operationOptions.withRef, "To access the wrapped instance, you need to specify " +
|
|
295
|
+
"{ withRef: true } in the options") : globals.invariant(operationOptions.withRef, 31);
|
|
296
|
+
return this.wrappedInstance;
|
|
297
|
+
};
|
|
298
|
+
WithApollo.prototype.setWrappedInstance = function (ref) {
|
|
299
|
+
this.wrappedInstance = ref;
|
|
300
|
+
};
|
|
301
|
+
WithApollo.prototype.render = function () {
|
|
302
|
+
var _this = this;
|
|
303
|
+
return (React__namespace.createElement(context.ApolloConsumer, null, function (client) {
|
|
304
|
+
var props = Object.assign({}, _this.props, {
|
|
305
|
+
client: client,
|
|
306
|
+
ref: operationOptions.withRef
|
|
307
|
+
? _this.setWrappedInstance
|
|
308
|
+
: undefined
|
|
309
|
+
});
|
|
310
|
+
return React__namespace.createElement(WrappedComponent, tslib.__assign({}, props));
|
|
311
|
+
}));
|
|
312
|
+
};
|
|
313
|
+
WithApollo.displayName = withDisplayName;
|
|
314
|
+
WithApollo.WrappedComponent = WrappedComponent;
|
|
315
|
+
return WithApollo;
|
|
316
|
+
}(React__namespace.Component));
|
|
317
|
+
return hoistNonReactStatics__default(WithApollo, WrappedComponent, {});
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
exports.graphql = graphql;
|
|
321
|
+
exports.withApollo = withApollo;
|
|
322
|
+
exports.withMutation = withMutation;
|
|
323
|
+
exports.withQuery = withQuery;
|
|
324
|
+
exports.withSubscription = withSubscription;
|
|
325
|
+
//# sourceMappingURL=hoc.cjs.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import '../../utilities/globals';
|
|
2
|
+
export { graphql } from './graphql';
|
|
3
|
+
export { withQuery } from './query-hoc';
|
|
4
|
+
export { withMutation } from './mutation-hoc';
|
|
5
|
+
export { withSubscription } from './subscription-hoc';
|
|
6
|
+
export { withApollo } from './withApollo';
|
|
7
|
+
export * from './types';
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/react/hoc/index.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAC;AAEjC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,cAAc,SAAS,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import "../../utilities/globals/index.js";
|
|
2
|
+
export { graphql } from "./graphql.js";
|
|
3
|
+
export { withQuery } from "./query-hoc.js";
|
|
4
|
+
export { withMutation } from "./mutation-hoc.js";
|
|
5
|
+
export { withSubscription } from "./subscription-hoc.js";
|
|
6
|
+
export { withApollo } from "./withApollo.js";
|
|
7
|
+
export * from "./types.js";
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/react/hoc/index.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAC;AAEjC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,cAAc,SAAS,CAAC","sourcesContent":["import '../../utilities/globals';\n\nexport { graphql } from './graphql';\n\nexport { withQuery } from './query-hoc';\nexport { withMutation } from './mutation-hoc';\nexport { withSubscription } from './subscription-hoc';\nexport { withApollo } from './withApollo';\n\nexport * from './types';\n"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { DocumentNode } from 'graphql';
|
|
3
|
+
import { DefaultContext, OperationVariables } from '../../core/types';
|
|
4
|
+
import { OperationOption, MutateProps } from './types';
|
|
5
|
+
import { ApolloCache } from '../../core';
|
|
6
|
+
export declare function withMutation<TProps extends TGraphQLVariables | {} = {}, TData extends Record<string, any> = {}, TGraphQLVariables extends OperationVariables = {}, TChildProps = MutateProps<TData, TGraphQLVariables>, TContext extends Record<string, any> = DefaultContext, TCache extends ApolloCache<any> = ApolloCache<any>>(document: DocumentNode, operationOptions?: OperationOption<TProps, TData, TGraphQLVariables, TChildProps>): (WrappedComponent: React.ComponentType<TProps & TChildProps>) => React.ComponentClass<TProps>;
|
|
7
|
+
//# sourceMappingURL=mutation-hoc.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mutation-hoc.d.ts","sourceRoot":"","sources":["../../../src/react/hoc/mutation-hoc.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAIvC,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AActE,OAAO,EAAE,eAAe,EAAe,WAAW,EAAE,MAAM,SAAS,CAAC;AACpE,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEzC,wBAAgB,YAAY,CAC1B,MAAM,SAAS,iBAAiB,GAAG,EAAE,GAAG,EAAE,EAC1C,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,EAAE,EACtC,iBAAiB,SAAS,kBAAkB,GAAG,EAAE,EACjD,WAAW,GAAG,WAAW,CAAC,KAAK,EAAE,iBAAiB,CAAC,EACnD,QAAQ,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,cAAc,EACrD,MAAM,SAAS,WAAW,CAAC,GAAG,CAAC,GAAG,WAAW,CAAC,GAAG,CAAC,EAElD,QAAQ,EAAE,YAAY,EACtB,gBAAgB,GAAE,eAAe,CAC/B,MAAM,EACN,KAAK,EACL,iBAAiB,EACjB,WAAW,CACP,sBAgBc,MAAM,aAAa,CAAC,MAAM,GAAG,WAAW,CAAC,KAC1D,MAAM,cAAc,CAAC,MAAM,CAAC,CA6DhC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { __assign, __extends, __rest } from "tslib";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import hoistNonReactStatics from 'hoist-non-react-statics';
|
|
4
|
+
import { parser } from "../parser/index.js";
|
|
5
|
+
import { Mutation } from "../components/index.js";
|
|
6
|
+
import { defaultMapPropsToOptions, getDisplayName, calculateVariablesFromProps, GraphQLBase } from "./hoc-utils.js";
|
|
7
|
+
export function withMutation(document, operationOptions) {
|
|
8
|
+
if (operationOptions === void 0) { operationOptions = {}; }
|
|
9
|
+
var operation = parser(document);
|
|
10
|
+
var _a = operationOptions.options, options = _a === void 0 ? defaultMapPropsToOptions : _a, _b = operationOptions.alias, alias = _b === void 0 ? 'Apollo' : _b;
|
|
11
|
+
var mapPropsToOptions = options;
|
|
12
|
+
if (typeof mapPropsToOptions !== 'function')
|
|
13
|
+
mapPropsToOptions = function () { return options; };
|
|
14
|
+
return function (WrappedComponent) {
|
|
15
|
+
var graphQLDisplayName = "".concat(alias, "(").concat(getDisplayName(WrappedComponent), ")");
|
|
16
|
+
var GraphQL = (function (_super) {
|
|
17
|
+
__extends(GraphQL, _super);
|
|
18
|
+
function GraphQL() {
|
|
19
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
20
|
+
}
|
|
21
|
+
GraphQL.prototype.render = function () {
|
|
22
|
+
var props = this.props;
|
|
23
|
+
var opts = mapPropsToOptions(props);
|
|
24
|
+
if (operationOptions.withRef) {
|
|
25
|
+
this.withRef = true;
|
|
26
|
+
props = Object.assign({}, props, {
|
|
27
|
+
ref: this.setWrappedInstance
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
if (!opts.variables && operation.variables.length > 0) {
|
|
31
|
+
opts.variables = calculateVariablesFromProps(operation, props);
|
|
32
|
+
}
|
|
33
|
+
return (React.createElement(Mutation, __assign({ ignoreResults: true }, opts, { mutation: document }), function (mutate, _a) {
|
|
34
|
+
var _b, _c;
|
|
35
|
+
var data = _a.data, r = __rest(_a, ["data"]);
|
|
36
|
+
var result = Object.assign(r, data || {});
|
|
37
|
+
var name = operationOptions.name || 'mutate';
|
|
38
|
+
var resultName = operationOptions.name
|
|
39
|
+
? "".concat(name, "Result")
|
|
40
|
+
: 'result';
|
|
41
|
+
var childProps = (_b = {},
|
|
42
|
+
_b[name] = mutate,
|
|
43
|
+
_b[resultName] = result,
|
|
44
|
+
_b);
|
|
45
|
+
if (operationOptions.props) {
|
|
46
|
+
var newResult = (_c = {},
|
|
47
|
+
_c[name] = mutate,
|
|
48
|
+
_c[resultName] = result,
|
|
49
|
+
_c.ownProps = props,
|
|
50
|
+
_c);
|
|
51
|
+
childProps = operationOptions.props(newResult);
|
|
52
|
+
}
|
|
53
|
+
return React.createElement(WrappedComponent, __assign({}, props, childProps));
|
|
54
|
+
}));
|
|
55
|
+
};
|
|
56
|
+
GraphQL.displayName = graphQLDisplayName;
|
|
57
|
+
GraphQL.WrappedComponent = WrappedComponent;
|
|
58
|
+
return GraphQL;
|
|
59
|
+
}(GraphQLBase));
|
|
60
|
+
return hoistNonReactStatics(GraphQL, WrappedComponent, {});
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=mutation-hoc.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mutation-hoc.js","sourceRoot":"","sources":["../../../src/react/hoc/mutation-hoc.tsx"],"names":[],"mappings":"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","sourcesContent":["import * as React from 'react';\nimport { DocumentNode } from 'graphql';\nimport hoistNonReactStatics from 'hoist-non-react-statics';\n\nimport { parser } from '../parser';\nimport { DefaultContext, OperationVariables } from '../../core/types';\nimport {\n BaseMutationOptions,\n MutationFunction,\n MutationResult\n} from '../types/types';\nimport { Mutation } from '../components';\n\nimport {\n defaultMapPropsToOptions,\n getDisplayName,\n calculateVariablesFromProps,\n GraphQLBase\n} from './hoc-utils';\nimport { OperationOption, OptionProps, MutateProps } from './types';\nimport { ApolloCache } from '../../core';\n\nexport function withMutation<\n TProps extends TGraphQLVariables | {} = {},\n TData extends Record<string, any> = {},\n TGraphQLVariables extends OperationVariables = {},\n TChildProps = MutateProps<TData, TGraphQLVariables>,\n TContext extends Record<string, any> = DefaultContext,\n TCache extends ApolloCache<any> = ApolloCache<any>,\n>(\n document: DocumentNode,\n operationOptions: OperationOption<\n TProps,\n TData,\n TGraphQLVariables,\n TChildProps\n > = {}\n) {\n // this is memoized so if coming from `graphql` there is nearly no extra cost\n const operation = parser(document);\n // extract options\n\n const {\n options = defaultMapPropsToOptions,\n alias = 'Apollo'\n } = operationOptions;\n\n let mapPropsToOptions = options as (props: any) => BaseMutationOptions<TData, TGraphQLVariables, TContext, TCache>;\n if (typeof mapPropsToOptions !== 'function')\n mapPropsToOptions = () => options as BaseMutationOptions<TData, TGraphQLVariables, TContext, TCache>;\n\n return (\n WrappedComponent: React.ComponentType<TProps & TChildProps>\n ): React.ComponentClass<TProps> => {\n const graphQLDisplayName = `${alias}(${getDisplayName(WrappedComponent)})`;\n class GraphQL extends GraphQLBase<TProps, TChildProps> {\n static displayName = graphQLDisplayName;\n static WrappedComponent = WrappedComponent;\n render() {\n let props = this.props as TProps;\n const opts = mapPropsToOptions(props) as BaseMutationOptions<TData, TGraphQLVariables, TContext, TCache>;\n\n if (operationOptions.withRef) {\n this.withRef = true;\n props = Object.assign({}, props, {\n ref: this.setWrappedInstance\n });\n }\n if (!opts.variables && operation.variables.length > 0) {\n opts.variables = calculateVariablesFromProps(operation, props) as TGraphQLVariables;\n }\n\n return (\n <Mutation ignoreResults {...opts} mutation={document}>\n {(\n mutate: MutationFunction<TData, TGraphQLVariables>,\n { data, ...r }: MutationResult<TData>\n ) => {\n // the HOC's historically hoisted the data from the execution result\n // up onto the result since it was passed as a nested prop\n // we massage the Mutation component's shape here to replicate that\n // this matches the query HoC\n const result = Object.assign(r, data || {});\n const name = operationOptions.name || 'mutate';\n const resultName = operationOptions.name\n ? `${name}Result`\n : 'result';\n let childProps = ({\n [name]: mutate,\n [resultName]: result\n } as any) as TChildProps;\n if (operationOptions.props) {\n const newResult: OptionProps<\n TProps,\n TData,\n TGraphQLVariables\n > = {\n [name]: mutate,\n [resultName]: result,\n ownProps: props\n };\n childProps = operationOptions.props(newResult) as any;\n }\n\n return <WrappedComponent {...props} {...childProps} />;\n }}\n </Mutation>\n );\n }\n }\n\n // Make sure we preserve any custom statics on the original component.\n return hoistNonReactStatics(GraphQL, WrappedComponent, {});\n };\n}\n"]}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { DocumentNode } from 'graphql';
|
|
3
|
+
import { OperationOption, DataProps } from './types';
|
|
4
|
+
export declare function withQuery<TProps extends TGraphQLVariables | Record<string, any> = Record<string, any>, TData extends object = {}, TGraphQLVariables extends object = {}, TChildProps extends object = DataProps<TData, TGraphQLVariables>>(document: DocumentNode, operationOptions?: OperationOption<TProps, TData, TGraphQLVariables, TChildProps>): (WrappedComponent: React.ComponentType<TProps & TChildProps>) => React.ComponentClass<TProps>;
|
|
5
|
+
//# sourceMappingURL=query-hoc.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query-hoc.d.ts","sourceRoot":"","sources":["../../../src/react/hoc/query-hoc.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAavC,OAAO,EAAE,eAAe,EAAe,SAAS,EAAE,MAAM,SAAS,CAAC;AAElE,wBAAgB,SAAS,CACvB,MAAM,SAAS,iBAAiB,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC5E,KAAK,SAAS,MAAM,GAAG,EAAE,EACzB,iBAAiB,SAAS,MAAM,GAAG,EAAE,EACrC,WAAW,SAAS,MAAM,GAAG,SAAS,CAAC,KAAK,EAAE,iBAAiB,CAAC,EAEhE,QAAQ,EAAE,YAAY,EACtB,gBAAgB,GAAE,eAAe,CAC/B,MAAM,EACN,KAAK,EACL,iBAAiB,EACjB,WAAW,CACP,sBAwBc,MAAM,aAAa,CAAC,MAAM,GAAG,WAAW,CAAC,KAC1D,MAAM,cAAc,CAAC,MAAM,CAAC,CA+EhC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { __assign, __extends, __rest } from "tslib";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import hoistNonReactStatics from 'hoist-non-react-statics';
|
|
4
|
+
import { parser } from "../parser/index.js";
|
|
5
|
+
import { Query } from "../components/index.js";
|
|
6
|
+
import { getDisplayName, GraphQLBase, calculateVariablesFromProps, defaultMapPropsToOptions, defaultMapPropsToSkip } from "./hoc-utils.js";
|
|
7
|
+
export function withQuery(document, operationOptions) {
|
|
8
|
+
if (operationOptions === void 0) { operationOptions = {}; }
|
|
9
|
+
var operation = parser(document);
|
|
10
|
+
var _a = operationOptions.options, options = _a === void 0 ? defaultMapPropsToOptions : _a, _b = operationOptions.skip, skip = _b === void 0 ? defaultMapPropsToSkip : _b, _c = operationOptions.alias, alias = _c === void 0 ? 'Apollo' : _c;
|
|
11
|
+
var mapPropsToOptions = options;
|
|
12
|
+
if (typeof mapPropsToOptions !== 'function') {
|
|
13
|
+
mapPropsToOptions = function () { return options; };
|
|
14
|
+
}
|
|
15
|
+
var mapPropsToSkip = skip;
|
|
16
|
+
if (typeof mapPropsToSkip !== 'function') {
|
|
17
|
+
mapPropsToSkip = function () { return skip; };
|
|
18
|
+
}
|
|
19
|
+
var lastResultProps;
|
|
20
|
+
return function (WrappedComponent) {
|
|
21
|
+
var graphQLDisplayName = "".concat(alias, "(").concat(getDisplayName(WrappedComponent), ")");
|
|
22
|
+
var GraphQL = (function (_super) {
|
|
23
|
+
__extends(GraphQL, _super);
|
|
24
|
+
function GraphQL() {
|
|
25
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
26
|
+
}
|
|
27
|
+
GraphQL.prototype.render = function () {
|
|
28
|
+
var _this = this;
|
|
29
|
+
var props = this.props;
|
|
30
|
+
var shouldSkip = mapPropsToSkip(props);
|
|
31
|
+
var opts = shouldSkip
|
|
32
|
+
? Object.create(null)
|
|
33
|
+
: __assign({}, mapPropsToOptions(props));
|
|
34
|
+
if (!shouldSkip && !opts.variables && operation.variables.length > 0) {
|
|
35
|
+
opts.variables = calculateVariablesFromProps(operation, props);
|
|
36
|
+
}
|
|
37
|
+
return (React.createElement(Query, __assign({}, opts, { displayName: graphQLDisplayName, skip: shouldSkip, query: document }), function (_a) {
|
|
38
|
+
var _b, _c;
|
|
39
|
+
var _ = _a.client, data = _a.data, r = __rest(_a, ["client", "data"]);
|
|
40
|
+
if (operationOptions.withRef) {
|
|
41
|
+
_this.withRef = true;
|
|
42
|
+
props = Object.assign({}, props, {
|
|
43
|
+
ref: _this.setWrappedInstance
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
if (shouldSkip) {
|
|
47
|
+
return (React.createElement(WrappedComponent, __assign({}, props, {})));
|
|
48
|
+
}
|
|
49
|
+
var result = Object.assign(r, data || {});
|
|
50
|
+
var name = operationOptions.name || 'data';
|
|
51
|
+
var childProps = (_b = {}, _b[name] = result, _b);
|
|
52
|
+
if (operationOptions.props) {
|
|
53
|
+
var newResult = (_c = {},
|
|
54
|
+
_c[name] = result,
|
|
55
|
+
_c.ownProps = props,
|
|
56
|
+
_c);
|
|
57
|
+
lastResultProps = operationOptions.props(newResult, lastResultProps);
|
|
58
|
+
childProps = lastResultProps;
|
|
59
|
+
}
|
|
60
|
+
return (React.createElement(WrappedComponent, __assign({}, props, childProps)));
|
|
61
|
+
}));
|
|
62
|
+
};
|
|
63
|
+
GraphQL.displayName = graphQLDisplayName;
|
|
64
|
+
GraphQL.WrappedComponent = WrappedComponent;
|
|
65
|
+
return GraphQL;
|
|
66
|
+
}(GraphQLBase));
|
|
67
|
+
return hoistNonReactStatics(GraphQL, WrappedComponent, {});
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=query-hoc.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query-hoc.js","sourceRoot":"","sources":["../../../src/react/hoc/query-hoc.tsx"],"names":[],"mappings":"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","sourcesContent":["import * as React from 'react';\nimport { DocumentNode } from 'graphql';\nimport hoistNonReactStatics from 'hoist-non-react-statics';\n\nimport { parser } from '../parser';\nimport { BaseQueryOptions } from '../types/types';\nimport { Query } from '../components';\nimport {\n getDisplayName,\n GraphQLBase,\n calculateVariablesFromProps,\n defaultMapPropsToOptions,\n defaultMapPropsToSkip\n} from './hoc-utils';\nimport { OperationOption, OptionProps, DataProps } from './types';\n\nexport function withQuery<\n TProps extends TGraphQLVariables | Record<string, any> = Record<string, any>,\n TData extends object = {},\n TGraphQLVariables extends object = {},\n TChildProps extends object = DataProps<TData, TGraphQLVariables>\n>(\n document: DocumentNode,\n operationOptions: OperationOption<\n TProps,\n TData,\n TGraphQLVariables,\n TChildProps\n > = {}\n) {\n // this is memoized so if coming from `graphql` there is nearly no extra cost\n const operation = parser(document);\n // extract options\n const {\n options = defaultMapPropsToOptions,\n skip = defaultMapPropsToSkip,\n alias = 'Apollo'\n } = operationOptions;\n\n let mapPropsToOptions = options as (props: any) => BaseQueryOptions;\n if (typeof mapPropsToOptions !== 'function') {\n mapPropsToOptions = () => options as BaseQueryOptions;\n }\n\n let mapPropsToSkip = skip as (props: any) => boolean;\n if (typeof mapPropsToSkip !== 'function') {\n mapPropsToSkip = () => skip as any;\n }\n\n // allow for advanced referential equality checks\n let lastResultProps: TChildProps | void;\n return (\n WrappedComponent: React.ComponentType<TProps & TChildProps>\n ): React.ComponentClass<TProps> => {\n const graphQLDisplayName = `${alias}(${getDisplayName(WrappedComponent)})`;\n class GraphQL extends GraphQLBase<TProps, TChildProps> {\n static displayName = graphQLDisplayName;\n static WrappedComponent = WrappedComponent;\n\n render() {\n let props = this.props;\n const shouldSkip = mapPropsToSkip(props);\n const opts = shouldSkip\n ? Object.create(null)\n : { ...mapPropsToOptions(props) };\n\n if (!shouldSkip && !opts.variables && operation.variables.length > 0) {\n opts.variables = calculateVariablesFromProps(operation, props);\n }\n\n return (\n <Query\n {...opts}\n displayName={graphQLDisplayName}\n skip={shouldSkip}\n query={document}\n >\n {({ client: _, data, ...r }: any) => {\n if (operationOptions.withRef) {\n this.withRef = true;\n props = Object.assign({}, props, {\n ref: this.setWrappedInstance\n });\n }\n\n // if we have skipped, no reason to manage any reshaping\n if (shouldSkip) {\n return (\n <WrappedComponent\n {...(props as TProps)}\n {...({} as TChildProps)}\n />\n );\n }\n\n // the HOC's historically hoisted the data from the execution result\n // up onto the result since it was passed as a nested prop\n // we massage the Query components shape here to replicate that\n const result = Object.assign(r, data || {});\n const name = operationOptions.name || 'data';\n let childProps = { [name]: result };\n if (operationOptions.props) {\n const newResult: OptionProps<\n TProps,\n TData,\n TGraphQLVariables\n > = {\n [name]: result,\n ownProps: props as TProps\n };\n lastResultProps = operationOptions.props(\n newResult,\n lastResultProps\n );\n childProps = lastResultProps;\n }\n\n return (\n <WrappedComponent\n {...(props as TProps)}\n {...(childProps as TChildProps)}\n />\n );\n }}\n </Query>\n );\n }\n }\n\n // Make sure we preserve any custom statics on the original component.\n return hoistNonReactStatics(GraphQL, WrappedComponent, {});\n };\n}\n"]}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { DocumentNode } from 'graphql';
|
|
3
|
+
import { OperationOption, DataProps } from './types';
|
|
4
|
+
export declare function withSubscription<TProps extends TGraphQLVariables | {} = {}, TData extends object = {}, TGraphQLVariables extends object = {}, TChildProps extends object = DataProps<TData, TGraphQLVariables>>(document: DocumentNode, operationOptions?: OperationOption<TProps, TData, TGraphQLVariables, TChildProps>): (WrappedComponent: React.ComponentType<TProps & TChildProps>) => React.ComponentClass<TProps>;
|
|
5
|
+
//# sourceMappingURL=subscription-hoc.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"subscription-hoc.d.ts","sourceRoot":"","sources":["../../../src/react/hoc/subscription-hoc.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAavC,OAAO,EAAE,eAAe,EAAe,SAAS,EAAE,MAAM,SAAS,CAAC;AAElE,wBAAgB,gBAAgB,CAC9B,MAAM,SAAS,iBAAiB,GAAG,EAAE,GAAG,EAAE,EAC1C,KAAK,SAAS,MAAM,GAAG,EAAE,EACzB,iBAAiB,SAAS,MAAM,GAAG,EAAE,EACrC,WAAW,SAAS,MAAM,GAAG,SAAS,CAAC,KAAK,EAAE,iBAAiB,CAAC,EAEhE,QAAQ,EAAE,YAAY,EACtB,gBAAgB,GAAE,eAAe,CAC/B,MAAM,EACN,KAAK,EACL,iBAAiB,EACjB,WAAW,CACP,sBAsBc,MAAM,aAAa,CAAC,MAAM,GAAG,WAAW,CAAC,KAC1D,MAAM,cAAc,CAAC,MAAM,CAAC,CAoGhC"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { __assign, __extends, __rest } from "tslib";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import hoistNonReactStatics from 'hoist-non-react-statics';
|
|
4
|
+
import { parser } from "../parser/index.js";
|
|
5
|
+
import { Subscription } from "../components/index.js";
|
|
6
|
+
import { getDisplayName, GraphQLBase, calculateVariablesFromProps, defaultMapPropsToOptions, defaultMapPropsToSkip } from "./hoc-utils.js";
|
|
7
|
+
export function withSubscription(document, operationOptions) {
|
|
8
|
+
if (operationOptions === void 0) { operationOptions = {}; }
|
|
9
|
+
var operation = parser(document);
|
|
10
|
+
var _a = operationOptions.options, options = _a === void 0 ? defaultMapPropsToOptions : _a, _b = operationOptions.skip, skip = _b === void 0 ? defaultMapPropsToSkip : _b, _c = operationOptions.alias, alias = _c === void 0 ? 'Apollo' : _c, shouldResubscribe = operationOptions.shouldResubscribe;
|
|
11
|
+
var mapPropsToOptions = options;
|
|
12
|
+
if (typeof mapPropsToOptions !== 'function')
|
|
13
|
+
mapPropsToOptions = function () { return options; };
|
|
14
|
+
var mapPropsToSkip = skip;
|
|
15
|
+
if (typeof mapPropsToSkip !== 'function')
|
|
16
|
+
mapPropsToSkip = function () { return skip; };
|
|
17
|
+
var lastResultProps;
|
|
18
|
+
return function (WrappedComponent) {
|
|
19
|
+
var graphQLDisplayName = "".concat(alias, "(").concat(getDisplayName(WrappedComponent), ")");
|
|
20
|
+
var GraphQL = (function (_super) {
|
|
21
|
+
__extends(GraphQL, _super);
|
|
22
|
+
function GraphQL(props) {
|
|
23
|
+
var _this = _super.call(this, props) || this;
|
|
24
|
+
_this.state = { resubscribe: false };
|
|
25
|
+
return _this;
|
|
26
|
+
}
|
|
27
|
+
GraphQL.prototype.updateResubscribe = function (resubscribe) {
|
|
28
|
+
this.setState({ resubscribe: resubscribe });
|
|
29
|
+
};
|
|
30
|
+
GraphQL.prototype.componentDidUpdate = function (prevProps) {
|
|
31
|
+
var resubscribe = !!(shouldResubscribe &&
|
|
32
|
+
shouldResubscribe(prevProps, this.props));
|
|
33
|
+
if (this.state.resubscribe !== resubscribe) {
|
|
34
|
+
this.updateResubscribe(resubscribe);
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
GraphQL.prototype.render = function () {
|
|
38
|
+
var _this = this;
|
|
39
|
+
var props = this.props;
|
|
40
|
+
var shouldSkip = mapPropsToSkip(props);
|
|
41
|
+
var opts = shouldSkip
|
|
42
|
+
? Object.create(null)
|
|
43
|
+
: mapPropsToOptions(props);
|
|
44
|
+
if (!shouldSkip && !opts.variables && operation.variables.length > 0) {
|
|
45
|
+
opts.variables = calculateVariablesFromProps(operation, props);
|
|
46
|
+
}
|
|
47
|
+
return (React.createElement(Subscription, __assign({}, opts, { displayName: graphQLDisplayName, skip: shouldSkip, subscription: document, shouldResubscribe: this.state.resubscribe }), function (_a) {
|
|
48
|
+
var _b, _c;
|
|
49
|
+
var data = _a.data, r = __rest(_a, ["data"]);
|
|
50
|
+
if (operationOptions.withRef) {
|
|
51
|
+
_this.withRef = true;
|
|
52
|
+
props = Object.assign({}, props, {
|
|
53
|
+
ref: _this.setWrappedInstance
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
if (shouldSkip) {
|
|
57
|
+
return (React.createElement(WrappedComponent, __assign({}, props, {})));
|
|
58
|
+
}
|
|
59
|
+
var result = Object.assign(r, data || {});
|
|
60
|
+
var name = operationOptions.name || 'data';
|
|
61
|
+
var childProps = (_b = {}, _b[name] = result, _b);
|
|
62
|
+
if (operationOptions.props) {
|
|
63
|
+
var newResult = (_c = {},
|
|
64
|
+
_c[name] = result,
|
|
65
|
+
_c.ownProps = props,
|
|
66
|
+
_c);
|
|
67
|
+
lastResultProps = operationOptions.props(newResult, lastResultProps);
|
|
68
|
+
childProps = lastResultProps;
|
|
69
|
+
}
|
|
70
|
+
return (React.createElement(WrappedComponent, __assign({}, props, childProps)));
|
|
71
|
+
}));
|
|
72
|
+
};
|
|
73
|
+
GraphQL.displayName = graphQLDisplayName;
|
|
74
|
+
GraphQL.WrappedComponent = WrappedComponent;
|
|
75
|
+
return GraphQL;
|
|
76
|
+
}(GraphQLBase));
|
|
77
|
+
return hoistNonReactStatics(GraphQL, WrappedComponent, {});
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=subscription-hoc.js.map
|