1 | 'use strict';
|
2 |
|
3 | Object.defineProperty(exports, '__esModule', { value: true });
|
4 |
|
5 | var globals = require('../utilities/globals');
|
6 | var tsInvariant = require('ts-invariant');
|
7 |
|
8 | const errorCodes =
|
9 | {
|
10 | 1: {
|
11 | file: "@apollo/client/cache/inmemory/entityStore.js",
|
12 | condition: "typeof dataId === \"string\"",
|
13 | message: "store.merge expects a string ID"
|
14 | },
|
15 | 4: {
|
16 | file: "@apollo/client/cache/inmemory/key-extractor.js",
|
17 | condition: "extracted !== void 0",
|
18 | message: "Missing field '%s' while extracting keyFields from %s"
|
19 | },
|
20 | 5: {
|
21 | file: "@apollo/client/cache/inmemory/policies.js",
|
22 | condition: "!old || old === which",
|
23 | message: "Cannot change root %s __typename more than once"
|
24 | },
|
25 | 8: {
|
26 | file: "@apollo/client/cache/inmemory/policies.js",
|
27 | message: "Cannot automatically merge arrays"
|
28 | },
|
29 | 9: {
|
30 | file: "@apollo/client/cache/inmemory/readFromStore.js",
|
31 | message: "No fragment named %s"
|
32 | },
|
33 | 10: {
|
34 | file: "@apollo/client/cache/inmemory/readFromStore.js",
|
35 | condition: "!isReference(value)",
|
36 | message: "Missing selection set for object of type %s returned for query field %s"
|
37 | },
|
38 | 11: {
|
39 | file: "@apollo/client/cache/inmemory/writeToStore.js",
|
40 | message: "Could not identify object %s"
|
41 | },
|
42 | 13: {
|
43 | file: "@apollo/client/cache/inmemory/writeToStore.js",
|
44 | message: "No fragment named %s"
|
45 | },
|
46 | 15: {
|
47 | file: "@apollo/client/core/ApolloClient.js",
|
48 | message: "To initialize Apollo Client, you must specify a 'cache' property " +
|
49 | "in the options object. \n" +
|
50 | "For more information, please visit: https://go.apollo.dev/c/docs"
|
51 | },
|
52 | 16: {
|
53 | file: "@apollo/client/core/ApolloClient.js",
|
54 | condition: "options.fetchPolicy !== \"cache-and-network\"",
|
55 | message: "The cache-and-network fetchPolicy does not work with client.query, because " +
|
56 | "client.query can only return a single result. Please use client.watchQuery " +
|
57 | "to receive multiple results from the cache and the network, or consider " +
|
58 | "using a different fetchPolicy, such as cache-first or network-only."
|
59 | },
|
60 | 18: {
|
61 | file: "@apollo/client/core/LocalState.js",
|
62 | condition: "fragment",
|
63 | message: "No fragment named %s"
|
64 | },
|
65 | 19: {
|
66 | file: "@apollo/client/core/LocalState.js",
|
67 | condition: "fragment",
|
68 | message: "No fragment named %s"
|
69 | },
|
70 | 21: {
|
71 | file: "@apollo/client/core/ObservableQuery.js",
|
72 | condition: "updateQuery",
|
73 | message: "You must provide an `updateQuery` function when using `fetchMore` with a `no-cache` fetch policy."
|
74 | },
|
75 | 23: {
|
76 | file: "@apollo/client/core/ObservableQuery.js",
|
77 | condition: "pollInterval",
|
78 | message: "Attempted to start a polling query without a polling interval."
|
79 | },
|
80 | 26: {
|
81 | file: "@apollo/client/core/QueryManager.js",
|
82 | message: "QueryManager stopped while query was in flight"
|
83 | },
|
84 | 27: {
|
85 | file: "@apollo/client/core/QueryManager.js",
|
86 | condition: "mutation",
|
87 | message: "mutation option is required. You must specify your GraphQL document in the mutation option."
|
88 | },
|
89 | 28: {
|
90 | file: "@apollo/client/core/QueryManager.js",
|
91 | condition: "fetchPolicy === \"network-only\" || fetchPolicy === \"no-cache\"",
|
92 | message: "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."
|
93 | },
|
94 | 29: {
|
95 | file: "@apollo/client/core/QueryManager.js",
|
96 | condition: "options.query",
|
97 | message: "query option is required. You must specify your GraphQL document " +
|
98 | "in the query option."
|
99 | },
|
100 | 30: {
|
101 | file: "@apollo/client/core/QueryManager.js",
|
102 | condition: "options.query.kind === \"Document\"",
|
103 | message: 'You must wrap the query string in a "gql" tag.'
|
104 | },
|
105 | 31: {
|
106 | file: "@apollo/client/core/QueryManager.js",
|
107 | condition: "!options.returnPartialData",
|
108 | message: "returnPartialData option only supported on watchQuery."
|
109 | },
|
110 | 32: {
|
111 | file: "@apollo/client/core/QueryManager.js",
|
112 | condition: "!options.pollInterval",
|
113 | message: "pollInterval option only supported on watchQuery."
|
114 | },
|
115 | 33: {
|
116 | file: "@apollo/client/core/QueryManager.js",
|
117 | message: "Store reset while query was in flight (not completed in link chain)"
|
118 | },
|
119 | 37: {
|
120 | file: "@apollo/client/link/core/ApolloLink.js",
|
121 | message: "request is not implemented"
|
122 | },
|
123 | 38: {
|
124 | file: "@apollo/client/link/http/checkFetcher.js",
|
125 | message: "\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 "
|
126 | },
|
127 | 40: {
|
128 | file: "@apollo/client/link/http/serializeFetchParameter.js",
|
129 | message: "Network request failed. %s is not serializable: %s"
|
130 | },
|
131 | 41: {
|
132 | file: "@apollo/client/link/persisted-queries/index.js",
|
133 | condition: "options &&\n (typeof options.sha256 === \"function\" ||\n typeof options.generateHash === \"function\")",
|
134 | message: 'Missing/invalid "sha256" or "generateHash" function. Please ' +
|
135 | 'configure one using the "createPersistedQueryLink(options)" options ' +
|
136 | "parameter."
|
137 | },
|
138 | 42: {
|
139 | file: "@apollo/client/link/persisted-queries/index.js",
|
140 | condition: "forward",
|
141 | message: "PersistedQueryLink cannot be the last link in the chain."
|
142 | },
|
143 | 44: {
|
144 | file: "@apollo/client/link/utils/validateOperation.js",
|
145 | message: "illegal argument: %s"
|
146 | },
|
147 | 45: {
|
148 | file: "@apollo/client/react/context/ApolloConsumer.js",
|
149 | condition: "context && context.client",
|
150 | message: 'Could not find "client" in the context of ApolloConsumer. ' +
|
151 | "Wrap the root component in an <ApolloProvider>."
|
152 | },
|
153 | 46: {
|
154 | file: "@apollo/client/react/context/ApolloContext.js",
|
155 | condition: "\"createContext\" in React",
|
156 | message: "Invoking `getApolloContext` in an environment where `React.createContext` is not available.\n" +
|
157 | "The Apollo Client functionality you are trying to use is only available in React Client Components.\n" +
|
158 | 'Please make sure to add "use client" at the top of your file.\n' +
|
159 | "For more information, see https://nextjs.org/docs/getting-started/react-essentials#client-components"
|
160 | },
|
161 | 47: {
|
162 | file: "@apollo/client/react/context/ApolloProvider.js",
|
163 | condition: "context.client",
|
164 | message: "ApolloProvider was not passed a client instance. Make " +
|
165 | 'sure you pass in your client via the "client" prop.'
|
166 | },
|
167 | 48: {
|
168 | file: "@apollo/client/react/hoc/hoc-utils.js",
|
169 | condition: "this.withRef",
|
170 | message: "To access the wrapped instance, you need to specify " +
|
171 | "{ withRef: true } in the options"
|
172 | },
|
173 | 49: {
|
174 | file: "@apollo/client/react/hoc/withApollo.js",
|
175 | condition: "operationOptions.withRef",
|
176 | message: "To access the wrapped instance, you need to specify " +
|
177 | "{ withRef: true } in the options"
|
178 | },
|
179 | 50: {
|
180 | file: "@apollo/client/react/hooks/useApolloClient.js",
|
181 | condition: "!!client",
|
182 | message: 'Could not find "client" in the context or passed in as an option. ' +
|
183 | "Wrap the root component in an <ApolloProvider>, or pass an ApolloClient " +
|
184 | "instance in via options."
|
185 | },
|
186 | 51: {
|
187 | file: "@apollo/client/react/hooks/useLoadableQuery.js",
|
188 | condition: "!calledDuringRender()",
|
189 | message: "useLoadableQuery: 'loadQuery' should not be called during render. To start a query during render, use the 'useBackgroundQuery' hook."
|
190 | },
|
191 | 52: {
|
192 | file: "@apollo/client/react/hooks/useLoadableQuery.js",
|
193 | condition: "internalQueryRef",
|
194 | message: "The query has not been loaded. Please load the query."
|
195 | },
|
196 | 57: {
|
197 | file: "@apollo/client/react/hooks/useSubscription.js",
|
198 | condition: "!optionsRef.current.skip",
|
199 | message: "A subscription that is skipped cannot be restarted."
|
200 | },
|
201 | 58: {
|
202 | file: "@apollo/client/react/hooks/useSuspenseQuery.js",
|
203 | condition: "supportedFetchPolicies.includes(fetchPolicy)",
|
204 | message: "The fetch policy `%s` is not supported with suspense."
|
205 | },
|
206 | 61: {
|
207 | file: "@apollo/client/react/internal/cache/QueryReference.js",
|
208 | condition: "!queryRef || QUERY_REFERENCE_SYMBOL in queryRef",
|
209 | message: "Expected a QueryRef object, but got something else instead."
|
210 | },
|
211 | 62: {
|
212 | file: "@apollo/client/react/parser/index.js",
|
213 | condition: "!!document && !!document.kind",
|
214 | message: "Argument of %s passed to parser was not a valid GraphQL " +
|
215 | "DocumentNode. You may need to use 'graphql-tag' or another method " +
|
216 | "to convert your operation into a document"
|
217 | },
|
218 | 63: {
|
219 | file: "@apollo/client/react/parser/index.js",
|
220 | condition: "!fragments.length ||\n queries.length ||\n mutations.length ||\n subscriptions.length",
|
221 | message: "Passing only a fragment to 'graphql' is not yet supported. " +
|
222 | "You must include a query, subscription or mutation as well"
|
223 | },
|
224 | 64: {
|
225 | file: "@apollo/client/react/parser/index.js",
|
226 | condition: "queries.length + mutations.length + subscriptions.length <= 1",
|
227 | message: "react-apollo only supports a query, subscription, or a mutation per HOC. " +
|
228 | "%s had %s queries, %s " +
|
229 | "subscriptions and %s mutations. " +
|
230 | "You can use 'compose' to join multiple operation types to a component"
|
231 | },
|
232 | 65: {
|
233 | file: "@apollo/client/react/parser/index.js",
|
234 | condition: "definitions.length === 1",
|
235 | message: "react-apollo only supports one definition per HOC. %s had " +
|
236 | "%s definitions. " +
|
237 | "You can use 'compose' to join multiple operation types to a component"
|
238 | },
|
239 | 66: {
|
240 | file: "@apollo/client/react/parser/index.js",
|
241 | condition: "operation.type === type",
|
242 | message: "Running a %s requires a graphql " + "%s, but a %s was used instead."
|
243 | },
|
244 | 67: {
|
245 | file: "@apollo/client/testing/core/mocking/mockLink.js",
|
246 | condition: "queryWithoutClientOnlyDirectives",
|
247 | message: "query is required"
|
248 | },
|
249 | 68: {
|
250 | file: "@apollo/client/testing/core/mocking/mockLink.js",
|
251 | condition: "mockedResponse.maxUsageCount > 0",
|
252 | message: "Mock response maxUsageCount must be greater than 0, %s given"
|
253 | },
|
254 | 69: {
|
255 | file: "@apollo/client/utilities/graphql/DocumentTransform.js",
|
256 | condition: "Array.isArray(cacheKeys)",
|
257 | message: "`getCacheKey` must return an array or undefined"
|
258 | },
|
259 | 70: {
|
260 | file: "@apollo/client/utilities/graphql/directives.js",
|
261 | condition: "evaledValue !== void 0",
|
262 | message: "Invalid variable referenced in @%s directive."
|
263 | },
|
264 | 71: {
|
265 | file: "@apollo/client/utilities/graphql/directives.js",
|
266 | condition: "directiveArguments && directiveArguments.length === 1",
|
267 | message: "Incorrect number of arguments for the @%s directive."
|
268 | },
|
269 | 72: {
|
270 | file: "@apollo/client/utilities/graphql/directives.js",
|
271 | condition: "ifArgument.name && ifArgument.name.value === \"if\"",
|
272 | message: "Invalid argument for the @%s directive."
|
273 | },
|
274 | 73: {
|
275 | file: "@apollo/client/utilities/graphql/directives.js",
|
276 | condition: "ifValue &&\n (ifValue.kind === \"Variable\" || ifValue.kind === \"BooleanValue\")",
|
277 | message: "Argument for the @%s directive must be a variable or a boolean value."
|
278 | },
|
279 | 74: {
|
280 | file: "@apollo/client/utilities/graphql/fragments.js",
|
281 | message: "Found a %s operation%s. " +
|
282 | "No operations are allowed when using a fragment as a query. Only fragments are allowed."
|
283 | },
|
284 | 75: {
|
285 | file: "@apollo/client/utilities/graphql/fragments.js",
|
286 | condition: "fragments.length === 1",
|
287 | message: "Found %s fragments. `fragmentName` must be provided when there is not exactly 1 fragment."
|
288 | },
|
289 | 76: {
|
290 | file: "@apollo/client/utilities/graphql/fragments.js",
|
291 | condition: "fragment",
|
292 | message: "No fragment named %s"
|
293 | },
|
294 | 77: {
|
295 | file: "@apollo/client/utilities/graphql/getFromAST.js",
|
296 | condition: "doc && doc.kind === \"Document\"",
|
297 | message: "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"
|
298 | },
|
299 | 78: {
|
300 | file: "@apollo/client/utilities/graphql/getFromAST.js",
|
301 | message: "Schema type definitions not allowed in queries. Found: \"%s\""
|
302 | },
|
303 | 79: {
|
304 | file: "@apollo/client/utilities/graphql/getFromAST.js",
|
305 | condition: "operations.length <= 1",
|
306 | message: "Ambiguous GraphQL document: contains %s operations"
|
307 | },
|
308 | 80: {
|
309 | file: "@apollo/client/utilities/graphql/getFromAST.js",
|
310 | condition: "queryDef && queryDef.operation === \"query\"",
|
311 | message: "Must contain a query definition."
|
312 | },
|
313 | 81: {
|
314 | file: "@apollo/client/utilities/graphql/getFromAST.js",
|
315 | condition: "doc.kind === \"Document\"",
|
316 | message: "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"
|
317 | },
|
318 | 82: {
|
319 | file: "@apollo/client/utilities/graphql/getFromAST.js",
|
320 | condition: "doc.definitions.length <= 1",
|
321 | message: "Fragment must have exactly one definition."
|
322 | },
|
323 | 83: {
|
324 | file: "@apollo/client/utilities/graphql/getFromAST.js",
|
325 | condition: "fragmentDef.kind === \"FragmentDefinition\"",
|
326 | message: "Must be a fragment definition."
|
327 | },
|
328 | 84: {
|
329 | file: "@apollo/client/utilities/graphql/getFromAST.js",
|
330 | message: "Expected a parsed GraphQL query with a query, mutation, subscription, or a fragment."
|
331 | },
|
332 | 85: {
|
333 | file: "@apollo/client/utilities/graphql/storeUtils.js",
|
334 | message: "The inline argument \"%s\" of kind \"%s\"" +
|
335 | "is not supported. Use variables instead of inline arguments to " +
|
336 | "overcome this limitation."
|
337 | }
|
338 | };
|
339 | const devDebug = {
|
340 | 17: {
|
341 | file: "@apollo/client/core/ApolloClient.js",
|
342 | message: "In client.refetchQueries, Promise.all promise rejected with error %o"
|
343 | },
|
344 | 25: {
|
345 | file: "@apollo/client/core/ObservableQuery.js",
|
346 | message: "Missing cache result fields: %o"
|
347 | }
|
348 | };
|
349 | const devLog = {};
|
350 | const devWarn = {
|
351 | 2: {
|
352 | file: "@apollo/client/cache/inmemory/entityStore.js",
|
353 | message: "cache.modify: You are trying to write a Reference that is not part of the store: %o\n" +
|
354 | "Please make sure to set the `mergeIntoStore` parameter to `true` when creating a Reference that is not part of the store yet:\n" +
|
355 | "`toReference(object, true)`"
|
356 | },
|
357 | 3: {
|
358 | file: "@apollo/client/cache/inmemory/entityStore.js",
|
359 | message: "cache.modify: Writing an array with a mix of both References and Objects will not result in the Objects being normalized correctly.\n" +
|
360 | "Please convert the object instance %o to a Reference before writing it to the cache by calling `toReference(object, true)`."
|
361 | },
|
362 | 6: {
|
363 | file: "@apollo/client/cache/inmemory/policies.js",
|
364 | message: "Inferring subtype %s of supertype %s"
|
365 | },
|
366 | 7: {
|
367 | file: "@apollo/client/cache/inmemory/policies.js",
|
368 | message: "Undefined 'from' passed to readField with arguments %s"
|
369 | },
|
370 | 14: {
|
371 | file: "@apollo/client/cache/inmemory/writeToStore.js",
|
372 | message: "Cache data may be lost when replacing the %s field of a %s object.\n\nThis could cause additional (usually avoidable) network requests to fetch data that were otherwise cached.\n\nTo address this problem (which is not a bug in Apollo Client), %sdefine a custom merge function for the %s field, so InMemoryCache can safely merge these objects:\n\n existing: %o\n incoming: %o\n\nFor more information about these options, please refer to the documentation:\n\n * Ensuring entity objects have IDs: https://go.apollo.dev/c/generating-unique-identifiers\n * Defining custom merge functions: https://go.apollo.dev/c/merging-non-normalized-objects\n"
|
373 | },
|
374 | 20: {
|
375 | file: "@apollo/client/core/ObservableQuery.js",
|
376 | message: "Called refetch(%o) for query %o, which does not declare a $variables variable.\nDid you mean to call refetch(variables) instead of refetch({ variables })?"
|
377 | },
|
378 | 34: {
|
379 | file: "@apollo/client/core/QueryManager.js",
|
380 | message: "Unknown query named \"%s\" requested in refetchQueries options.include array"
|
381 | },
|
382 | 35: {
|
383 | file: "@apollo/client/core/QueryManager.js",
|
384 | message: "Unknown query %o requested in refetchQueries options.include array"
|
385 | },
|
386 | 36: {
|
387 | file: "@apollo/client/link/core/ApolloLink.js",
|
388 | message: "You are calling concat on a terminating link, which will have no effect %o"
|
389 | },
|
390 | 39: {
|
391 | file: "@apollo/client/link/http/createHttpLink.js",
|
392 | message: "Multipart-subscriptions do not support @defer"
|
393 | },
|
394 | 43: {
|
395 | file: "@apollo/client/link/utils/toPromise.js",
|
396 | message: "Promise Wrapper does not support multiple results from Observable"
|
397 | },
|
398 | 53: {
|
399 | file: "@apollo/client/react/hooks/useSubscription.js",
|
400 | message: "'useSubscription' supports only the 'onSubscriptionData' or 'onData' option, but not both. Only the 'onData' option will be used."
|
401 | },
|
402 | 54: {
|
403 | file: "@apollo/client/react/hooks/useSubscription.js",
|
404 | message: "'onSubscriptionData' is deprecated and will be removed in a future major version. Please use the 'onData' option instead."
|
405 | },
|
406 | 55: {
|
407 | file: "@apollo/client/react/hooks/useSubscription.js",
|
408 | message: "'useSubscription' supports only the 'onSubscriptionComplete' or 'onComplete' option, but not both. Only the 'onComplete' option will be used."
|
409 | },
|
410 | 56: {
|
411 | file: "@apollo/client/react/hooks/useSubscription.js",
|
412 | message: "'onSubscriptionComplete' is deprecated and will be removed in a future major version. Please use the 'onComplete' option instead."
|
413 | },
|
414 | 59: {
|
415 | file: "@apollo/client/react/hooks/useSuspenseQuery.js",
|
416 | message: "Using `returnPartialData` with a `no-cache` fetch policy has no effect. To read partial data from the cache, consider using an alternate fetch policy."
|
417 | },
|
418 | 87: {
|
419 | file: "@apollo/client/utilities/graphql/transform.js",
|
420 | message: "Removing an @connection directive even though it does not have a key. " +
|
421 | "You may want to use the key parameter to specify a store key."
|
422 | }
|
423 | };
|
424 | const devError = {
|
425 | 12: {
|
426 | file: "@apollo/client/cache/inmemory/writeToStore.js",
|
427 | message: "Missing field '%s' while writing result %o"
|
428 | },
|
429 | 22: {
|
430 | file: "@apollo/client/core/ObservableQuery.js",
|
431 | message: "Unhandled GraphQL subscription error"
|
432 | },
|
433 | 24: {
|
434 | file: "@apollo/client/core/ObservableQuery.js",
|
435 | message: "Unhandled error"
|
436 | },
|
437 | 60: {
|
438 | file: "@apollo/client/react/hooks/useSyncExternalStore.js",
|
439 | message: "The result of getSnapshot should be cached to avoid an infinite loop"
|
440 | },
|
441 | 86: {
|
442 | file: "@apollo/client/utilities/graphql/transform.js",
|
443 | message: "Could not find operation or fragment"
|
444 | }
|
445 | };
|
446 |
|
447 | var version = "3.11.8";
|
448 |
|
449 | function maybe(thunk) {
|
450 | try {
|
451 | return thunk();
|
452 | }
|
453 | catch (_a) { }
|
454 | }
|
455 |
|
456 | var global$1 = (maybe(function () { return globalThis; }) ||
|
457 | maybe(function () { return window; }) ||
|
458 | maybe(function () { return self; }) ||
|
459 | maybe(function () { return global; }) ||
|
460 | maybe(function () {
|
461 | return maybe.constructor("return this")();
|
462 | }));
|
463 |
|
464 | var prefixCounts = new Map();
|
465 | function makeUniqueId(prefix) {
|
466 | var count = prefixCounts.get(prefix) || 1;
|
467 | prefixCounts.set(prefix, count + 1);
|
468 | return "".concat(prefix, ":").concat(count, ":").concat(Math.random().toString(36).slice(2));
|
469 | }
|
470 |
|
471 | function stringifyForDisplay(value, space) {
|
472 | if (space === void 0) { space = 0; }
|
473 | var undefId = makeUniqueId("stringifyForDisplay");
|
474 | return JSON.stringify(value, function (key, value) {
|
475 | return value === void 0 ? undefId : value;
|
476 | }, space)
|
477 | .split(JSON.stringify(undefId))
|
478 | .join("<undefined>");
|
479 | }
|
480 |
|
481 | function wrap(fn) {
|
482 | return function (message) {
|
483 | var args = [];
|
484 | for (var _i = 1; _i < arguments.length; _i++) {
|
485 | args[_i - 1] = arguments[_i];
|
486 | }
|
487 | if (typeof message === "number") {
|
488 | var arg0 = message;
|
489 | message = getHandledErrorMsg(arg0);
|
490 | if (!message) {
|
491 | message = getFallbackErrorMsg(arg0, args);
|
492 | args = [];
|
493 | }
|
494 | }
|
495 | fn.apply(void 0, [message].concat(args));
|
496 | };
|
497 | }
|
498 | Object.assign(function invariant(condition, message) {
|
499 | var args = [];
|
500 | for (var _i = 2; _i < arguments.length; _i++) {
|
501 | args[_i - 2] = arguments[_i];
|
502 | }
|
503 | if (!condition) {
|
504 | tsInvariant.invariant(condition, getHandledErrorMsg(message, args) || getFallbackErrorMsg(message, args));
|
505 | }
|
506 | }, {
|
507 | debug: wrap(tsInvariant.invariant.debug),
|
508 | log: wrap(tsInvariant.invariant.log),
|
509 | warn: wrap(tsInvariant.invariant.warn),
|
510 | error: wrap(tsInvariant.invariant.error),
|
511 | });
|
512 | var ApolloErrorMessageHandler = Symbol.for("ApolloErrorMessageHandler_" + version);
|
513 | function stringify(arg) {
|
514 | if (typeof arg == "string") {
|
515 | return arg;
|
516 | }
|
517 | try {
|
518 | return stringifyForDisplay(arg, 2).slice(0, 1000);
|
519 | }
|
520 | catch (_a) {
|
521 | return "<non-serializable>";
|
522 | }
|
523 | }
|
524 | function getHandledErrorMsg(message, messageArgs) {
|
525 | if (messageArgs === void 0) { messageArgs = []; }
|
526 | if (!message)
|
527 | return;
|
528 | return (global$1[ApolloErrorMessageHandler] &&
|
529 | global$1[ApolloErrorMessageHandler](message, messageArgs.map(stringify)));
|
530 | }
|
531 | function getFallbackErrorMsg(message, messageArgs) {
|
532 | if (messageArgs === void 0) { messageArgs = []; }
|
533 | if (!message)
|
534 | return;
|
535 | return "An error occurred! For more details, see the full error text at https://go.apollo.dev/c/err#".concat(encodeURIComponent(JSON.stringify({
|
536 | version: version,
|
537 | message: message,
|
538 | args: messageArgs.map(stringify),
|
539 | })));
|
540 | }
|
541 |
|
542 | function setErrorMessageHandler(handler) {
|
543 | globals.global[ApolloErrorMessageHandler] = handler;
|
544 | }
|
545 |
|
546 | function loadErrorMessageHandler() {
|
547 | var errorCodes = [];
|
548 | for (var _i = 0; _i < arguments.length; _i++) {
|
549 | errorCodes[_i] = arguments[_i];
|
550 | }
|
551 | setErrorMessageHandler(handler);
|
552 | for (var _a = 0, errorCodes_1 = errorCodes; _a < errorCodes_1.length; _a++) {
|
553 | var codes = errorCodes_1[_a];
|
554 | Object.assign(handler, codes);
|
555 | }
|
556 | return handler;
|
557 | }
|
558 | var handler = (function (message, args) {
|
559 | if (typeof message === "number") {
|
560 | var definition = globals.global[ApolloErrorMessageHandler][message];
|
561 | if (!message || !(definition === null || definition === void 0 ? void 0 : definition.message))
|
562 | return;
|
563 | message = definition.message;
|
564 | }
|
565 | return args.reduce(function (msg, arg) { return msg.replace(/%[sdfo]/, String(arg)); }, String(message));
|
566 | });
|
567 |
|
568 | function loadDevMessages() {
|
569 | loadErrorMessageHandler(devDebug, devError, devLog, devWarn);
|
570 | }
|
571 |
|
572 | function loadErrorMessages() {
|
573 | loadErrorMessageHandler(errorCodes);
|
574 | }
|
575 |
|
576 | exports.loadDevMessages = loadDevMessages;
|
577 | exports.loadErrorMessageHandler = loadErrorMessageHandler;
|
578 | exports.loadErrorMessages = loadErrorMessages;
|
579 | exports.setErrorMessageHandler = setErrorMessageHandler;
|
580 |
|