@apollo/client 4.0.0-rc.0 → 4.0.0-rc.2

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.
Files changed (118) hide show
  1. package/CHANGELOG.md +112 -0
  2. package/__cjs/cache/core/cache.cjs +1 -1
  3. package/__cjs/cache/core/types/DataProxy.d.cts +4 -4
  4. package/__cjs/cache/index.cjs.map +1 -1
  5. package/__cjs/cache/index.d.cts +1 -1
  6. package/__cjs/cache/inmemory/entityStore.cjs +3 -3
  7. package/__cjs/cache/inmemory/inMemoryCache.cjs +2 -7
  8. package/__cjs/cache/inmemory/inMemoryCache.cjs.map +1 -1
  9. package/__cjs/cache/inmemory/key-extractor.cjs +1 -1
  10. package/__cjs/cache/inmemory/key-extractor.cjs.map +1 -1
  11. package/__cjs/cache/inmemory/policies.cjs +4 -4
  12. package/__cjs/cache/inmemory/readFromStore.cjs +4 -6
  13. package/__cjs/cache/inmemory/readFromStore.cjs.map +1 -1
  14. package/__cjs/cache/inmemory/readFromStore.d.cts +0 -1
  15. package/__cjs/cache/inmemory/types.d.cts +0 -5
  16. package/__cjs/cache/inmemory/writeToStore.cjs +4 -4
  17. package/__cjs/core/ApolloClient.cjs +14 -21
  18. package/__cjs/core/ApolloClient.cjs.map +1 -1
  19. package/__cjs/core/ApolloClient.d.cts +0 -7
  20. package/__cjs/core/ObservableQuery.cjs +6 -6
  21. package/__cjs/core/ObservableQuery.cjs.map +1 -1
  22. package/__cjs/core/QueryInfo.cjs.map +1 -1
  23. package/__cjs/core/QueryInfo.d.cts +3 -3
  24. package/__cjs/core/QueryManager.cjs +13 -12
  25. package/__cjs/core/QueryManager.cjs.map +1 -1
  26. package/__cjs/core/index.cjs.map +1 -1
  27. package/__cjs/core/index.d.cts +1 -1
  28. package/__cjs/core/types.d.cts +94 -42
  29. package/__cjs/core/watchQueryOptions.d.cts +9 -9
  30. package/__cjs/incremental/handlers/notImplemented.cjs +1 -1
  31. package/__cjs/invariantErrorCodes.cjs +59 -64
  32. package/__cjs/link/context/index.cjs +18 -14
  33. package/__cjs/link/context/index.cjs.map +1 -1
  34. package/__cjs/link/context/index.d.cts +17 -5
  35. package/__cjs/link/core/ApolloLink.cjs +2 -2
  36. package/__cjs/link/core/types.d.cts +3 -1
  37. package/__cjs/link/http/checkFetcher.cjs +1 -1
  38. package/__cjs/link/http/parseAndCheckHttpResponse.cjs +1 -1
  39. package/__cjs/link/http/serializeFetchParameter.cjs +1 -1
  40. package/__cjs/link/persisted-queries/index.cjs +2 -2
  41. package/__cjs/link/utils/transformOperation.cjs +1 -0
  42. package/__cjs/link/utils/transformOperation.cjs.map +1 -1
  43. package/__cjs/link/utils/validateOperation.cjs +2 -1
  44. package/__cjs/link/utils/validateOperation.cjs.map +1 -1
  45. package/__cjs/local-state/LocalState.cjs +6 -9
  46. package/__cjs/local-state/LocalState.cjs.map +1 -1
  47. package/__cjs/react/hooks/useMutation.cjs.map +1 -1
  48. package/__cjs/react/hooks/useMutation.d.cts +2 -2
  49. package/__cjs/react/hooks/useQuery.cjs +11 -3
  50. package/__cjs/react/hooks/useQuery.cjs.map +1 -1
  51. package/__cjs/testing/react/MockedProvider.cjs +2 -2
  52. package/__cjs/testing/react/MockedProvider.cjs.map +1 -1
  53. package/__cjs/testing/react/MockedProvider.d.cts +2 -6
  54. package/__cjs/utilities/index.cjs +3 -1
  55. package/__cjs/utilities/index.cjs.map +1 -1
  56. package/__cjs/utilities/index.d.cts +1 -0
  57. package/__cjs/utilities/internal/getMainDefinition.cjs +1 -6
  58. package/__cjs/utilities/internal/getMainDefinition.cjs.map +1 -1
  59. package/__cjs/version.cjs +1 -1
  60. package/cache/core/cache.js +1 -1
  61. package/cache/core/types/DataProxy.d.ts +4 -4
  62. package/cache/index.d.ts +1 -1
  63. package/cache/index.js.map +1 -1
  64. package/cache/inmemory/entityStore.js +3 -3
  65. package/cache/inmemory/inMemoryCache.js +2 -7
  66. package/cache/inmemory/inMemoryCache.js.map +1 -1
  67. package/cache/inmemory/key-extractor.js +1 -1
  68. package/cache/inmemory/key-extractor.js.map +1 -1
  69. package/cache/inmemory/policies.js +4 -4
  70. package/cache/inmemory/readFromStore.d.ts +0 -1
  71. package/cache/inmemory/readFromStore.js +4 -6
  72. package/cache/inmemory/readFromStore.js.map +1 -1
  73. package/cache/inmemory/types.d.ts +0 -5
  74. package/cache/inmemory/writeToStore.js +4 -4
  75. package/core/ApolloClient.d.ts +0 -7
  76. package/core/ApolloClient.js +14 -21
  77. package/core/ApolloClient.js.map +1 -1
  78. package/core/ObservableQuery.js +6 -6
  79. package/core/ObservableQuery.js.map +1 -1
  80. package/core/QueryInfo.d.ts +3 -3
  81. package/core/QueryInfo.js.map +1 -1
  82. package/core/QueryManager.js +13 -12
  83. package/core/QueryManager.js.map +1 -1
  84. package/core/index.d.ts +1 -1
  85. package/core/index.js.map +1 -1
  86. package/core/types.d.ts +94 -42
  87. package/core/watchQueryOptions.d.ts +9 -9
  88. package/incremental/handlers/notImplemented.js +1 -1
  89. package/invariantErrorCodes.js +59 -64
  90. package/link/context/index.d.ts +17 -5
  91. package/link/context/index.js +18 -14
  92. package/link/context/index.js.map +1 -1
  93. package/link/core/ApolloLink.js +2 -2
  94. package/link/core/types.d.ts +3 -1
  95. package/link/http/checkFetcher.js +1 -1
  96. package/link/http/parseAndCheckHttpResponse.js +1 -1
  97. package/link/http/serializeFetchParameter.js +1 -1
  98. package/link/persisted-queries/index.js +2 -2
  99. package/link/utils/transformOperation.js +1 -0
  100. package/link/utils/transformOperation.js.map +1 -1
  101. package/link/utils/validateOperation.js +2 -1
  102. package/link/utils/validateOperation.js.map +1 -1
  103. package/local-state/LocalState.js +6 -9
  104. package/local-state/LocalState.js.map +1 -1
  105. package/package.json +3 -2
  106. package/react/hooks/useMutation.d.ts +2 -2
  107. package/react/hooks/useMutation.js.map +1 -1
  108. package/react/hooks/useQuery.js +12 -4
  109. package/react/hooks/useQuery.js.map +1 -1
  110. package/testing/react/MockedProvider.d.ts +2 -6
  111. package/testing/react/MockedProvider.js +2 -2
  112. package/testing/react/MockedProvider.js.map +1 -1
  113. package/utilities/index.d.ts +1 -0
  114. package/utilities/index.js +1 -0
  115. package/utilities/index.js.map +1 -1
  116. package/utilities/internal/getMainDefinition.js +1 -6
  117. package/utilities/internal/getMainDefinition.js.map +1 -1
  118. package/version.js +1 -1
