UNPKG

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