@apollo/client 3.7.5 → 3.7.6
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 +102 -52
- package/apollo-client.cjs.map +1 -1
- package/apollo-client.min.cjs +1 -1
- package/cache/core/cache.d.ts +1 -1
- package/cache/core/cache.d.ts.map +1 -1
- package/cache/core/cache.js.map +1 -1
- package/cache/core/types/common.d.ts +7 -7
- package/cache/core/types/common.d.ts.map +1 -1
- package/cache/inmemory/entityStore.d.ts +1 -1
- package/cache/inmemory/entityStore.d.ts.map +1 -1
- package/cache/inmemory/helpers.js.map +1 -1
- package/cache/inmemory/inMemoryCache.d.ts +3 -2
- package/cache/inmemory/inMemoryCache.d.ts.map +1 -1
- package/cache/inmemory/inMemoryCache.js.map +1 -1
- package/cache/inmemory/policies.d.ts +12 -12
- package/cache/inmemory/policies.d.ts.map +1 -1
- package/cache/inmemory/policies.js.map +1 -1
- package/cache/inmemory/reactiveVars.d.ts +1 -1
- package/cache/inmemory/reactiveVars.d.ts.map +1 -1
- package/cache/inmemory/readFromStore.d.ts +2 -2
- package/cache/inmemory/readFromStore.d.ts.map +1 -1
- package/cache/inmemory/types.d.ts +4 -4
- package/cache/inmemory/types.d.ts.map +1 -1
- package/cache/inmemory/writeToStore.d.ts +1 -1
- package/cache/inmemory/writeToStore.d.ts.map +1 -1
- package/cache/inmemory/writeToStore.js.map +1 -1
- package/core/ApolloClient.d.ts +5 -5
- package/core/ApolloClient.d.ts.map +1 -1
- package/core/ApolloClient.js.map +1 -1
- package/core/LocalState.d.ts +9 -6
- package/core/LocalState.d.ts.map +1 -1
- package/core/LocalState.js +61 -14
- package/core/LocalState.js.map +1 -1
- package/core/ObservableQuery.d.ts +5 -5
- package/core/ObservableQuery.d.ts.map +1 -1
- package/core/ObservableQuery.js +1 -1
- package/core/ObservableQuery.js.map +1 -1
- package/core/QueryInfo.d.ts +1 -1
- package/core/QueryInfo.d.ts.map +1 -1
- package/core/QueryManager.d.ts +7 -7
- package/core/QueryManager.d.ts.map +1 -1
- package/core/QueryManager.js +12 -9
- package/core/QueryManager.js.map +1 -1
- package/core/core.cjs +74 -24
- package/core/core.cjs.map +1 -1
- package/core/core.cjs.native.js +74 -24
- package/core/types.d.ts +16 -16
- package/core/types.d.ts.map +1 -1
- package/core/watchQueryOptions.d.ts +9 -9
- package/core/watchQueryOptions.d.ts.map +1 -1
- package/core/watchQueryOptions.js.map +1 -1
- package/errors/index.d.ts +2 -2
- package/errors/index.d.ts.map +1 -1
- package/invariantErrorCodes.js +48 -43
- package/link/batch/batch.cjs +5 -3
- package/link/batch/batch.cjs.map +1 -1
- package/link/batch/batch.cjs.native.js +5 -3
- package/link/batch/batching.d.ts +2 -2
- package/link/batch/batching.d.ts.map +1 -1
- package/link/batch/batching.js +5 -3
- package/link/batch/batching.js.map +1 -1
- package/link/context/index.d.ts +1 -1
- package/link/context/index.d.ts.map +1 -1
- package/link/core/ApolloLink.js +1 -1
- package/link/core/core.cjs +1 -1
- package/link/core/core.cjs.map +1 -1
- package/link/core/core.cjs.native.js +1 -1
- package/link/core/types.d.ts +6 -6
- package/link/core/types.d.ts.map +1 -1
- package/link/http/checkFetcher.js +1 -1
- package/link/http/createHttpLink.js.map +1 -1
- package/link/http/http.cjs +2 -2
- package/link/http/http.cjs.map +1 -1
- package/link/http/http.cjs.native.js +2 -2
- package/link/http/iterators/async.js.map +1 -1
- package/link/http/iterators/nodeStream.js.map +1 -1
- package/link/http/iterators/promise.js.map +1 -1
- package/link/http/iterators/reader.js.map +1 -1
- package/link/http/parseAndCheckHttpResponse.d.ts +2 -2
- package/link/http/parseAndCheckHttpResponse.d.ts.map +1 -1
- package/link/http/parseAndCheckHttpResponse.js.map +1 -1
- package/link/http/serializeFetchParameter.d.ts +1 -1
- package/link/http/serializeFetchParameter.d.ts.map +1 -1
- package/link/http/serializeFetchParameter.js +1 -1
- package/link/persisted-queries/index.d.ts +2 -2
- package/link/persisted-queries/index.d.ts.map +1 -1
- package/link/persisted-queries/index.js +2 -2
- package/link/persisted-queries/persisted-queries.cjs +2 -2
- package/link/persisted-queries/persisted-queries.cjs.map +1 -1
- package/link/persisted-queries/persisted-queries.cjs.native.js +2 -2
- package/link/utils/throwServerError.d.ts +1 -1
- package/link/utils/throwServerError.d.ts.map +1 -1
- package/link/utils/utils.cjs +1 -1
- package/link/utils/utils.cjs.map +1 -1
- package/link/utils/utils.cjs.native.js +1 -1
- package/link/utils/validateOperation.js +1 -1
- package/package.json +9 -9
- package/react/components/Query.d.ts +2 -2
- package/react/components/Query.d.ts.map +1 -1
- package/react/components/Query.js.map +1 -1
- package/react/components/Subscription.d.ts +2 -2
- package/react/components/Subscription.d.ts.map +1 -1
- package/react/components/Subscription.js.map +1 -1
- package/react/components/types.d.ts +2 -2
- package/react/components/types.d.ts.map +1 -1
- package/react/components/types.js.map +1 -1
- package/react/context/ApolloConsumer.js +1 -1
- package/react/context/ApolloProvider.js +1 -1
- package/react/context/context.cjs +2 -2
- package/react/context/context.cjs.map +1 -1
- package/react/context/context.cjs.native.js +2 -2
- package/react/hoc/graphql.d.ts +2 -1
- package/react/hoc/graphql.d.ts.map +1 -1
- package/react/hoc/graphql.js.map +1 -1
- package/react/hoc/hoc-utils.d.ts +1 -1
- package/react/hoc/hoc-utils.d.ts.map +1 -1
- package/react/hoc/hoc-utils.js +1 -1
- package/react/hoc/hoc.cjs +2 -2
- package/react/hoc/hoc.cjs.map +1 -1
- package/react/hoc/hoc.cjs.native.js +2 -2
- package/react/hoc/mutation-hoc.d.ts +2 -2
- package/react/hoc/mutation-hoc.d.ts.map +1 -1
- package/react/hoc/mutation-hoc.js.map +1 -1
- package/react/hoc/query-hoc.d.ts +1 -1
- package/react/hoc/query-hoc.d.ts.map +1 -1
- package/react/hoc/query-hoc.js.map +1 -1
- package/react/hoc/subscription-hoc.d.ts +1 -1
- package/react/hoc/subscription-hoc.d.ts.map +1 -1
- package/react/hoc/subscription-hoc.js.map +1 -1
- package/react/hoc/types.d.ts +6 -6
- package/react/hoc/types.d.ts.map +1 -1
- package/react/hoc/types.js.map +1 -1
- package/react/hoc/withApollo.js +1 -1
- package/react/hooks/hooks.cjs +1 -1
- package/react/hooks/hooks.cjs.map +1 -1
- package/react/hooks/hooks.cjs.native.js +1 -1
- package/react/hooks/useApolloClient.js +1 -1
- package/react/hooks/useLazyQuery.d.ts +1 -1
- package/react/hooks/useLazyQuery.d.ts.map +1 -1
- package/react/hooks/useLazyQuery.js.map +1 -1
- package/react/hooks/useQuery.d.ts +3 -3
- package/react/hooks/useQuery.d.ts.map +1 -1
- package/react/hooks/useQuery.js.map +1 -1
- package/react/hooks/useSubscription.d.ts +1 -1
- package/react/hooks/useSubscription.d.ts.map +1 -1
- package/react/hooks/useSubscription.js.map +1 -1
- package/react/hooks/useSyncExternalStore.d.ts +1 -1
- package/react/hooks/useSyncExternalStore.d.ts.map +1 -1
- package/react/parser/index.js +5 -5
- package/react/parser/parser.cjs +5 -5
- package/react/parser/parser.cjs.map +1 -1
- package/react/parser/parser.cjs.native.js +5 -5
- package/react/ssr/RenderPromises.d.ts +4 -4
- package/react/ssr/RenderPromises.d.ts.map +1 -1
- package/react/ssr/RenderPromises.js.map +1 -1
- package/react/ssr/getDataFromTree.d.ts +1 -1
- package/react/ssr/getDataFromTree.d.ts.map +1 -1
- package/react/types/types.d.ts +17 -17
- package/react/types/types.d.ts.map +1 -1
- package/react/types/types.js.map +1 -1
- package/testing/core/core.cjs +1 -1
- package/testing/core/core.cjs.map +1 -1
- package/testing/core/core.cjs.native.js +1 -1
- package/testing/core/mocking/mockFetch.js.map +1 -1
- package/testing/core/mocking/mockLink.d.ts +1 -1
- package/testing/core/mocking/mockLink.d.ts.map +1 -1
- package/testing/core/mocking/mockLink.js +1 -1
- package/testing/core/observableToPromise.d.ts +2 -2
- package/testing/core/observableToPromise.d.ts.map +1 -1
- package/testing/core/observableToPromise.js.map +1 -1
- package/utilities/common/cloneDeep.js.map +1 -1
- package/utilities/common/errorHandling.d.ts +2 -2
- package/utilities/common/errorHandling.d.ts.map +1 -1
- package/utilities/common/errorHandling.js.map +1 -1
- package/utilities/common/incrementalResult.d.ts +4 -4
- package/utilities/common/incrementalResult.d.ts.map +1 -1
- package/utilities/common/incrementalResult.js.map +1 -1
- package/utilities/common/mergeDeep.d.ts +2 -2
- package/utilities/common/mergeDeep.d.ts.map +1 -1
- package/utilities/common/mergeOptions.d.ts +2 -2
- package/utilities/common/mergeOptions.d.ts.map +1 -1
- package/utilities/common/mergeOptions.js.map +1 -1
- package/utilities/globals/globals.cjs +1 -1
- package/utilities/globals/globals.cjs.map +1 -1
- package/utilities/globals/globals.cjs.native.js +1 -1
- package/utilities/globals/index.js +1 -1
- package/utilities/graphql/directives.d.ts +2 -2
- package/utilities/graphql/directives.d.ts.map +1 -1
- package/utilities/graphql/directives.js +4 -4
- package/utilities/graphql/directives.js.map +1 -1
- package/utilities/graphql/fragments.d.ts +1 -1
- package/utilities/graphql/fragments.d.ts.map +1 -1
- package/utilities/graphql/fragments.js +3 -3
- package/utilities/graphql/getFromAST.js +8 -8
- package/utilities/graphql/storeUtils.d.ts +3 -3
- package/utilities/graphql/storeUtils.d.ts.map +1 -1
- package/utilities/graphql/storeUtils.js +1 -1
- package/utilities/graphql/storeUtils.js.map +1 -1
- package/utilities/graphql/transform.d.ts +9 -9
- package/utilities/graphql/transform.d.ts.map +1 -1
- package/utilities/graphql/transform.js.map +1 -1
- package/utilities/observables/Concast.d.ts +5 -5
- package/utilities/observables/Concast.d.ts.map +1 -1
- package/utilities/observables/asyncMap.js.map +1 -1
- package/utilities/policies/pagination.d.ts +7 -7
- package/utilities/policies/pagination.d.ts.map +1 -1
- package/utilities/policies/pagination.js.map +1 -1
- package/utilities/types/IsStrictlyAny.d.ts +3 -3
- package/utilities/types/IsStrictlyAny.d.ts.map +1 -1
- package/utilities/utilities.cjs +16 -16
- package/utilities/utilities.cjs.map +1 -1
- package/utilities/utilities.cjs.native.js +16 -16
- package/version.js +1 -1
package/invariantErrorCodes.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
// consult the @apollo/client/invariantErrorCodes.js file specific to
|
|
6
6
|
// your @apollo/client version. This file is not meant to be imported.
|
|
7
7
|
{
|
|
8
|
-
"@apollo/client version": "3.7.
|
|
8
|
+
"@apollo/client version": "3.7.6",
|
|
9
9
|
|
|
10
10
|
1: {
|
|
11
11
|
file: "@apollo/client/cache/inmemory/entityStore.js",
|
|
@@ -70,70 +70,75 @@
|
|
|
70
70
|
},
|
|
71
71
|
|
|
72
72
|
12: {
|
|
73
|
+
file: "@apollo/client/core/LocalState.js",
|
|
74
|
+
node: invariant(fragment, "No fragment named ".concat(spread.name.value))
|
|
75
|
+
},
|
|
76
|
+
|
|
77
|
+
13: {
|
|
73
78
|
file: "@apollo/client/core/ObservableQuery.js",
|
|
74
79
|
node: invariant(pollInterval, 'Attempted to start a polling query without a polling interval.')
|
|
75
80
|
},
|
|
76
81
|
|
|
77
|
-
|
|
82
|
+
14: {
|
|
78
83
|
file: "@apollo/client/core/QueryManager.js",
|
|
79
84
|
node: new InvariantError('QueryManager stopped while query was in flight')
|
|
80
85
|
},
|
|
81
86
|
|
|
82
|
-
|
|
87
|
+
15: {
|
|
83
88
|
file: "@apollo/client/core/QueryManager.js",
|
|
84
89
|
node: invariant(mutation, 'mutation option is required. You must specify your GraphQL document in the mutation option.')
|
|
85
90
|
},
|
|
86
91
|
|
|
87
|
-
|
|
92
|
+
16: {
|
|
88
93
|
file: "@apollo/client/core/QueryManager.js",
|
|
89
94
|
|
|
90
95
|
node: invariant(fetchPolicy === 'network-only' ||
|
|
91
96
|
fetchPolicy === 'no-cache', "Mutations support only 'network-only' or 'no-cache' fetchPolicy strings. The default `network-only` behavior automatically writes mutation results to the cache. Passing `no-cache` skips the cache write.")
|
|
92
97
|
},
|
|
93
98
|
|
|
94
|
-
|
|
99
|
+
17: {
|
|
95
100
|
file: "@apollo/client/core/QueryManager.js",
|
|
96
101
|
|
|
97
102
|
node: invariant(options.query, 'query option is required. You must specify your GraphQL document ' +
|
|
98
103
|
'in the query option.')
|
|
99
104
|
},
|
|
100
105
|
|
|
101
|
-
|
|
106
|
+
18: {
|
|
102
107
|
file: "@apollo/client/core/QueryManager.js",
|
|
103
108
|
node: invariant(options.query.kind === 'Document', 'You must wrap the query string in a "gql" tag.')
|
|
104
109
|
},
|
|
105
110
|
|
|
106
|
-
|
|
111
|
+
19: {
|
|
107
112
|
file: "@apollo/client/core/QueryManager.js",
|
|
108
113
|
node: invariant(!options.returnPartialData, 'returnPartialData option only supported on watchQuery.')
|
|
109
114
|
},
|
|
110
115
|
|
|
111
|
-
|
|
116
|
+
20: {
|
|
112
117
|
file: "@apollo/client/core/QueryManager.js",
|
|
113
118
|
node: invariant(!options.pollInterval, 'pollInterval option only supported on watchQuery.')
|
|
114
119
|
},
|
|
115
120
|
|
|
116
|
-
|
|
121
|
+
21: {
|
|
117
122
|
file: "@apollo/client/core/QueryManager.js",
|
|
118
123
|
node: new InvariantError('Store reset while query was in flight (not completed in link chain)')
|
|
119
124
|
},
|
|
120
125
|
|
|
121
|
-
|
|
126
|
+
22: {
|
|
122
127
|
file: "@apollo/client/link/core/ApolloLink.js",
|
|
123
128
|
node: new InvariantError('request is not implemented')
|
|
124
129
|
},
|
|
125
130
|
|
|
126
|
-
|
|
131
|
+
23: {
|
|
127
132
|
file: "@apollo/client/link/http/checkFetcher.js",
|
|
128
133
|
node: new InvariantError("\n\"fetch\" has not been found globally and no fetcher has been configured. To fix this, install a fetch package (like https://www.npmjs.com/package/cross-fetch), instantiate the fetcher, and pass it into your HttpLink constructor. For example:\n\nimport fetch from 'cross-fetch';\nimport { ApolloClient, HttpLink } from '@apollo/client';\nconst client = new ApolloClient({\n link: new HttpLink({ uri: '/graphql', fetch })\n});\n ")
|
|
129
134
|
},
|
|
130
135
|
|
|
131
|
-
|
|
136
|
+
24: {
|
|
132
137
|
file: "@apollo/client/link/http/serializeFetchParameter.js",
|
|
133
138
|
node: new InvariantError("Network request failed. ".concat(label, " is not serializable: ").concat(e.message))
|
|
134
139
|
},
|
|
135
140
|
|
|
136
|
-
|
|
141
|
+
25: {
|
|
137
142
|
file: "@apollo/client/link/persisted-queries/index.js",
|
|
138
143
|
|
|
139
144
|
node: invariant(options && (typeof options.sha256 === 'function' ||
|
|
@@ -142,45 +147,45 @@
|
|
|
142
147
|
'parameter.')
|
|
143
148
|
},
|
|
144
149
|
|
|
145
|
-
|
|
150
|
+
26: {
|
|
146
151
|
file: "@apollo/client/link/persisted-queries/index.js",
|
|
147
152
|
node: invariant(forward, 'PersistedQueryLink cannot be the last link in the chain.')
|
|
148
153
|
},
|
|
149
154
|
|
|
150
|
-
|
|
155
|
+
27: {
|
|
151
156
|
file: "@apollo/client/link/utils/validateOperation.js",
|
|
152
157
|
node: new InvariantError("illegal argument: ".concat(key))
|
|
153
158
|
},
|
|
154
159
|
|
|
155
|
-
|
|
160
|
+
28: {
|
|
156
161
|
file: "@apollo/client/react/context/ApolloConsumer.js",
|
|
157
162
|
|
|
158
163
|
node: invariant(context && context.client, 'Could not find "client" in the context of ApolloConsumer. ' +
|
|
159
164
|
'Wrap the root component in an <ApolloProvider>.')
|
|
160
165
|
},
|
|
161
166
|
|
|
162
|
-
|
|
167
|
+
29: {
|
|
163
168
|
file: "@apollo/client/react/context/ApolloProvider.js",
|
|
164
169
|
|
|
165
170
|
node: invariant(context.client, 'ApolloProvider was not passed a client instance. Make ' +
|
|
166
171
|
'sure you pass in your client via the "client" prop.')
|
|
167
172
|
},
|
|
168
173
|
|
|
169
|
-
|
|
174
|
+
30: {
|
|
170
175
|
file: "@apollo/client/react/hoc/hoc-utils.js",
|
|
171
176
|
|
|
172
177
|
node: invariant(this.withRef, "To access the wrapped instance, you need to specify " +
|
|
173
178
|
"{ withRef: true } in the options")
|
|
174
179
|
},
|
|
175
180
|
|
|
176
|
-
|
|
181
|
+
31: {
|
|
177
182
|
file: "@apollo/client/react/hoc/withApollo.js",
|
|
178
183
|
|
|
179
184
|
node: invariant(operationOptions.withRef, "To access the wrapped instance, you need to specify " +
|
|
180
185
|
"{ withRef: true } in the options")
|
|
181
186
|
},
|
|
182
187
|
|
|
183
|
-
|
|
188
|
+
32: {
|
|
184
189
|
file: "@apollo/client/react/hooks/useApolloClient.js",
|
|
185
190
|
|
|
186
191
|
node: invariant(!!client, 'Could not find "client" in the context or passed in as an option. ' +
|
|
@@ -188,7 +193,7 @@
|
|
|
188
193
|
'instance in via options.')
|
|
189
194
|
},
|
|
190
195
|
|
|
191
|
-
|
|
196
|
+
33: {
|
|
192
197
|
file: "@apollo/client/react/parser/index.js",
|
|
193
198
|
|
|
194
199
|
node: invariant(!!document && !!document.kind, "Argument of ".concat(document, " passed to parser was not a valid GraphQL ") +
|
|
@@ -196,7 +201,7 @@
|
|
|
196
201
|
"to convert your operation into a document")
|
|
197
202
|
},
|
|
198
203
|
|
|
199
|
-
|
|
204
|
+
34: {
|
|
200
205
|
file: "@apollo/client/react/parser/index.js",
|
|
201
206
|
|
|
202
207
|
node: invariant(!fragments.length ||
|
|
@@ -204,7 +209,7 @@
|
|
|
204
209
|
"You must include a query, subscription or mutation as well")
|
|
205
210
|
},
|
|
206
211
|
|
|
207
|
-
|
|
212
|
+
35: {
|
|
208
213
|
file: "@apollo/client/react/parser/index.js",
|
|
209
214
|
|
|
210
215
|
node: invariant(queries.length + mutations.length + subscriptions.length <= 1, "react-apollo only supports a query, subscription, or a mutation per HOC. " +
|
|
@@ -213,7 +218,7 @@
|
|
|
213
218
|
"You can use 'compose' to join multiple operation types to a component")
|
|
214
219
|
},
|
|
215
220
|
|
|
216
|
-
|
|
221
|
+
36: {
|
|
217
222
|
file: "@apollo/client/react/parser/index.js",
|
|
218
223
|
|
|
219
224
|
node: invariant(definitions.length === 1, "react-apollo only supports one definition per HOC. ".concat(document, " had ") +
|
|
@@ -221,103 +226,103 @@
|
|
|
221
226
|
"You can use 'compose' to join multiple operation types to a component")
|
|
222
227
|
},
|
|
223
228
|
|
|
224
|
-
|
|
229
|
+
37: {
|
|
225
230
|
file: "@apollo/client/react/parser/index.js",
|
|
226
231
|
|
|
227
232
|
node: invariant(operation.type === type, "Running a ".concat(requiredOperationName, " requires a graphql ") +
|
|
228
233
|
"".concat(requiredOperationName, ", but a ").concat(usedOperationName, " was used instead."))
|
|
229
234
|
},
|
|
230
235
|
|
|
231
|
-
|
|
236
|
+
38: {
|
|
232
237
|
file: "@apollo/client/testing/core/mocking/mockLink.js",
|
|
233
238
|
node: invariant(queryWithoutConnection, "query is required")
|
|
234
239
|
},
|
|
235
240
|
|
|
236
|
-
|
|
241
|
+
39: {
|
|
237
242
|
file: "@apollo/client/utilities/globals/index.js",
|
|
238
243
|
node: invariant("boolean" === typeof DEV, DEV)
|
|
239
244
|
},
|
|
240
245
|
|
|
241
|
-
|
|
246
|
+
40: {
|
|
242
247
|
file: "@apollo/client/utilities/graphql/directives.js",
|
|
243
248
|
node: invariant(evaledValue !== void 0, "Invalid variable referenced in @".concat(directive.name.value, " directive."))
|
|
244
249
|
},
|
|
245
250
|
|
|
246
|
-
|
|
251
|
+
41: {
|
|
247
252
|
file: "@apollo/client/utilities/graphql/directives.js",
|
|
248
253
|
node: invariant(directiveArguments && directiveArguments.length === 1, "Incorrect number of arguments for the @".concat(directiveName, " directive."))
|
|
249
254
|
},
|
|
250
255
|
|
|
251
|
-
|
|
256
|
+
42: {
|
|
252
257
|
file: "@apollo/client/utilities/graphql/directives.js",
|
|
253
258
|
node: invariant(ifArgument.name && ifArgument.name.value === 'if', "Invalid argument for the @".concat(directiveName, " directive."))
|
|
254
259
|
},
|
|
255
260
|
|
|
256
|
-
|
|
261
|
+
43: {
|
|
257
262
|
file: "@apollo/client/utilities/graphql/directives.js",
|
|
258
263
|
|
|
259
264
|
node: invariant(ifValue &&
|
|
260
265
|
(ifValue.kind === 'Variable' || ifValue.kind === 'BooleanValue'), "Argument for the @".concat(directiveName, " directive must be a variable or a boolean value."))
|
|
261
266
|
},
|
|
262
267
|
|
|
263
|
-
|
|
268
|
+
44: {
|
|
264
269
|
file: "@apollo/client/utilities/graphql/fragments.js",
|
|
265
270
|
|
|
266
271
|
node: new InvariantError("Found a ".concat(definition.operation, " operation").concat(definition.name ? " named '".concat(definition.name.value, "'") : '', ". ") +
|
|
267
272
|
'No operations are allowed when using a fragment as a query. Only fragments are allowed.')
|
|
268
273
|
},
|
|
269
274
|
|
|
270
|
-
|
|
275
|
+
45: {
|
|
271
276
|
file: "@apollo/client/utilities/graphql/fragments.js",
|
|
272
277
|
node: invariant(fragments.length === 1, "Found ".concat(fragments.length, " fragments. `fragmentName` must be provided when there is not exactly 1 fragment."))
|
|
273
278
|
},
|
|
274
279
|
|
|
275
|
-
|
|
280
|
+
46: {
|
|
276
281
|
file: "@apollo/client/utilities/graphql/fragments.js",
|
|
277
282
|
node: invariant(fragment, "No fragment named ".concat(fragmentName))
|
|
278
283
|
},
|
|
279
284
|
|
|
280
|
-
|
|
285
|
+
47: {
|
|
281
286
|
file: "@apollo/client/utilities/graphql/getFromAST.js",
|
|
282
287
|
node: 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")
|
|
283
288
|
},
|
|
284
289
|
|
|
285
|
-
|
|
290
|
+
48: {
|
|
286
291
|
file: "@apollo/client/utilities/graphql/getFromAST.js",
|
|
287
292
|
node: new InvariantError("Schema type definitions not allowed in queries. Found: \"".concat(definition.kind, "\""))
|
|
288
293
|
},
|
|
289
294
|
|
|
290
|
-
|
|
295
|
+
49: {
|
|
291
296
|
file: "@apollo/client/utilities/graphql/getFromAST.js",
|
|
292
297
|
node: invariant(operations.length <= 1, "Ambiguous GraphQL document: contains ".concat(operations.length, " operations"))
|
|
293
298
|
},
|
|
294
299
|
|
|
295
|
-
|
|
300
|
+
50: {
|
|
296
301
|
file: "@apollo/client/utilities/graphql/getFromAST.js",
|
|
297
302
|
node: invariant(queryDef && queryDef.operation === 'query', 'Must contain a query definition.')
|
|
298
303
|
},
|
|
299
304
|
|
|
300
|
-
|
|
305
|
+
51: {
|
|
301
306
|
file: "@apollo/client/utilities/graphql/getFromAST.js",
|
|
302
307
|
node: 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")
|
|
303
308
|
},
|
|
304
309
|
|
|
305
|
-
|
|
310
|
+
52: {
|
|
306
311
|
file: "@apollo/client/utilities/graphql/getFromAST.js",
|
|
307
312
|
node: invariant(doc.definitions.length <= 1, 'Fragment must have exactly one definition.')
|
|
308
313
|
},
|
|
309
314
|
|
|
310
|
-
|
|
315
|
+
53: {
|
|
311
316
|
file: "@apollo/client/utilities/graphql/getFromAST.js",
|
|
312
317
|
node: invariant(fragmentDef.kind === 'FragmentDefinition', 'Must be a fragment definition.')
|
|
313
318
|
},
|
|
314
319
|
|
|
315
|
-
|
|
320
|
+
54: {
|
|
316
321
|
file: "@apollo/client/utilities/graphql/getFromAST.js",
|
|
317
322
|
node: new InvariantError('Expected a parsed GraphQL query with a query, mutation, subscription, or a fragment.')
|
|
318
323
|
},
|
|
319
324
|
|
|
320
|
-
|
|
325
|
+
55: {
|
|
321
326
|
file: "@apollo/client/utilities/graphql/storeUtils.js",
|
|
322
327
|
|
|
323
328
|
node: new InvariantError("The inline argument \"".concat(name.value, "\" of kind \"").concat(value.kind, "\"") +
|
package/link/batch/batch.cjs
CHANGED
|
@@ -10,6 +10,7 @@ var OperationBatcher = (function () {
|
|
|
10
10
|
function OperationBatcher(_a) {
|
|
11
11
|
var batchDebounce = _a.batchDebounce, batchInterval = _a.batchInterval, batchMax = _a.batchMax, batchHandler = _a.batchHandler, batchKey = _a.batchKey;
|
|
12
12
|
this.batchesByKey = new Map();
|
|
13
|
+
this.scheduledBatchTimerByKey = new Map();
|
|
13
14
|
this.batchDebounce = batchDebounce;
|
|
14
15
|
this.batchInterval = batchInterval;
|
|
15
16
|
this.batchMax = batchMax || 0;
|
|
@@ -118,10 +119,11 @@ var OperationBatcher = (function () {
|
|
|
118
119
|
};
|
|
119
120
|
OperationBatcher.prototype.scheduleQueueConsumption = function (key) {
|
|
120
121
|
var _this = this;
|
|
121
|
-
clearTimeout(this.
|
|
122
|
-
this.
|
|
122
|
+
clearTimeout(this.scheduledBatchTimerByKey.get(key));
|
|
123
|
+
this.scheduledBatchTimerByKey.set(key, setTimeout(function () {
|
|
123
124
|
_this.consumeQueue(key);
|
|
124
|
-
|
|
125
|
+
_this.scheduledBatchTimerByKey.delete(key);
|
|
126
|
+
}, this.batchInterval));
|
|
125
127
|
};
|
|
126
128
|
return OperationBatcher;
|
|
127
129
|
}());
|
package/link/batch/batch.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"batch.cjs","sources":["batching.js","batchLink.js"],"sourcesContent":["import { __assign } from \"tslib\";\nimport { Observable } from '../../utilities';\nvar OperationBatcher = (function () {\n function OperationBatcher(_a) {\n var batchDebounce = _a.batchDebounce, batchInterval = _a.batchInterval, batchMax = _a.batchMax, batchHandler = _a.batchHandler, batchKey = _a.batchKey;\n this.batchesByKey = new Map();\n this.batchDebounce = batchDebounce;\n this.batchInterval = batchInterval;\n this.batchMax = batchMax || 0;\n this.batchHandler = batchHandler;\n this.batchKey = batchKey || (function () { return ''; });\n }\n OperationBatcher.prototype.enqueueRequest = function (request) {\n var _this = this;\n var requestCopy = __assign(__assign({}, request), { next: [], error: [], complete: [], subscribers: new Set() });\n var key = this.batchKey(request.operation);\n if (!requestCopy.observable) {\n requestCopy.observable = new Observable(function (observer) {\n var batch = _this.batchesByKey.get(key);\n if (!batch)\n _this.batchesByKey.set(key, batch = new Set());\n var isFirstEnqueuedRequest = batch.size === 0;\n var isFirstSubscriber = requestCopy.subscribers.size === 0;\n requestCopy.subscribers.add(observer);\n if (isFirstSubscriber) {\n batch.add(requestCopy);\n }\n if (observer.next) {\n requestCopy.next.push(observer.next.bind(observer));\n }\n if (observer.error) {\n requestCopy.error.push(observer.error.bind(observer));\n }\n if (observer.complete) {\n requestCopy.complete.push(observer.complete.bind(observer));\n }\n if (isFirstEnqueuedRequest || _this.batchDebounce) {\n _this.scheduleQueueConsumption(key);\n }\n if (batch.size === _this.batchMax) {\n _this.consumeQueue(key);\n }\n return function () {\n var _a;\n if (requestCopy.subscribers.delete(observer) &&\n requestCopy.subscribers.size < 1) {\n if (batch.delete(requestCopy) && batch.size < 1) {\n _this.consumeQueue(key);\n (_a = batch.subscription) === null || _a === void 0 ? void 0 : _a.unsubscribe();\n }\n }\n };\n });\n }\n return requestCopy.observable;\n };\n OperationBatcher.prototype.consumeQueue = function (key) {\n if (key === void 0) { key = ''; }\n var batch = this.batchesByKey.get(key);\n this.batchesByKey.delete(key);\n if (!batch || !batch.size) {\n return;\n }\n var operations = [];\n var forwards = [];\n var observables = [];\n var nexts = [];\n var errors = [];\n var completes = [];\n batch.forEach(function (request) {\n operations.push(request.operation);\n forwards.push(request.forward);\n observables.push(request.observable);\n nexts.push(request.next);\n errors.push(request.error);\n completes.push(request.complete);\n });\n var batchedObservable = this.batchHandler(operations, forwards) || Observable.of();\n var onError = function (error) {\n errors.forEach(function (rejecters) {\n if (rejecters) {\n rejecters.forEach(function (e) { return e(error); });\n }\n });\n };\n batch.subscription = batchedObservable.subscribe({\n next: function (results) {\n if (!Array.isArray(results)) {\n results = [results];\n }\n if (nexts.length !== results.length) {\n var error = new Error(\"server returned results with length \".concat(results.length, \", expected length of \").concat(nexts.length));\n error.result = results;\n return onError(error);\n }\n results.forEach(function (result, index) {\n if (nexts[index]) {\n nexts[index].forEach(function (next) { return next(result); });\n }\n });\n },\n error: onError,\n complete: function () {\n completes.forEach(function (complete) {\n if (complete) {\n complete.forEach(function (c) { return c(); });\n }\n });\n },\n });\n return observables;\n };\n OperationBatcher.prototype.scheduleQueueConsumption = function (key) {\n var _this = this;\n clearTimeout(this.scheduledBatchTimer);\n this.scheduledBatchTimer = setTimeout(function () {\n _this.consumeQueue(key);\n }, this.batchInterval);\n };\n return OperationBatcher;\n}());\nexport { OperationBatcher };\n//# sourceMappingURL=batching.js.map","import { __extends } from \"tslib\";\nimport { ApolloLink } from '../core';\nimport { OperationBatcher } from './batching';\nexport { OperationBatcher } from './batching';\nvar BatchLink = (function (_super) {\n __extends(BatchLink, _super);\n function BatchLink(fetchParams) {\n var _this = _super.call(this) || this;\n var _a = fetchParams || {}, batchDebounce = _a.batchDebounce, _b = _a.batchInterval, batchInterval = _b === void 0 ? 10 : _b, _c = _a.batchMax, batchMax = _c === void 0 ? 0 : _c, _d = _a.batchHandler, batchHandler = _d === void 0 ? function () { return null; } : _d, _e = _a.batchKey, batchKey = _e === void 0 ? function () { return ''; } : _e;\n _this.batcher = new OperationBatcher({\n batchDebounce: batchDebounce,\n batchInterval: batchInterval,\n batchMax: batchMax,\n batchHandler: batchHandler,\n batchKey: batchKey,\n });\n if (fetchParams.batchHandler.length <= 1) {\n _this.request = function (operation) { return _this.batcher.enqueueRequest({ operation: operation }); };\n }\n return _this;\n }\n BatchLink.prototype.request = function (operation, forward) {\n return this.batcher.enqueueRequest({\n operation: operation,\n forward: forward,\n });\n };\n return BatchLink;\n}(ApolloLink));\nexport { BatchLink };\n//# sourceMappingURL=batchLink.js.map"],"names":["__assign","Observable","__extends","ApolloLink"],"mappings":";;;;;;;;AAEG,IAAC,gBAAgB,IAAI,YAAY;AACpC,IAAI,SAAS,gBAAgB,CAAC,EAAE,EAAE;AAClC,QAAQ,IAAI,aAAa,GAAG,EAAE,CAAC,aAAa,EAAE,aAAa,GAAG,EAAE,CAAC,aAAa,EAAE,QAAQ,GAAG,EAAE,CAAC,QAAQ,EAAE,YAAY,GAAG,EAAE,CAAC,YAAY,EAAE,QAAQ,GAAG,EAAE,CAAC,QAAQ,CAAC;AAC/J,QAAQ,IAAI,CAAC,YAAY,GAAG,IAAI,GAAG,EAAE,CAAC;AACtC,QAAQ,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;AAC3C,QAAQ,I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I,SAAS,CAAC,SAAS,CAAC,OAAO,GAAG,UAAU,SAAS,EAAE,OAAO,EAAE;AAChE,QAAQ,OAAO,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC;AAC3C,YAAY,SAAS,EAAE,SAAS;AAChC,YAAY,OAAO,EAAE,OAAO;AAC5B,SAAS,CAAC,CAAC;AACX,KAAK,CAAC;AACN,IAAI,OAAO,SAAS,CAAC;AACrB,CAAC,CAACC,eAAU,CAAC;;;;;"}
|
|
1
|
+
{"version":3,"file":"batch.cjs","sources":["batching.js","batchLink.js"],"sourcesContent":["import { __assign } from \"tslib\";\nimport { Observable } from '../../utilities';\nvar OperationBatcher = (function () {\n function OperationBatcher(_a) {\n var batchDebounce = _a.batchDebounce, batchInterval = _a.batchInterval, batchMax = _a.batchMax, batchHandler = _a.batchHandler, batchKey = _a.batchKey;\n this.batchesByKey = new Map();\n this.scheduledBatchTimerByKey = new Map();\n this.batchDebounce = batchDebounce;\n this.batchInterval = batchInterval;\n this.batchMax = batchMax || 0;\n this.batchHandler = batchHandler;\n this.batchKey = batchKey || (function () { return ''; });\n }\n OperationBatcher.prototype.enqueueRequest = function (request) {\n var _this = this;\n var requestCopy = __assign(__assign({}, request), { next: [], error: [], complete: [], subscribers: new Set() });\n var key = this.batchKey(request.operation);\n if (!requestCopy.observable) {\n requestCopy.observable = new Observable(function (observer) {\n var batch = _this.batchesByKey.get(key);\n if (!batch)\n _this.batchesByKey.set(key, batch = new Set());\n var isFirstEnqueuedRequest = batch.size === 0;\n var isFirstSubscriber = requestCopy.subscribers.size === 0;\n requestCopy.subscribers.add(observer);\n if (isFirstSubscriber) {\n batch.add(requestCopy);\n }\n if (observer.next) {\n requestCopy.next.push(observer.next.bind(observer));\n }\n if (observer.error) {\n requestCopy.error.push(observer.error.bind(observer));\n }\n if (observer.complete) {\n requestCopy.complete.push(observer.complete.bind(observer));\n }\n if (isFirstEnqueuedRequest || _this.batchDebounce) {\n _this.scheduleQueueConsumption(key);\n }\n if (batch.size === _this.batchMax) {\n _this.consumeQueue(key);\n }\n return function () {\n var _a;\n if (requestCopy.subscribers.delete(observer) &&\n requestCopy.subscribers.size < 1) {\n if (batch.delete(requestCopy) && batch.size < 1) {\n _this.consumeQueue(key);\n (_a = batch.subscription) === null || _a === void 0 ? void 0 : _a.unsubscribe();\n }\n }\n };\n });\n }\n return requestCopy.observable;\n };\n OperationBatcher.prototype.consumeQueue = function (key) {\n if (key === void 0) { key = ''; }\n var batch = this.batchesByKey.get(key);\n this.batchesByKey.delete(key);\n if (!batch || !batch.size) {\n return;\n }\n var operations = [];\n var forwards = [];\n var observables = [];\n var nexts = [];\n var errors = [];\n var completes = [];\n batch.forEach(function (request) {\n operations.push(request.operation);\n forwards.push(request.forward);\n observables.push(request.observable);\n nexts.push(request.next);\n errors.push(request.error);\n completes.push(request.complete);\n });\n var batchedObservable = this.batchHandler(operations, forwards) || Observable.of();\n var onError = function (error) {\n errors.forEach(function (rejecters) {\n if (rejecters) {\n rejecters.forEach(function (e) { return e(error); });\n }\n });\n };\n batch.subscription = batchedObservable.subscribe({\n next: function (results) {\n if (!Array.isArray(results)) {\n results = [results];\n }\n if (nexts.length !== results.length) {\n var error = new Error(\"server returned results with length \".concat(results.length, \", expected length of \").concat(nexts.length));\n error.result = results;\n return onError(error);\n }\n results.forEach(function (result, index) {\n if (nexts[index]) {\n nexts[index].forEach(function (next) { return next(result); });\n }\n });\n },\n error: onError,\n complete: function () {\n completes.forEach(function (complete) {\n if (complete) {\n complete.forEach(function (c) { return c(); });\n }\n });\n },\n });\n return observables;\n };\n OperationBatcher.prototype.scheduleQueueConsumption = function (key) {\n var _this = this;\n clearTimeout(this.scheduledBatchTimerByKey.get(key));\n this.scheduledBatchTimerByKey.set(key, setTimeout(function () {\n _this.consumeQueue(key);\n _this.scheduledBatchTimerByKey.delete(key);\n }, this.batchInterval));\n };\n return OperationBatcher;\n}());\nexport { OperationBatcher };\n//# sourceMappingURL=batching.js.map","import { __extends } from \"tslib\";\nimport { ApolloLink } from '../core';\nimport { OperationBatcher } from './batching';\nexport { OperationBatcher } from './batching';\nvar BatchLink = (function (_super) {\n __extends(BatchLink, _super);\n function BatchLink(fetchParams) {\n var _this = _super.call(this) || this;\n var _a = fetchParams || {}, batchDebounce = _a.batchDebounce, _b = _a.batchInterval, batchInterval = _b === void 0 ? 10 : _b, _c = _a.batchMax, batchMax = _c === void 0 ? 0 : _c, _d = _a.batchHandler, batchHandler = _d === void 0 ? function () { return null; } : _d, _e = _a.batchKey, batchKey = _e === void 0 ? function () { return ''; } : _e;\n _this.batcher = new OperationBatcher({\n batchDebounce: batchDebounce,\n batchInterval: batchInterval,\n batchMax: batchMax,\n batchHandler: batchHandler,\n batchKey: batchKey,\n });\n if (fetchParams.batchHandler.length <= 1) {\n _this.request = function (operation) { return _this.batcher.enqueueRequest({ operation: operation }); };\n }\n return _this;\n }\n BatchLink.prototype.request = function (operation, forward) {\n return this.batcher.enqueueRequest({\n operation: operation,\n forward: forward,\n });\n };\n return BatchLink;\n}(ApolloLink));\nexport { BatchLink };\n//# sourceMappingURL=batchLink.js.map"],"names":["__assign","Observable","__extends","ApolloLink"],"mappings":";;;;;;;;AAEG,IAAC,gBAAgB,IAAI,YAAY;AACpC,IAAI,SAAS,gBAAgB,CAAC,EAAE,EAAE;AAClC,QAAQ,IAAI,aAAa,GAAG,EAAE,CAAC,aAAa,EAAE,aAAa,GAAG,EAAE,CAAC,aAAa,EAAE,QAAQ,GAAG,EAAE,CAAC,QAAQ,EAAE,YAAY,GAAG,EAAE,CAAC,YAAY,EAAE,QAAQ,GAAG,EAAE,CAAC,QAAQ,CAAC;AAC/J,QAAQ,IAAI,CAAC,YAAY,GAAG,IAAI,GAAG,EAAE,CAAC;AACtC,QAAQ,IAAI,CAAC,wBAAwB,GAAG,IAAI,GAAG,EAAE,CAAC;AAClD,QAAQ,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;AAC3C,QAAQ,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;AAC3C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AAC,CAAC,EAAE,CAAC;AACpH,SAAS;AACT,QAAQ,OAAO,KAAK,CAAC;AACrB,KAAK;AACL,IAAI,SAAS,CAAC,SAAS,CAAC,OAAO,GAAG,UAAU,SAAS,EAAE,OAAO,EAAE;AAChE,QAAQ,OAAO,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC;AAC3C,YAAY,SAAS,EAAE,SAAS;AAChC,YAAY,OAAO,EAAE,OAAO;AAC5B,SAAS,CAAC,CAAC;AACX,KAAK,CAAC;AACN,IAAI,OAAO,SAAS,CAAC;AACrB,CAAC,CAACC,eAAU,CAAC;;;;;"}
|
|
@@ -10,6 +10,7 @@ var OperationBatcher = (function () {
|
|
|
10
10
|
function OperationBatcher(_a) {
|
|
11
11
|
var batchDebounce = _a.batchDebounce, batchInterval = _a.batchInterval, batchMax = _a.batchMax, batchHandler = _a.batchHandler, batchKey = _a.batchKey;
|
|
12
12
|
this.batchesByKey = new Map();
|
|
13
|
+
this.scheduledBatchTimerByKey = new Map();
|
|
13
14
|
this.batchDebounce = batchDebounce;
|
|
14
15
|
this.batchInterval = batchInterval;
|
|
15
16
|
this.batchMax = batchMax || 0;
|
|
@@ -118,10 +119,11 @@ var OperationBatcher = (function () {
|
|
|
118
119
|
};
|
|
119
120
|
OperationBatcher.prototype.scheduleQueueConsumption = function (key) {
|
|
120
121
|
var _this = this;
|
|
121
|
-
clearTimeout(this.
|
|
122
|
-
this.
|
|
122
|
+
clearTimeout(this.scheduledBatchTimerByKey.get(key));
|
|
123
|
+
this.scheduledBatchTimerByKey.set(key, setTimeout(function () {
|
|
123
124
|
_this.consumeQueue(key);
|
|
124
|
-
|
|
125
|
+
_this.scheduledBatchTimerByKey.delete(key);
|
|
126
|
+
}, this.batchInterval));
|
|
125
127
|
};
|
|
126
128
|
return OperationBatcher;
|
|
127
129
|
}());
|
package/link/batch/batching.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { FetchResult, NextLink, Operation } from '../core';
|
|
2
2
|
import { Observable } from '../../utilities';
|
|
3
|
-
export
|
|
3
|
+
export type BatchHandler = (operations: Operation[], forward?: (NextLink | undefined)[]) => Observable<FetchResult[]> | null;
|
|
4
4
|
export interface BatchableRequest {
|
|
5
5
|
operation: Operation;
|
|
6
6
|
forward?: NextLink;
|
|
7
7
|
}
|
|
8
8
|
export declare class OperationBatcher {
|
|
9
9
|
private batchesByKey;
|
|
10
|
-
private
|
|
10
|
+
private scheduledBatchTimerByKey;
|
|
11
11
|
private batchDebounce?;
|
|
12
12
|
private batchInterval?;
|
|
13
13
|
private batchMax;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"batching.d.ts","sourceRoot":"","sources":["../../../src/link/batch/batching.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAC3D,OAAO,EAAE,UAAU,EAA0B,MAAM,iBAAiB,CAAC;AAErE,
|
|
1
|
+
{"version":3,"file":"batching.d.ts","sourceRoot":"","sources":["../../../src/link/batch/batching.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAC3D,OAAO,EAAE,UAAU,EAA0B,MAAM,iBAAiB,CAAC;AAErE,MAAM,MAAM,YAAY,GAAG,CACzB,UAAU,EAAE,SAAS,EAAE,EACvB,OAAO,CAAC,EAAE,CAAC,QAAQ,GAAG,SAAS,CAAC,EAAE,KAC/B,UAAU,CAAC,WAAW,EAAE,CAAC,GAAG,IAAI,CAAC;AAEtC,MAAM,WAAW,gBAAgB;IAC/B,SAAS,EAAE,SAAS,CAAC;IACrB,OAAO,CAAC,EAAE,QAAQ,CAAC;CACpB;AAmBD,qBAAa,gBAAgB;IAE3B,OAAO,CAAC,YAAY,CAAmC;IAEvD,OAAO,CAAC,wBAAwB,CAAoD;IACpF,OAAO,CAAC,aAAa,CAAC,CAAU;IAChC,OAAO,CAAC,aAAa,CAAC,CAAS;IAC/B,OAAO,CAAC,QAAQ,CAAS;IAGzB,OAAO,CAAC,YAAY,CAAe;IACnC,OAAO,CAAC,QAAQ,CAAmC;gBAEvC,EACV,aAAa,EACb,aAAa,EACb,QAAQ,EACR,YAAY,EACZ,QAAQ,GACT,EAAE;QACD,aAAa,CAAC,EAAE,OAAO,CAAC;QACxB,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,YAAY,EAAE,YAAY,CAAC;QAC3B,QAAQ,CAAC,EAAE,CAAC,SAAS,EAAE,SAAS,KAAK,MAAM,CAAC;KAC7C;IAQM,cAAc,CAAC,OAAO,EAAE,gBAAgB,GAAG,UAAU,CAAC,WAAW,CAAC;IAqElE,YAAY,CACjB,GAAG,GAAE,MAAW,GACf,CAAC,UAAU,CAAC,WAAW,CAAC,GAAG,SAAS,CAAC,EAAE,GAAG,SAAS;IA8EtD,OAAO,CAAC,wBAAwB;CAOjC"}
|
package/link/batch/batching.js
CHANGED
|
@@ -4,6 +4,7 @@ var OperationBatcher = (function () {
|
|
|
4
4
|
function OperationBatcher(_a) {
|
|
5
5
|
var batchDebounce = _a.batchDebounce, batchInterval = _a.batchInterval, batchMax = _a.batchMax, batchHandler = _a.batchHandler, batchKey = _a.batchKey;
|
|
6
6
|
this.batchesByKey = new Map();
|
|
7
|
+
this.scheduledBatchTimerByKey = new Map();
|
|
7
8
|
this.batchDebounce = batchDebounce;
|
|
8
9
|
this.batchInterval = batchInterval;
|
|
9
10
|
this.batchMax = batchMax || 0;
|
|
@@ -112,10 +113,11 @@ var OperationBatcher = (function () {
|
|
|
112
113
|
};
|
|
113
114
|
OperationBatcher.prototype.scheduleQueueConsumption = function (key) {
|
|
114
115
|
var _this = this;
|
|
115
|
-
clearTimeout(this.
|
|
116
|
-
this.
|
|
116
|
+
clearTimeout(this.scheduledBatchTimerByKey.get(key));
|
|
117
|
+
this.scheduledBatchTimerByKey.set(key, setTimeout(function () {
|
|
117
118
|
_this.consumeQueue(key);
|
|
118
|
-
|
|
119
|
+
_this.scheduledBatchTimerByKey.delete(key);
|
|
120
|
+
}, this.batchInterval));
|
|
119
121
|
};
|
|
120
122
|
return OperationBatcher;
|
|
121
123
|
}());
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"batching.js","sourceRoot":"","sources":["../../../src/link/batch/batching.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,UAAU,EAA0B,MAAM,iBAAiB,CAAC;AA6BrE;IAaE,0BAAY,EAYX;YAXC,aAAa,mBAAA,EACb,aAAa,mBAAA,EACb,QAAQ,cAAA,EACR,YAAY,kBAAA,EACZ,QAAQ,cAAA;QAhBF,iBAAY,GAAG,IAAI,GAAG,EAAwB,CAAC;QAwBrD,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,CAAC,QAAQ,GAAG,QAAQ,IAAI,CAAC,CAAC;QAC9B,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,QAAQ,GAAG,QAAQ,IAAI,CAAC,cAAM,OAAA,EAAE,EAAF,CAAE,CAAC,CAAC;IACzC,CAAC;IAEM,yCAAc,GAArB,UAAsB,OAAyB;QAA/C,iBAiEC;QAhEC,IAAM,WAAW,yBACZ,OAAO,KACV,IAAI,EAAE,EAAE,EACR,KAAK,EAAE,EAAE,EACT,QAAQ,EAAE,EAAE,EACZ,WAAW,EAAE,IAAI,GAAG,EAAE,GACvB,CAAC;QAEF,IAAM,GAAG,GAAG,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QAE7C,IAAI,CAAC,WAAW,CAAC,UAAU,EAAE;YAC3B,WAAW,CAAC,UAAU,GAAG,IAAI,UAAU,CAAc,UAAA,QAAQ;gBAC3D,IAAI,KAAK,GAAG,KAAI,CAAC,YAAY,CAAC,GAAG,CAAC,GAAG,CAAE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AEZ,QAAQ,CAAC,OAAO,CAAC,UAAC,CAAC,IAAK,OAAA,CAAC,EAAE,EAAH,CAAG,CAAC,CAAC;qBAC9B;gBACH,CAAC,CAAC,CAAC;YACL,CAAC;SACF,CAAC,CAAC;QAEH,OAAO,WAAW,CAAC;IACrB,CAAC;IAEO,mDAAwB,GAAhC,UAAiC,GAAW;QAA5C,iBAKC;QAJC,YAAY,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;QACvC,IAAI,CAAC,mBAAmB,GAAG,UAAU,CAAC;YACpC,KAAI,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;QACzB,CAAC,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;IACzB,CAAC;IACH,uBAAC;AAAD,CAAC,AA5LD,IA4LC","sourcesContent":["import { FetchResult, NextLink, Operation } from '../core';\nimport { Observable, ObservableSubscription } from '../../utilities';\n\nexport type BatchHandler = (\n operations: Operation[],\n forward?: (NextLink | undefined)[],\n) => Observable<FetchResult[]> | null;\n\nexport interface BatchableRequest {\n operation: Operation;\n forward?: NextLink;\n}\n\ntype QueuedRequest = BatchableRequest & {\n observable?: Observable<FetchResult>;\n next: Array<(result: FetchResult) => void>;\n error: Array<(error: Error) => void>;\n complete: Array<() => void>;\n subscribers: Set<object>;\n}\n\n// Batches are primarily a Set<QueuedRequest>, but may have other optional\n// properties, such as batch.subscription.\ntype RequestBatch = Set<QueuedRequest> & {\n subscription?: ObservableSubscription;\n}\n\n// QueryBatcher doesn't fire requests immediately. Requests that were enqueued within\n// a certain amount of time (configurable through `batchInterval`) will be batched together\n// into one query.\nexport class OperationBatcher {\n // Queue on which the QueryBatcher will operate on a per-tick basis.\n private batchesByKey = new Map<string, RequestBatch>();\n\n private scheduledBatchTimer: ReturnType<typeof setTimeout>;\n private batchDebounce?: boolean;\n private batchInterval?: number;\n private batchMax: number;\n\n //This function is called to the queries in the queue to the server.\n private batchHandler: BatchHandler;\n private batchKey: (operation: Operation) => string;\n\n constructor({\n batchDebounce,\n batchInterval,\n batchMax,\n batchHandler,\n batchKey,\n }: {\n batchDebounce?: boolean;\n batchInterval?: number;\n batchMax?: number;\n batchHandler: BatchHandler;\n batchKey?: (operation: Operation) => string;\n }) {\n this.batchDebounce = batchDebounce;\n this.batchInterval = batchInterval;\n this.batchMax = batchMax || 0;\n this.batchHandler = batchHandler;\n this.batchKey = batchKey || (() => '');\n }\n\n public enqueueRequest(request: BatchableRequest): Observable<FetchResult> {\n const requestCopy: QueuedRequest = {\n ...request,\n next: [],\n error: [],\n complete: [],\n subscribers: new Set(),\n };\n\n const key = this.batchKey(request.operation);\n\n if (!requestCopy.observable) {\n requestCopy.observable = new Observable<FetchResult>(observer => {\n let batch = this.batchesByKey.get(key)!;\n if (!batch) this.batchesByKey.set(key, batch = new Set());\n\n // These booleans seem to me (@benjamn) like they might always be the\n // same (and thus we could do with only one of them), but I'm not 100%\n // sure about that.\n const isFirstEnqueuedRequest = batch.size === 0;\n const isFirstSubscriber = requestCopy.subscribers.size === 0;\n requestCopy.subscribers.add(observer);\n if (isFirstSubscriber) {\n batch.add(requestCopy);\n }\n\n // called for each subscriber, so need to save all listeners (next, error, complete)\n if (observer.next) {\n requestCopy.next.push(observer.next.bind(observer));\n }\n\n if (observer.error) {\n requestCopy.error.push(observer.error.bind(observer));\n }\n\n if (observer.complete) {\n requestCopy.complete.push(observer.complete.bind(observer));\n }\n\n // The first enqueued request triggers the queue consumption after `batchInterval` milliseconds.\n if (isFirstEnqueuedRequest || this.batchDebounce) {\n this.scheduleQueueConsumption(key);\n }\n\n // When amount of requests reaches `batchMax`, trigger the queue consumption without waiting on the `batchInterval`.\n if (batch.size === this.batchMax) {\n this.consumeQueue(key);\n }\n\n return () => {\n // If this is last subscriber for this request, remove request from queue\n if (requestCopy.subscribers.delete(observer) &&\n requestCopy.subscribers.size < 1) {\n // If this is last request from queue, remove queue entirely\n if (batch.delete(requestCopy) && batch.size < 1) {\n this.consumeQueue(key);\n // If queue was in flight, cancel it\n batch.subscription?.unsubscribe();\n }\n }\n }\n });\n }\n\n return requestCopy.observable;\n }\n\n // Consumes the queue.\n // Returns a list of promises (one for each query).\n public consumeQueue(\n key: string = '',\n ): (Observable<FetchResult> | undefined)[] | undefined {\n const batch = this.batchesByKey.get(key);\n // Delete this batch and process it below.\n this.batchesByKey.delete(key);\n if (!batch || !batch.size) {\n // No requests to be processed.\n return;\n }\n\n const operations: QueuedRequest['operation'][] = [];\n const forwards: QueuedRequest['forward'][] = [];\n const observables: QueuedRequest['observable'][] = [];\n const nexts: QueuedRequest['next'][] = [];\n const errors: QueuedRequest['error'][] = [];\n const completes: QueuedRequest['complete'][] = [];\n\n // Even though batch is a Set, it preserves the order of first insertion\n // when iterating (per ECMAScript specification), so these requests will be\n // handled in the order they were enqueued (minus any deleted ones).\n batch.forEach(request => {\n operations.push(request.operation);\n forwards.push(request.forward);\n observables.push(request.observable);\n nexts.push(request.next);\n errors.push(request.error);\n completes.push(request.complete);\n });\n\n const batchedObservable =\n this.batchHandler(operations, forwards) || Observable.of();\n\n const onError = (error: Error) => {\n //each callback list in batch\n errors.forEach(rejecters => {\n if (rejecters) {\n //each subscriber to request\n rejecters.forEach((e) => e(error));\n }\n });\n };\n\n batch.subscription = batchedObservable.subscribe({\n next: results => {\n if (!Array.isArray(results)) {\n results = [results];\n }\n\n if (nexts.length !== results.length) {\n const error = new Error(\n `server returned results with length ${\n results.length\n }, expected length of ${nexts.length}`,\n );\n (error as any).result = results;\n\n return onError(error);\n }\n\n results.forEach((result, index) => {\n if (nexts[index]) {\n nexts[index].forEach((next) => next(result));\n }\n });\n },\n error: onError,\n complete: () => {\n completes.forEach(complete => {\n if (complete) {\n //each subscriber to request\n complete.forEach((c) => c());\n }\n });\n },\n });\n\n return observables;\n }\n\n private scheduleQueueConsumption(key: string): void {\n clearTimeout(this.scheduledBatchTimer);\n this.scheduledBatchTimer = setTimeout(() => {\n this.consumeQueue(key);\n }, this.batchInterval);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":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,WAAW,CAAC;IACrB,CAAC;IAEO,mDAAwB,GAAhC,UAAiC,GAAW;QAA5C,iBAMC;QALC,YAAY,CAAC,IAAI,CAAC,wBAAwB,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;QACrD,IAAI,CAAC,wBAAwB,CAAC,GAAG,CAAC,GAAG,EAAE,UAAU,CAAC;YAChD,KAAI,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;YACvB,KAAI,CAAC,wBAAwB,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QAC5C,CAAC,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC;IAC1B,CAAC;IACH,uBAAC;AAAD,CAAC,AA7LD,IA6LC","sourcesContent":["import { FetchResult, NextLink, Operation } from '../core';\nimport { Observable, ObservableSubscription } from '../../utilities';\n\nexport type BatchHandler = (\n operations: Operation[],\n forward?: (NextLink | undefined)[],\n) => Observable<FetchResult[]> | null;\n\nexport interface BatchableRequest {\n operation: Operation;\n forward?: NextLink;\n}\n\ntype QueuedRequest = BatchableRequest & {\n observable?: Observable<FetchResult>;\n next: Array<(result: FetchResult) => void>;\n error: Array<(error: Error) => void>;\n complete: Array<() => void>;\n subscribers: Set<object>;\n}\n\n// Batches are primarily a Set<QueuedRequest>, but may have other optional\n// properties, such as batch.subscription.\ntype RequestBatch = Set<QueuedRequest> & {\n subscription?: ObservableSubscription;\n}\n\n// QueryBatcher doesn't fire requests immediately. Requests that were enqueued within\n// a certain amount of time (configurable through `batchInterval`) will be batched together\n// into one query.\nexport class OperationBatcher {\n // Queue on which the QueryBatcher will operate on a per-tick basis.\n private batchesByKey = new Map<string, RequestBatch>();\n\n private scheduledBatchTimerByKey = new Map<string, ReturnType<typeof setTimeout>>();\n private batchDebounce?: boolean;\n private batchInterval?: number;\n private batchMax: number;\n\n //This function is called to the queries in the queue to the server.\n private batchHandler: BatchHandler;\n private batchKey: (operation: Operation) => string;\n\n constructor({\n batchDebounce,\n batchInterval,\n batchMax,\n batchHandler,\n batchKey,\n }: {\n batchDebounce?: boolean;\n batchInterval?: number;\n batchMax?: number;\n batchHandler: BatchHandler;\n batchKey?: (operation: Operation) => string;\n }) {\n this.batchDebounce = batchDebounce;\n this.batchInterval = batchInterval;\n this.batchMax = batchMax || 0;\n this.batchHandler = batchHandler;\n this.batchKey = batchKey || (() => '');\n }\n\n public enqueueRequest(request: BatchableRequest): Observable<FetchResult> {\n const requestCopy: QueuedRequest = {\n ...request,\n next: [],\n error: [],\n complete: [],\n subscribers: new Set(),\n };\n\n const key = this.batchKey(request.operation);\n\n if (!requestCopy.observable) {\n requestCopy.observable = new Observable<FetchResult>(observer => {\n let batch = this.batchesByKey.get(key)!;\n if (!batch) this.batchesByKey.set(key, batch = new Set());\n\n // These booleans seem to me (@benjamn) like they might always be the\n // same (and thus we could do with only one of them), but I'm not 100%\n // sure about that.\n const isFirstEnqueuedRequest = batch.size === 0;\n const isFirstSubscriber = requestCopy.subscribers.size === 0;\n requestCopy.subscribers.add(observer);\n if (isFirstSubscriber) {\n batch.add(requestCopy);\n }\n\n // called for each subscriber, so need to save all listeners (next, error, complete)\n if (observer.next) {\n requestCopy.next.push(observer.next.bind(observer));\n }\n\n if (observer.error) {\n requestCopy.error.push(observer.error.bind(observer));\n }\n\n if (observer.complete) {\n requestCopy.complete.push(observer.complete.bind(observer));\n }\n\n // The first enqueued request triggers the queue consumption after `batchInterval` milliseconds.\n if (isFirstEnqueuedRequest || this.batchDebounce) {\n this.scheduleQueueConsumption(key);\n }\n\n // When amount of requests reaches `batchMax`, trigger the queue consumption without waiting on the `batchInterval`.\n if (batch.size === this.batchMax) {\n this.consumeQueue(key);\n }\n\n return () => {\n // If this is last subscriber for this request, remove request from queue\n if (requestCopy.subscribers.delete(observer) &&\n requestCopy.subscribers.size < 1) {\n // If this is last request from queue, remove queue entirely\n if (batch.delete(requestCopy) && batch.size < 1) {\n this.consumeQueue(key);\n // If queue was in flight, cancel it\n batch.subscription?.unsubscribe();\n }\n }\n }\n });\n }\n\n return requestCopy.observable;\n }\n\n // Consumes the queue.\n // Returns a list of promises (one for each query).\n public consumeQueue(\n key: string = '',\n ): (Observable<FetchResult> | undefined)[] | undefined {\n const batch = this.batchesByKey.get(key);\n // Delete this batch and process it below.\n this.batchesByKey.delete(key);\n if (!batch || !batch.size) {\n // No requests to be processed.\n return;\n }\n\n const operations: QueuedRequest['operation'][] = [];\n const forwards: QueuedRequest['forward'][] = [];\n const observables: QueuedRequest['observable'][] = [];\n const nexts: QueuedRequest['next'][] = [];\n const errors: QueuedRequest['error'][] = [];\n const completes: QueuedRequest['complete'][] = [];\n\n // Even though batch is a Set, it preserves the order of first insertion\n // when iterating (per ECMAScript specification), so these requests will be\n // handled in the order they were enqueued (minus any deleted ones).\n batch.forEach(request => {\n operations.push(request.operation);\n forwards.push(request.forward);\n observables.push(request.observable);\n nexts.push(request.next);\n errors.push(request.error);\n completes.push(request.complete);\n });\n\n const batchedObservable =\n this.batchHandler(operations, forwards) || Observable.of();\n\n const onError = (error: Error) => {\n //each callback list in batch\n errors.forEach(rejecters => {\n if (rejecters) {\n //each subscriber to request\n rejecters.forEach((e) => e(error));\n }\n });\n };\n\n batch.subscription = batchedObservable.subscribe({\n next: results => {\n if (!Array.isArray(results)) {\n results = [results];\n }\n\n if (nexts.length !== results.length) {\n const error = new Error(\n `server returned results with length ${\n results.length\n }, expected length of ${nexts.length}`,\n );\n (error as any).result = results;\n\n return onError(error);\n }\n\n results.forEach((result, index) => {\n if (nexts[index]) {\n nexts[index].forEach((next) => next(result));\n }\n });\n },\n error: onError,\n complete: () => {\n completes.forEach(complete => {\n if (complete) {\n //each subscriber to request\n complete.forEach((c) => c());\n }\n });\n },\n });\n\n return observables;\n }\n\n private scheduleQueueConsumption(key: string): void {\n clearTimeout(this.scheduledBatchTimerByKey.get(key));\n this.scheduledBatchTimerByKey.set(key, setTimeout(() => {\n this.consumeQueue(key);\n this.scheduledBatchTimerByKey.delete(key);\n }, this.batchInterval));\n }\n}\n"]}
|
package/link/context/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ApolloLink, GraphQLRequest } from '../core';
|
|
2
2
|
import { DefaultContext } from '../../core';
|
|
3
|
-
export
|
|
3
|
+
export type ContextSetter = (operation: GraphQLRequest, prevContext: DefaultContext) => Promise<DefaultContext> | DefaultContext;
|
|
4
4
|
export declare function setContext(setter: ContextSetter): ApolloLink;
|
|
5
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/link/context/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAa,cAAc,EAAY,MAAM,SAAS,CAAC;AAE1E,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE5C,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/link/context/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAa,cAAc,EAAY,MAAM,SAAS,CAAC;AAE1E,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE5C,MAAM,MAAM,aAAa,GAAG,CAC1B,SAAS,EAAE,cAAc,EACzB,WAAW,EAAE,cAAc,KACxB,OAAO,CAAC,cAAc,CAAC,GAAG,cAAc,CAAC;AAE9C,wBAAgB,UAAU,CAAC,MAAM,EAAE,aAAa,GAAG,UAAU,CA2B5D"}
|
package/link/core/ApolloLink.js
CHANGED
|
@@ -81,7 +81,7 @@ var ApolloLink = (function () {
|
|
|
81
81
|
return ApolloLink.concat(this, next);
|
|
82
82
|
};
|
|
83
83
|
ApolloLink.prototype.request = function (operation, forward) {
|
|
84
|
-
throw __DEV__ ? new InvariantError('request is not implemented') : new InvariantError(
|
|
84
|
+
throw __DEV__ ? new InvariantError('request is not implemented') : new InvariantError(22);
|
|
85
85
|
};
|
|
86
86
|
ApolloLink.prototype.onError = function (error, observer) {
|
|
87
87
|
if (observer && observer.error) {
|
package/link/core/core.cjs
CHANGED
|
@@ -86,7 +86,7 @@ var ApolloLink = (function () {
|
|
|
86
86
|
return ApolloLink.concat(this, next);
|
|
87
87
|
};
|
|
88
88
|
ApolloLink.prototype.request = function (operation, forward) {
|
|
89
|
-
throw __DEV__ ? new globals.InvariantError('request is not implemented') : new globals.InvariantError(
|
|
89
|
+
throw __DEV__ ? new globals.InvariantError('request is not implemented') : new globals.InvariantError(22);
|
|
90
90
|
};
|
|
91
91
|
ApolloLink.prototype.onError = function (error, observer) {
|
|
92
92
|
if (observer && observer.error) {
|
package/link/core/core.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core.cjs","sources":["ApolloLink.js","empty.js","from.js","split.js","concat.js","execute.js"],"sourcesContent":["import { __extends } from \"tslib\";\nimport { InvariantError, invariant } from '../../utilities/globals';\nimport { Observable } from '../../utilities';\nimport { validateOperation, createOperation, transformOperation, } from '../utils';\nfunction passthrough(op, forward) {\n return (forward ? forward(op) : Observable.of());\n}\nfunction toLink(handler) {\n return typeof handler === 'function' ? new ApolloLink(handler) : handler;\n}\nfunction isTerminating(link) {\n return link.request.length <= 1;\n}\nvar LinkError = (function (_super) {\n __extends(LinkError, _super);\n function LinkError(message, link) {\n var _this = _super.call(this, message) || this;\n _this.link = link;\n return _this;\n }\n return LinkError;\n}(Error));\nvar ApolloLink = (function () {\n function ApolloLink(request) {\n if (request)\n this.request = request;\n }\n ApolloLink.empty = function () {\n return new ApolloLink(function () { return Observable.of(); });\n };\n ApolloLink.from = function (links) {\n if (links.length === 0)\n return ApolloLink.empty();\n return links.map(toLink).reduce(function (x, y) { return x.concat(y); });\n };\n ApolloLink.split = function (test, left, right) {\n var leftLink = toLink(left);\n var rightLink = toLink(right || new ApolloLink(passthrough));\n if (isTerminating(leftLink) && isTerminating(rightLink)) {\n return new ApolloLink(function (operation) {\n return test(operation)\n ? leftLink.request(operation) || Observable.of()\n : rightLink.request(operation) || Observable.of();\n });\n }\n else {\n return new ApolloLink(function (operation, forward) {\n return test(operation)\n ? leftLink.request(operation, forward) || Observable.of()\n : rightLink.request(operation, forward) || Observable.of();\n });\n }\n };\n ApolloLink.execute = function (link, operation) {\n return (link.request(createOperation(operation.context, transformOperation(validateOperation(operation)))) || Observable.of());\n };\n ApolloLink.concat = function (first, second) {\n var firstLink = toLink(first);\n if (isTerminating(firstLink)) {\n __DEV__ && invariant.warn(new LinkError(\"You are calling concat on a terminating link, which will have no effect\", firstLink));\n return firstLink;\n }\n var nextLink = toLink(second);\n if (isTerminating(nextLink)) {\n return new ApolloLink(function (operation) {\n return firstLink.request(operation, function (op) { return nextLink.request(op) || Observable.of(); }) || Observable.of();\n });\n }\n else {\n return new ApolloLink(function (operation, forward) {\n return (firstLink.request(operation, function (op) {\n return nextLink.request(op, forward) || Observable.of();\n }) || Observable.of());\n });\n }\n };\n ApolloLink.prototype.split = function (test, left, right) {\n return this.concat(ApolloLink.split(test, left, right || new ApolloLink(passthrough)));\n };\n ApolloLink.prototype.concat = function (next) {\n return ApolloLink.concat(this, next);\n };\n ApolloLink.prototype.request = function (operation, forward) {\n throw __DEV__ ? new InvariantError('request is not implemented') : new InvariantError(
|
|
1
|
+
{"version":3,"file":"core.cjs","sources":["ApolloLink.js","empty.js","from.js","split.js","concat.js","execute.js"],"sourcesContent":["import { __extends } from \"tslib\";\nimport { InvariantError, invariant } from '../../utilities/globals';\nimport { Observable } from '../../utilities';\nimport { validateOperation, createOperation, transformOperation, } from '../utils';\nfunction passthrough(op, forward) {\n return (forward ? forward(op) : Observable.of());\n}\nfunction toLink(handler) {\n return typeof handler === 'function' ? new ApolloLink(handler) : handler;\n}\nfunction isTerminating(link) {\n return link.request.length <= 1;\n}\nvar LinkError = (function (_super) {\n __extends(LinkError, _super);\n function LinkError(message, link) {\n var _this = _super.call(this, message) || this;\n _this.link = link;\n return _this;\n }\n return LinkError;\n}(Error));\nvar ApolloLink = (function () {\n function ApolloLink(request) {\n if (request)\n this.request = request;\n }\n ApolloLink.empty = function () {\n return new ApolloLink(function () { return Observable.of(); });\n };\n ApolloLink.from = function (links) {\n if (links.length === 0)\n return ApolloLink.empty();\n return links.map(toLink).reduce(function (x, y) { return x.concat(y); });\n };\n ApolloLink.split = function (test, left, right) {\n var leftLink = toLink(left);\n var rightLink = toLink(right || new ApolloLink(passthrough));\n if (isTerminating(leftLink) && isTerminating(rightLink)) {\n return new ApolloLink(function (operation) {\n return test(operation)\n ? leftLink.request(operation) || Observable.of()\n : rightLink.request(operation) || Observable.of();\n });\n }\n else {\n return new ApolloLink(function (operation, forward) {\n return test(operation)\n ? leftLink.request(operation, forward) || Observable.of()\n : rightLink.request(operation, forward) || Observable.of();\n });\n }\n };\n ApolloLink.execute = function (link, operation) {\n return (link.request(createOperation(operation.context, transformOperation(validateOperation(operation)))) || Observable.of());\n };\n ApolloLink.concat = function (first, second) {\n var firstLink = toLink(first);\n if (isTerminating(firstLink)) {\n __DEV__ && invariant.warn(new LinkError(\"You are calling concat on a terminating link, which will have no effect\", firstLink));\n return firstLink;\n }\n var nextLink = toLink(second);\n if (isTerminating(nextLink)) {\n return new ApolloLink(function (operation) {\n return firstLink.request(operation, function (op) { return nextLink.request(op) || Observable.of(); }) || Observable.of();\n });\n }\n else {\n return new ApolloLink(function (operation, forward) {\n return (firstLink.request(operation, function (op) {\n return nextLink.request(op, forward) || Observable.of();\n }) || Observable.of());\n });\n }\n };\n ApolloLink.prototype.split = function (test, left, right) {\n return this.concat(ApolloLink.split(test, left, right || new ApolloLink(passthrough)));\n };\n ApolloLink.prototype.concat = function (next) {\n return ApolloLink.concat(this, next);\n };\n ApolloLink.prototype.request = function (operation, forward) {\n throw __DEV__ ? new InvariantError('request is not implemented') : new InvariantError(22);\n };\n ApolloLink.prototype.onError = function (error, observer) {\n if (observer && observer.error) {\n observer.error(error);\n return false;\n }\n throw error;\n };\n ApolloLink.prototype.setOnError = function (fn) {\n this.onError = fn;\n return this;\n };\n return ApolloLink;\n}());\nexport { ApolloLink };\n//# sourceMappingURL=ApolloLink.js.map","import { ApolloLink } from './ApolloLink';\nexport var empty = ApolloLink.empty;\n//# sourceMappingURL=empty.js.map","import { ApolloLink } from './ApolloLink';\nexport var from = ApolloLink.from;\n//# sourceMappingURL=from.js.map","import { ApolloLink } from './ApolloLink';\nexport var split = ApolloLink.split;\n//# sourceMappingURL=split.js.map","import { ApolloLink } from './ApolloLink';\nexport var concat = ApolloLink.concat;\n//# sourceMappingURL=concat.js.map","import { ApolloLink } from './ApolloLink';\nexport var execute = ApolloLink.execute;\n//# sourceMappingURL=execute.js.map"],"names":["Observable","__extends","createOperation","transformOperation","validateOperation","invariant","InvariantError"],"mappings":";;;;;;;;;AAIA,SAAS,WAAW,CAAC,EAAE,EAAE,OAAO,EAAE;AAClC,IAAI,QAAQ,OAAO,GAAG,OAAO,CAAC,EAAE,CAAC,GAAGA,oBAAU,CAAC,EAAE,EAAE,EAAE;AACrD,CAAC;AACD,SAAS,MAAM,CAAC,OAAO,EAAE;AACzB,IAAI,OAAO,OAAO,OAAO,KAAK,UAAU,GAAG,IAAI,UAAU,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;AAC7E,CAAC;AACD,SAAS,aAAa,CAAC,IAAI,EAAE;AAC7B,IAAI,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,IAAI,CAAC,CAAC;AACpC,CAAC;AACD,IAAI,SAAS,IAAI,UAAU,MAAM,EAAE;AACnC,IAAIC,eAAS,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;AACjC,IAAI,SAAS,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE;AACtC,QAAQ,IAAI,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,IAAI,IAAI,CAAC;AACvD,QAAQ,KAAK,CAAC,IAAI,GAAG,IAAI,CAAC;AAC1B,QAAQ,OAAO,KAAK,CAAC;AACrB,KAAK;AACL,IAAI,OAAO,SAAS,CAAC;AACrB,CAAC,CAAC,KAAK,CAAC,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CAAC,SAAS,CAAC,OAAO,GAAG,UAAU,KAAK,EAAE,QAAQ,EAAE;AAC9D,QAAQ,IAAI,QAAQ,IAAI,QAAQ,CAAC,KAAK,EAAE;AACxC,YAAY,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;AAClC,YAAY,OAAO,KAAK,CAAC;AACzB,SAAS;AACT,QAAQ,MAAM,KAAK,CAAC;AACpB,KAAK,CAAC;AACN,IAAI,UAAU,CAAC,SAAS,CAAC,UAAU,GAAG,UAAU,EAAE,EAAE;AACpD,QAAQ,IAAI,CAAC,OAAO,GAAG,EAAE,CAAC;AAC1B,QAAQ,OAAO,IAAI,CAAC;AACpB,KAAK,CAAC;AACN,IAAI,OAAO,UAAU,CAAC;AACtB,CAAC,EAAE;;AChGO,IAAC,KAAK,GAAG,UAAU,CAAC;;ACApB,IAAC,IAAI,GAAG,UAAU,CAAC;;ACAnB,IAAC,KAAK,GAAG,UAAU,CAAC;;ACApB,IAAC,MAAM,GAAG,UAAU,CAAC;;ACArB,IAAC,OAAO,GAAG,UAAU,CAAC;;;;;;;;;"}
|
|
@@ -86,7 +86,7 @@ var ApolloLink = (function () {
|
|
|
86
86
|
return ApolloLink.concat(this, next);
|
|
87
87
|
};
|
|
88
88
|
ApolloLink.prototype.request = function (operation, forward) {
|
|
89
|
-
throw __DEV__ ? new globals.InvariantError('request is not implemented') : new globals.InvariantError(
|
|
89
|
+
throw __DEV__ ? new globals.InvariantError('request is not implemented') : new globals.InvariantError(22);
|
|
90
90
|
};
|
|
91
91
|
ApolloLink.prototype.onError = function (error, observer) {
|
|
92
92
|
if (observer && observer.error) {
|