@@ -280,29 +280,29 @@ you have an infinite render loop in your application.`
280
280
  message: "No fragment named %s"
281
281
  },
282
282
 
283
- 55: {
283
+ 54: {
284
284
  file: "@apollo/client/__cjs/local-state/LocalState.cjs",
285
285
  message: "Could not resolve __typename on object %o returned from resolver '%s'. '__typename' needs to be returned to properly resolve child fields."
286
286
  },
287
287
 
288
- 56: {
288
+ 55: {
289
289
  file: "@apollo/client/__cjs/local-state/LocalState.cjs",
290
290
  condition: "fragment",
291
291
  message: `No fragment named %s`
292
292
  },
293
293
 
294
- 57: {
294
+ 56: {
295
295
  file: "@apollo/client/__cjs/local-state/LocalState.cjs",
296
296
  condition: "cache.fragmentMatches",
297
297
  message: "The configured cache does not support fragment matching which will lead to incorrect results when executing local resolvers. Please use a cache that implements `fragmetMatches`."
298
298
  },
299
299
 
300
- 58: {
300
+ 57: {
301
301
  file: "@apollo/client/__cjs/link/utils/validateOperation.cjs",
302
302
  message: `illegal argument: %s`
303
303
  },
304
304
 
305
- 59: {
305
+ 58: {
306
306
  file: "@apollo/client/__cjs/link/persisted-queries/index.cjs",
307
307
  condition: "options &&\n (typeof options.sha256 === \"function\" ||\n typeof options.generateHash === \"function\")",
308
308
 
@@ -311,13 +311,13 @@ you have an infinite render loop in your application.`
311
311
  "parameter."
312
312
  },
313
313
 
314
- 60: {
314
+ 59: {
315
315
  file: "@apollo/client/__cjs/link/persisted-queries/index.cjs",
316
316
  condition: "forward",
317
317
  message: "PersistedQueryLink cannot be the last link in the chain."
318
318
  },
319
319
 
320
- 61: {
320
+ 60: {
321
321
  file: "@apollo/client/__cjs/link/http/checkFetcher.cjs",
322
322
  condition: "fetcher || typeof fetch !== \"undefined\"",
323
323
 
@@ -335,29 +335,29 @@ const client = new ApolloClient({
335
335
  `
336
336
  },
337
337
 
338
- 62: {
338
+ 61: {
339
339
  file: "@apollo/client/__cjs/link/http/parseAndCheckHttpResponse.cjs",
340
340
  condition: "response.body && typeof response.body.getReader === \"function\"",
341
341
  message: "Unknown type for `response.body`. Please use a `fetch` implementation that is WhatWG-compliant and that uses WhatWG ReadableStreams for `body`."
342
342
  },
343
343
 
344
- 63: {
344
+ 62: {
345
345
  file: "@apollo/client/__cjs/link/http/serializeFetchParameter.cjs",
346
346
  message: `Network request failed. %s is not serializable: %s`
347
347
  },
348
348
 
349
- 65: {
349
+ 64: {
350
350
  file: "@apollo/client/__cjs/link/core/ApolloLink.cjs",
351
351
  message: "request is not implemented"
352
352
  },
353
353
 
354
- 66: {
354
+ 65: {
355
355
  file: "@apollo/client/__cjs/incremental/handlers/notImplemented.cjs",
356
356
  condition: "!(0, internal_1.hasDirectives)([\"defer\"], request.query)",
357
357
  message: "`@defer` is not supported without specifying an incremental handler. Please pass a handler as the `incrementalHandler` option to the `ApolloClient` constructor."
358
358
  },
359
359
 
360
- 67: {
360
+ 66: {
361
361
  file: "@apollo/client/__cjs/core/ApolloClient.cjs",
362
362
  condition: "options.cache",
363
363
 
@@ -366,7 +366,7 @@ const client = new ApolloClient({
366
366
  "For more information, please visit: https://go.apollo.dev/c/docs"
367
367
  },
368
368
 
369
- 68: {
369
+ 67: {
370
370
  file: "@apollo/client/__cjs/core/ApolloClient.cjs",
371
371
  condition: "options.link",
372
372
 
@@ -375,7 +375,7 @@ const client = new ApolloClient({
375
375
  "For more information, please visit: https://go.apollo.dev/c/docs"
376
376
  },
377
377
 
378
- 69: {
378
+ 68: {
379
379
  file: "@apollo/client/__cjs/core/ApolloClient.cjs",
380
380
  condition: "options.fetchPolicy !== \"cache-and-network\"",
381
381
 
@@ -385,7 +385,7 @@ const client = new ApolloClient({
385
385
  "using a different fetchPolicy, such as cache-first or network-only."
386
386
  },
387
387
 
388
- 70: {
388
+ 69: {
389
389
  file: "@apollo/client/__cjs/core/ApolloClient.cjs",
390
390
  condition: "options.fetchPolicy !== \"standby\"",
391
391
 
@@ -394,7 +394,7 @@ const client = new ApolloClient({
394
394
  "as cache-first or network-only."
395
395
  },
396
396
 
397
- 71: {
397
+ 70: {
398
398
  file: "@apollo/client/__cjs/core/ApolloClient.cjs",
399
399
  condition: "options.query",
400
400
 
@@ -402,158 +402,158 @@ const client = new ApolloClient({
402
402
  "in the query option."
403
403
  },
404
404
 
405
- 72: {
405
+ 71: {
406
406
  file: "@apollo/client/__cjs/core/ApolloClient.cjs",
407
407
  condition: "options.query.kind === \"Document\"",
408
408
  message: 'You must wrap the query string in a "gql" tag.'
409
409
  },
410
410
 
411
- 73: {
411
+ 72: {
412
412
  file: "@apollo/client/__cjs/core/ApolloClient.cjs",
413
413
  condition: "!options.returnPartialData",
414
414
  message: "returnPartialData option only supported on watchQuery."
415
415
  },
416
416
 
417
- 74: {
417
+ 73: {
418
418
  file: "@apollo/client/__cjs/core/ApolloClient.cjs",
419
419
  condition: "!options.pollInterval",
420
420
  message: "pollInterval option only supported on watchQuery."
421
421
  },
422
422
 
423
- 75: {
423
+ 74: {
424
424
  file: "@apollo/client/__cjs/core/ApolloClient.cjs",
425
425
  condition: "!options.notifyOnNetworkStatusChange",
426
426
  message: "notifyOnNetworkStatusChange option only supported on watchQuery."
427
427
  },
428
428
 
429
- 76: {
429
+ 75: {
430
430
  file: "@apollo/client/__cjs/core/ApolloClient.cjs",
431
431
  condition: "optionsWithDefaults.mutation",
432
432
  message: "The `mutation` option is required. Please provide a GraphQL document in the `mutation` option."
433
433
  },
434
434
 
435
- 77: {
435
+ 76: {
436
436
  file: "@apollo/client/__cjs/core/ApolloClient.cjs",
437
437
  condition: "optionsWithDefaults.fetchPolicy === \"network-only\" ||\n optionsWithDefaults.fetchPolicy === \"no-cache\"",
438
438
  message: "Mutations only support 'network-only' or 'no-cache' fetch policies. The default 'network-only' behavior automatically writes mutation results to the cache. Passing 'no-cache' skips the cache write."
439
439
  },
440
440
 
441
- 80: {
441
+ 79: {
442
442
  file: "@apollo/client/__cjs/core/ObservableQuery.cjs",
443
443
  condition: "this.options.fetchPolicy !== \"cache-only\"",
444
444
  message: "Cannot execute `fetchMore` for 'cache-only' query '%s'. Please use a different fetch policy."
445
445
  },
446
446
 
447
- 81: {
447
+ 80: {
448
448
  file: "@apollo/client/__cjs/core/ObservableQuery.cjs",
449
449
  condition: "updateQuery",
450
450
  message: "You must provide an `updateQuery` function when using `fetchMore` with a `no-cache` fetch policy."
451
451
  },
452
452
 
453
- 85: {
453
+ 84: {
454
454
  file: "@apollo/client/__cjs/core/QueryManager.cjs",
455
455
  message: "QueryManager stopped while query was in flight"
456
456
  },
457
457
 
458
- 86: {
458
+ 85: {
459
459
  file: "@apollo/client/__cjs/core/QueryManager.cjs",
460
460
  condition: "this.localState",
461
461
  message: "Mutation '%s' contains `@client` fields with variables provided by `@export` but local state has not been configured."
462
462
  },
463
463
 
464
- 87: {
464
+ 86: {
465
465
  file: "@apollo/client/__cjs/core/QueryManager.cjs",
466
466
  message: "Store reset while query was in flight (not completed in link chain)"
467
467
  },
468
468
 
469
- 90: {
469
+ 89: {
470
470
  file: "@apollo/client/__cjs/core/QueryManager.cjs",
471
471
  condition: "!this.getDocumentInfo(query).hasClientExports || this.localState",
472
472
  message: "Subscription '%s' contains `@client` fields with variables provided by `@export` but local state has not been configured."
473
473
  },
474
474
 
475
- 91: {
475
+ 90: {
476
476
  file: "@apollo/client/__cjs/core/QueryManager.cjs",
477
477
  condition: "this.localState",
478
478
  message: "%s '%s' contains `@client` fields but local state has not been configured."
479
479
  },
480
480
 
481
- 92: {
481
+ 91: {
482
482
  file: "@apollo/client/__cjs/core/QueryManager.cjs",
483
483
  condition: "!hasIncrementalDirective",
484
484
  message: "%s '%s' contains `@client` and `@defer` directives. These cannot be used together."
485
485
  },
486
486
 
487
- 93: {
487
+ 92: {
488
488
  file: "@apollo/client/__cjs/core/QueryManager.cjs",
489
489
  condition: "this.localState",
490
490
  message: "Query '%s' contains `@client` fields with variables provided by `@export` but local state has not been configured."
491
491
  },
492
492
 
493
- 95: {
493
+ 94: {
494
494
  file: "@apollo/client/__cjs/core/QueryManager.cjs",
495
495
  condition: "this.localState",
496
496
  message: "Query '%s' contains `@client` fields but local state has not been configured."
497
497
  },
498
498
 
499
- 96: {
499
+ 95: {
500
500
  file: "@apollo/client/__cjs/core/QueryManager.cjs",
501
501
  condition: "didEmitValue",
502
502
  message: "The link chain completed without emitting a value. This is likely unintentional and should be updated to emit a value before completing."
503
503
  },
504
504
 
505
- 97: {
505
+ 96: {
506
506
  file: "@apollo/client/__cjs/cache/inmemory/entityStore.cjs",
507
507
  condition: "typeof dataId === \"string\"",
508
508
  message: "store.merge expects a string ID"
509
509
  },
510
510
 
511
- 100: {
511
+ 99: {
512
512
  file: "@apollo/client/__cjs/cache/inmemory/key-extractor.cjs",
513
513
  condition: "extracted !== void 0",
514
514
  message: `Missing field '%s' while extracting keyFields from %s`
515
515
  },
516
516
 
517
- 101: {
517
+ 100: {
518
518
  file: "@apollo/client/__cjs/cache/inmemory/policies.cjs",
519
519
  condition: "!old || old === which",
520
520
  message: `Cannot change root %s __typename more than once`
521
521
  },
522
522
 
523
- 104: {
523
+ 103: {
524
524
  file: "@apollo/client/__cjs/cache/inmemory/policies.cjs",
525
525
  message: "Cannot automatically merge arrays"
526
526
  },
527
527
 
528
- 105: {
528
+ 104: {
529
529
  file: "@apollo/client/__cjs/cache/inmemory/readFromStore.cjs",
530
530
  message: `No fragment named %s`
531
531
  },
532
532
 
533
- 106: {
533
+ 105: {
534
534
  file: "@apollo/client/__cjs/cache/inmemory/readFromStore.cjs",
535
535
  condition: "!(0, utilities_1.isReference)(value)",
536
536
  message: `Missing selection set for object of type %s returned for query field %s`
537
537
  },
538
538
 
539
- 107: {
539
+ 106: {
540
540
  file: "@apollo/client/__cjs/cache/inmemory/writeToStore.cjs",
541
541
  message: `Could not identify object %s`
542
542
  },
543
543
 
544
- 109: {
544
+ 108: {
545
545
  file: "@apollo/client/__cjs/cache/inmemory/writeToStore.cjs",
546
546
  message: `No fragment named %s`
547
547
  }
548
548
  };
549
549
 
550
550
  export const devDebug = {
551
- 78: {
551
+ 77: {
552
552
  file: "@apollo/client/__cjs/core/ApolloClient.cjs",
553
553
  message: `In client.refetchQueries, Promise.all promise rejected with error %o`
554
554
  },
555
555
 
556
- 84: {
556
+ 83: {
557
557
  file: "@apollo/client/__cjs/core/ObservableQuery.cjs",
558
558
  message: `Missing cache result fields: %o`
559
559
  }
@@ -588,58 +588,53 @@ export const devWarn = {
588
588
  },
589
589
 
590
590
  51: {
591
- file: "@apollo/client/__cjs/local-state/LocalState.cjs",
592
- message: "Could not find a resolver for the '%s' field. The field value has been set to `null`."
593
- },
594
-
595
- 52: {
596
591
  file: "@apollo/client/__cjs/local-state/LocalState.cjs",
597
592
  message: "The '%s' resolver returned `undefined` instead of a value. This is likely a bug in the resolver. If you didn't mean to return a value, return `null` instead."
598
593
  },
599
594
 
600
- 53: {
595
+ 52: {
601
596
  file: "@apollo/client/__cjs/local-state/LocalState.cjs",
602
597
  message: "The '%s' field had no cached value and only forced resolvers were run. The value was set to `null`."
603
598
  },
604
599
 
605
- 54: {
600
+ 53: {
606
601
  file: "@apollo/client/__cjs/local-state/LocalState.cjs",
607
602
  message: "The '%s' field on object %o returned `undefined` instead of a value. The parent resolver did not include the property in the returned value and there was no resolver defined for the field."
608
603
  },
609
604
 
610
- 64: {
605
+ 63: {
611
606
  file: "@apollo/client/__cjs/link/core/ApolloLink.cjs",
612
607
  message: `You are calling concat on a terminating link, which will have no effect %o`
613
608
  },
614
609
 
615
- 79: {
610
+ 78: {
616
611
  file: "@apollo/client/__cjs/core/ObservableQuery.cjs",
617
612
 
618
613
  message: `Called refetch(%o) for query %o, which does not declare a $variables variable.
619
614
  Did you mean to call refetch(variables) instead of refetch({ variables })?`
620
615
  },
621
616
 
622
- 83: {
617
+ 82: {
623
618
  file: "@apollo/client/__cjs/core/ObservableQuery.cjs",
624
619
  message: "Cannot poll on 'cache-only' query '%s' and as such, polling is disabled. Please use a different fetch policy."
625
620
  },
626
621
 
627
- 88: {
622
+ 87: {
628
623
  file: "@apollo/client/__cjs/core/QueryManager.cjs",
629
624
  message: `Unknown query named "%s" requested in refetchQueries options.include array`
630
625
  },
631
626
 
632
- 89: {
627
+ 88: {
633
628
  file: "@apollo/client/__cjs/core/QueryManager.cjs",
634
629
  message: `Unknown anonymous query requested in refetchQueries options.include array`
635
630
  },
636
631
 
637
- 94: {
632
+ 93: {
638
633
  file: "@apollo/client/__cjs/core/QueryManager.cjs",
639
634
  message: '[%s]: Fragments masked by data masking are inaccessible when using fetch policy "no-cache". Please add `@unmask` to each fragment spread to access the data.'
640
635
  },
641
636
 
642
- 98: {
637
+ 97: {
643
638
  file: "@apollo/client/__cjs/cache/inmemory/entityStore.cjs",
644
639
 
645
640
  message: "cache.modify: You are trying to write a Reference that is not part of the store: %o\n" +
@@ -647,24 +642,24 @@ Did you mean to call refetch(variables) instead of refetch({ variables })?`
647
642
  "`toReference(object, true)`"
648
643
  },
649
644
 
650
- 99: {
645
+ 98: {
651
646
  file: "@apollo/client/__cjs/cache/inmemory/entityStore.cjs",
652
647
 
653
648
  message: "cache.modify: Writing an array with a mix of both References and Objects will not result in the Objects being normalized correctly.\n" +
654
649
  "Please convert the object instance %o to a Reference before writing it to the cache by calling `toReference(object, true)`."
655
650
  },
656
651
 
657
- 102: {
652
+ 101: {
658
653
  file: "@apollo/client/__cjs/cache/inmemory/policies.cjs",
659
654
  message: `Inferring subtype %s of supertype %s`
660
655
  },
661
656
 
662
- 103: {
657
+ 102: {
663
658
  file: "@apollo/client/__cjs/cache/inmemory/policies.cjs",
664
659
  message: `Undefined 'from' passed to readField with arguments %s`
665
660
  },
666
661
 
667
- 110: {
662
+ 109: {
668
663
  file: "@apollo/client/__cjs/cache/inmemory/writeToStore.cjs",
669
664
 
670
665
  message: `Cache data may be lost when replacing the %s field of a %s object.
@@ -683,7 +678,7 @@ For more information about these options, please refer to the documentation:
683
678
  `
684
679
  },
685
680
 
686
- 111: {
681
+ 110: {
687
682
  file: "@apollo/client/__cjs/cache/core/cache.cjs",
688
683
  message: "Could not identify object passed to `from` for '%s' fragment, either because the object is non-normalized or the key fields are missing. If you are masking this object, please ensure the key fields are requested by the parent object."
689
684
  }
@@ -700,12 +695,12 @@ export const devError = {
700
695
  message: "The result of getSnapshot should be cached to avoid an infinite loop"
701
696
  },
702
697
 
703
- 82: {
698
+ 81: {
704
699
  file: "@apollo/client/__cjs/core/ObservableQuery.cjs",
705
700
  message: "Unhandled GraphQL subscription error"
706
701
  },
707
702
 
708
- 108: {
703
+ 107: {
709
704
  file: "@apollo/client/__cjs/cache/inmemory/writeToStore.cjs",
710
705
  message: `Missing field '%s' while writing result %o`
711
706
  }
@@ -6,36 +6,40 @@ const rxjs_1 = require("rxjs");
6
6
  const link_1 = require("@apollo/client/link");
7
7
  /**
8
8
  * @deprecated
9
- * Use `SetContextLink` from `@apollo/client/link/context` instead.
9
+ * Use `SetContextLink` from `@apollo/client/link/context` instead. Note you
10
+ * will need to flip the arguments when using `SetContextLink` as `prevContext`
11
+ * is the first argument.
12
+ *
13
+ * ```ts
14
+ * new SetContextLink((prevContext, operation) => {
15
+ * // ...
16
+ * })
17
+ * ```
10
18
  */
11
19
  function setContext(setter) {
12
- return new SetContextLink(setter);
20
+ return new SetContextLink((prevContext, operation) => setter(operation, prevContext));
13
21
  }
14
22
  class SetContextLink extends link_1.ApolloLink {
15
23
  constructor(setter) {
16
24
  super((operation, forward) => {
17
25
  const { ...request } = operation;
26
+ Object.defineProperty(request, "client", {
27
+ enumerable: false,
28
+ value: operation.client,
29
+ });
18
30
  return new rxjs_1.Observable((observer) => {
19
- let handle;
20
31
  let closed = false;
21
32
  Promise.resolve(request)
22
- .then((req) => setter(req, operation.getContext()))
33
+ .then((req) => setter(operation.getContext(), req))
23
34
  .then(operation.setContext)
24
35
  .then(() => {
25
- // if the observer is already closed, no need to subscribe.
26
- if (closed)
27
- return;
28
- handle = forward(operation).subscribe({
29
- next: observer.next.bind(observer),
30
- error: observer.error.bind(observer),
31
- complete: observer.complete.bind(observer),
32
- });
36
+ if (!closed) {
37
+ forward(operation).subscribe(observer);
38
+ }
33
39
  })
34
40
  .catch(observer.error.bind(observer));
35
41
  return () => {
36
42
  closed = true;
37
- if (handle)
38
- handle.unsubscribe();
39
43
  };
40
44
  });
41
45
  });
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":["../../../../src/link/context/index.ts"],"sourcesContent":["import type { Subscription } from \"rxjs\";\nimport { Observable } from \"rxjs\";\n\nimport type { GraphQLRequest, OperationContext } from \"@apollo/client/link\";\nimport { ApolloLink } from \"@apollo/client/link\";\n\nexport type ContextSetter = (\n operation: GraphQLRequest,\n prevContext: OperationContext\n) => Promise<Partial<OperationContext>> | Partial<OperationContext>;\n\n/**\n * @deprecated\n * Use `SetContextLink` from `@apollo/client/link/context` instead.\n */\nexport function setContext(setter: ContextSetter) {\n return new SetContextLink(setter);\n}\nexport class SetContextLink extends ApolloLink {\n constructor(setter: ContextSetter) {\n super((operation, forward) => {\n const { ...request } = operation;\n\n return new Observable((observer) => {\n let handle: Subscription;\n let closed = false;\n Promise.resolve(request)\n .then((req) => setter(req, operation.getContext()))\n .then(operation.setContext)\n .then(() => {\n // if the observer is already closed, no need to subscribe.\n if (closed) return;\n handle = forward(operation).subscribe({\n next: observer.next.bind(observer),\n error: observer.error.bind(observer),\n complete: observer.complete.bind(observer),\n });\n })\n .catch(observer.error.bind(observer));\n\n return () => {\n closed = true;\n if (handle) handle.unsubscribe();\n };\n });\n });\n }\n}\n"],"names":[],"mappings":";;;AAeA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA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AA,CAAA;"}
1
+ {"version":3,"file":"index.cjs","sources":["../../../../src/link/context/index.ts"],"sourcesContent":["import { Observable } from \"rxjs\";\n\nimport type { Operation, OperationContext } from \"@apollo/client/link\";\nimport { ApolloLink } from \"@apollo/client/link\";\n\nexport declare namespace SetContextLink {\n export type ContextSetter = (\n prevContext: OperationContext,\n operation: SetContextOperation\n ) => Promise<Partial<OperationContext>> | Partial<OperationContext>;\n\n export type LegacyContextSetter = (\n operation: SetContextOperation,\n prevContext: OperationContext\n ) => Promise<Partial<OperationContext>> | Partial<OperationContext>;\n\n export type SetContextOperation = Omit<\n Operation,\n \"getContext\" | \"setContext\"\n >;\n}\n\n/**\n * @deprecated\n * Use `SetContextLink` from `@apollo/client/link/context` instead. Note you\n * will need to flip the arguments when using `SetContextLink` as `prevContext`\n * is the first argument.\n *\n * ```ts\n * new SetContextLink((prevContext, operation) => {\n * // ...\n * })\n * ```\n */\nexport function setContext(setter: SetContextLink.LegacyContextSetter) {\n return new SetContextLink((prevContext, operation) =>\n setter(operation, prevContext)\n );\n}\nexport class SetContextLink extends ApolloLink {\n constructor(setter: SetContextLink.ContextSetter) {\n super((operation, forward) => {\n const { ...request } = operation as SetContextLink.SetContextOperation;\n\n Object.defineProperty(request, \"client\", {\n enumerable: false,\n value: operation.client,\n });\n\n return new Observable((observer) => {\n let closed = false;\n Promise.resolve(request)\n .then((req) => setter(operation.getContext(), req))\n .then(operation.setContext)\n .then(() => {\n if (!closed) {\n forward(operation).subscribe(observer);\n }\n })\n .catch(observer.error.bind(observer));\n\n return () => {\n closed = true;\n };\n });\n });\n }\n}\n"],"names":[],"mappings":";;;AAkCA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;AAlCA,CAAA,CAAA,CAAA,CAAA,EAAA,CAA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AAC;oBACxC;gBACF,CAAC;oBACX,CAAW,CAAX,CAAA,CAAA,CAAA,CAAgB,CAAC,CAAjB,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAyB,CAAC,CAA1B,CAAA,CAAA,CAAA,CAA+B,CAAC,CAAhC,CAAA,CAAA,CAAoC,CAAC,CAArC,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAA6C,CAAC,CAAC;gBAEvC,CAAR,CAAA,CAAA,CAAA,CAAA,EAAe,CAAf,EAAkB,CAAlB,EAAA;oBACU,CAAV,CAAA,CAAA,CAAA,CAAA,EAAA,EAAmB,CAAnB,CAAA,CAAA,CAAuB;gBACf,CAAC;YACH,CAAC,CAAC;QACJ,CAAC,CAAC;IACJ;AACF;AA5BA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;"}
@@ -1,12 +1,24 @@
1
- import type { GraphQLRequest, OperationContext } from "@apollo/client/link";
1
+ import type { Operation, OperationContext } from "@apollo/client/link";
2
2
  import { ApolloLink } from "@apollo/client/link";
3
- export type ContextSetter = (operation: GraphQLRequest, prevContext: OperationContext) => Promise<Partial<OperationContext>> | Partial<OperationContext>;
3
+ export declare namespace SetContextLink {
4
+ type ContextSetter = (prevContext: OperationContext, operation: SetContextOperation) => Promise<Partial<OperationContext>> | Partial<OperationContext>;
5
+ type LegacyContextSetter = (operation: SetContextOperation, prevContext: OperationContext) => Promise<Partial<OperationContext>> | Partial<OperationContext>;
6
+ type SetContextOperation = Omit<Operation, "getContext" | "setContext">;
7
+ }
4
8
  /**
5
9
  * @deprecated
6
- * Use `SetContextLink` from `@apollo/client/link/context` instead.
10
+ * Use `SetContextLink` from `@apollo/client/link/context` instead. Note you
11
+ * will need to flip the arguments when using `SetContextLink` as `prevContext`
12
+ * is the first argument.
13
+ *
14
+ * ```ts
15
+ * new SetContextLink((prevContext, operation) => {
16
+ * // ...
17
+ * })
18
+ * ```
7
19
  */
8
- export declare function setContext(setter: ContextSetter): SetContextLink;
20
+ export declare function setContext(setter: SetContextLink.LegacyContextSetter): SetContextLink;
9
21
  export declare class SetContextLink extends ApolloLink {
10
- constructor(setter: ContextSetter);
22
+ constructor(setter: SetContextLink.ContextSetter);
11
23
  }
12
24
  //# sourceMappingURL=index.d.cts.map
@@ -52,7 +52,7 @@ class ApolloLink {
52
52
  static concat(first, second) {
53
53
  const firstLink = toLink(first);
54
54
  if (isTerminating(firstLink)) {
55
- __DEV__ && invariant_1.invariant.warn(64, firstLink);
55
+ __DEV__ && invariant_1.invariant.warn(63, firstLink);
56
56
  return firstLink;
57
57
  }
58
58
  const nextLink = toLink(second);
@@ -81,7 +81,7 @@ class ApolloLink {
81
81
  return ApolloLink.concat(this, next);
82
82
  }
83
83
  request(operation, forward) {
84
- throw (0, invariant_1.newInvariantError)(65);
84
+ throw (0, invariant_1.newInvariantError)(64);
85
85
  }
86
86
  /**
87
87
  * @internal
@@ -1,4 +1,4 @@
1
- import type { FormattedExecutionResult, GraphQLFormattedError } from "graphql";
1
+ import type { FormattedExecutionResult, GraphQLFormattedError, OperationTypeNode } from "graphql";
2
2
  import type { DocumentNode } from "graphql";
3
3
  import type { Observable } from "rxjs";
4
4
  import type { ApolloClient, DefaultContext } from "@apollo/client";
@@ -11,6 +11,7 @@ export interface GraphQLRequest<TVariables = Record<string, any>> {
11
11
  query: DocumentNode;
12
12
  variables?: TVariables;
13
13
  operationName?: string;
14
+ operationType?: OperationTypeNode;
14
15
  context?: DefaultContext;
15
16
  extensions?: Record<string, any>;
16
17
  }
@@ -18,6 +19,7 @@ export interface Operation {
18
19
  query: DocumentNode;
19
20
  variables: Record<string, any>;
20
21
  operationName: string;
22
+ operationType: OperationTypeNode | undefined;
21
23
  extensions: Record<string, any>;
22
24
  setContext: {
23
25
  (context: Partial<OperationContext>): void;
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.checkFetcher = void 0;
4
4
  const invariant_1 = require("@apollo/client/utilities/invariant");
5
5
  const checkFetcher = (fetcher) => {
6
- (0, invariant_1.invariant)(fetcher || typeof fetch !== "undefined", 61);
6
+ (0, invariant_1.invariant)(fetcher || typeof fetch !== "undefined", 60);
7
7
  };
8
8
  exports.checkFetcher = checkFetcher;
9
9
  //# sourceMappingURL=checkFetcher.cjs.map
@@ -37,7 +37,7 @@ async function* consumeMultipartBody(response) {
37
37
  /;\s*boundary=(?:'([^']+)'|"([^"]+)"|([^"'].+?))\s*(?:;|$)/i);
38
38
  const boundary = "\r\n--" + (match?.findLast((val) => !!val) || "-");
39
39
  let buffer = "";
40
- (0, invariant_1.invariant)(response.body && typeof response.body.getReader === "function", 62);
40
+ (0, invariant_1.invariant)(response.body && typeof response.body.getReader === "function", 61);
41
41
  const reader = response.body.getReader();
42
42
  let done = false;
43
43
  let value;
@@ -8,7 +8,7 @@ const serializeFetchParameter = (p, label) => {
8
8
  serialized = JSON.stringify(p);
9
9
  }
10
10
  catch (e) {
11
- const parseError = (0, invariant_1.newInvariantError)(63, label, e.message);
11
+ const parseError = (0, invariant_1.newInvariantError)(62, label, e.message);
12
12
  parseError.parseError = e;
13
13
  throw parseError;
14
14
  }
@@ -54,7 +54,7 @@ class PersistedQueryLink extends link_1.ApolloLink {
54
54
  // hashing with something other than SHA-256.
55
55
  (0, invariant_1.invariant)(options &&
56
56
  (typeof options.sha256 === "function" ||
57
- typeof options.generateHash === "function"), 59);
57
+ typeof options.generateHash === "function"), 58);
58
58
  const { sha256,
59
59
  // If both a `sha256` and `generateHash` option are provided, the
60
60
  // `sha256` option will be ignored. Developers can configure and
@@ -80,7 +80,7 @@ class PersistedQueryLink extends link_1.ApolloLink {
80
80
  return hash;
81
81
  }
82
82
  super((operation, forward) => {
83
- (0, invariant_1.invariant)(forward, 60);
83
+ (0, invariant_1.invariant)(forward, 59);
84
84
  const { query } = operation;
85
85
  return new rxjs_1.Observable((observer) => {
86
86
  let subscription;
@@ -7,6 +7,7 @@ function transformOperation(operation) {
7
7
  variables: operation.variables || {},
8
8
  extensions: operation.extensions || {},
9
9
  operationName: operation.operationName,
10
+ operationType: operation.operationType,
10
11
  query: operation.query,
11
12
  };
12
13
  // Best guess at an operation name