@apollo/client 4.0.6 → 4.1.0-alpha.1

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 (121) hide show
  1. package/CHANGELOG.md +43 -4
  2. package/__cjs/cache/core/cache.cjs +1 -1
  3. package/__cjs/cache/core/cache.cjs.map +1 -1
  4. package/__cjs/cache/core/cache.d.cts +19 -0
  5. package/__cjs/cache/inmemory/entityStore.cjs +3 -3
  6. package/__cjs/cache/inmemory/entityStore.cjs.map +1 -1
  7. package/__cjs/cache/inmemory/inMemoryCache.cjs +3 -0
  8. package/__cjs/cache/inmemory/inMemoryCache.cjs.map +1 -1
  9. package/__cjs/cache/inmemory/inMemoryCache.d.cts +1 -0
  10. package/__cjs/cache/inmemory/key-extractor.cjs +1 -1
  11. package/__cjs/cache/inmemory/key-extractor.cjs.map +1 -1
  12. package/__cjs/cache/inmemory/policies.cjs +4 -4
  13. package/__cjs/cache/inmemory/policies.cjs.map +1 -1
  14. package/__cjs/cache/inmemory/readFromStore.cjs +2 -2
  15. package/__cjs/cache/inmemory/writeToStore.cjs +5 -5
  16. package/__cjs/cache/inmemory/writeToStore.cjs.map +1 -1
  17. package/__cjs/core/ApolloClient.cjs +14 -13
  18. package/__cjs/core/ApolloClient.cjs.map +1 -1
  19. package/__cjs/core/ApolloClient.d.cts +12 -0
  20. package/__cjs/core/ObservableQuery.cjs +157 -110
  21. package/__cjs/core/ObservableQuery.cjs.map +1 -1
  22. package/__cjs/core/ObservableQuery.d.cts +1 -0
  23. package/__cjs/core/QueryManager.cjs +19 -17
  24. package/__cjs/core/QueryManager.cjs.map +1 -1
  25. package/__cjs/incremental/handlers/defer20220824.cjs +20 -9
  26. package/__cjs/incremental/handlers/defer20220824.cjs.map +1 -1
  27. package/__cjs/incremental/handlers/defer20220824.d.cts +14 -5
  28. package/__cjs/incremental/handlers/graphql17Alpha9.cjs +181 -0
  29. package/__cjs/incremental/handlers/graphql17Alpha9.cjs.map +1 -0
  30. package/__cjs/incremental/handlers/graphql17Alpha9.d.cts +97 -0
  31. package/__cjs/incremental/handlers/notImplemented.cjs +1 -1
  32. package/__cjs/incremental/index.cjs +3 -1
  33. package/__cjs/incremental/index.cjs.map +1 -1
  34. package/__cjs/incremental/index.d.cts +1 -0
  35. package/__cjs/invariantErrorCodes.cjs +75 -59
  36. package/__cjs/link/core/ApolloLink.cjs +3 -3
  37. package/__cjs/link/http/checkFetcher.cjs +1 -1
  38. package/__cjs/link/http/parseAndCheckHttpResponse.cjs +1 -1
  39. package/__cjs/link/persisted-queries/index.cjs +2 -2
  40. package/__cjs/link/ws/index.cjs +1 -1
  41. package/__cjs/local-state/LocalState.cjs +28 -14
  42. package/__cjs/local-state/LocalState.cjs.map +1 -1
  43. package/__cjs/local-state/LocalState.d.cts +3 -2
  44. package/__cjs/react/hooks/useReactiveVar.cjs +1 -2
  45. package/__cjs/react/hooks/useReactiveVar.cjs.map +1 -1
  46. package/__cjs/react/hooks/useReactiveVar.d.cts +1 -2
  47. package/__cjs/react/internal/cache/QueryReference.cjs +16 -0
  48. package/__cjs/react/internal/cache/QueryReference.cjs.map +1 -1
  49. package/__cjs/react/internal/cache/QueryReference.d.cts +1 -0
  50. package/__cjs/testing/core/mocking/mockLink.cjs.map +1 -1
  51. package/__cjs/testing/core/mocking/mockLink.d.cts +1 -3
  52. package/__cjs/utilities/internal/DeepMerger.cjs +10 -1
  53. package/__cjs/utilities/internal/DeepMerger.cjs.map +1 -1
  54. package/__cjs/utilities/internal/DeepMerger.d.cts +14 -2
  55. package/__cjs/utilities/internal/getStoreKeyName.cjs +1 -0
  56. package/__cjs/utilities/internal/getStoreKeyName.cjs.map +1 -1
  57. package/__cjs/version.cjs +1 -1
  58. package/__cjs/version.cjs.map +1 -1
  59. package/cache/core/cache.d.ts +19 -0
  60. package/cache/core/cache.js +1 -1
  61. package/cache/core/cache.js.map +1 -1
  62. package/cache/inmemory/entityStore.js +3 -3
  63. package/cache/inmemory/entityStore.js.map +1 -1
  64. package/cache/inmemory/inMemoryCache.d.ts +1 -0
  65. package/cache/inmemory/inMemoryCache.js +3 -0
  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/policies.js.map +1 -1
  71. package/cache/inmemory/readFromStore.js +2 -2
  72. package/cache/inmemory/writeToStore.js +5 -5
  73. package/cache/inmemory/writeToStore.js.map +1 -1
  74. package/core/ApolloClient.d.ts +12 -0
  75. package/core/ApolloClient.js +14 -13
  76. package/core/ApolloClient.js.map +1 -1
  77. package/core/ObservableQuery.d.ts +1 -0
  78. package/core/ObservableQuery.js +159 -112
  79. package/core/ObservableQuery.js.map +1 -1
  80. package/core/QueryManager.js +19 -17
  81. package/core/QueryManager.js.map +1 -1
  82. package/incremental/handlers/defer20220824.d.ts +14 -5
  83. package/incremental/handlers/defer20220824.js +20 -9
  84. package/incremental/handlers/defer20220824.js.map +1 -1
  85. package/incremental/handlers/graphql17Alpha9.d.ts +97 -0
  86. package/incremental/handlers/graphql17Alpha9.js +177 -0
  87. package/incremental/handlers/graphql17Alpha9.js.map +1 -0
  88. package/incremental/handlers/notImplemented.js +1 -1
  89. package/incremental/index.d.ts +1 -0
  90. package/incremental/index.js +3 -2
  91. package/incremental/index.js.map +1 -1
  92. package/invariantErrorCodes.js +75 -59
  93. package/link/core/ApolloLink.js +3 -3
  94. package/link/http/checkFetcher.js +1 -1
  95. package/link/http/parseAndCheckHttpResponse.js +1 -1
  96. package/link/persisted-queries/index.js +2 -2
  97. package/link/ws/index.js +1 -1
  98. package/local-state/LocalState.d.ts +3 -2
  99. package/local-state/LocalState.js +28 -14
  100. package/local-state/LocalState.js.map +1 -1
  101. package/package.json +1 -1
  102. package/react/hooks/useReactiveVar.d.ts +1 -2
  103. package/react/hooks/useReactiveVar.js +1 -2
  104. package/react/hooks/useReactiveVar.js.map +1 -1
  105. package/react/hooks-compiled/useReactiveVar.d.ts +1 -2
  106. package/react/hooks-compiled/useReactiveVar.js +1 -2
  107. package/react/hooks-compiled/useReactiveVar.js.map +1 -1
  108. package/react/internal/cache/QueryReference.d.ts +1 -0
  109. package/react/internal/cache/QueryReference.js +16 -0
  110. package/react/internal/cache/QueryReference.js.map +1 -1
  111. package/testing/core/mocking/mockLink.d.ts +1 -3
  112. package/testing/core/mocking/mockLink.js.map +1 -1
  113. package/utilities/internal/DeepMerger.d.ts +14 -2
  114. package/utilities/internal/DeepMerger.js +10 -1
  115. package/utilities/internal/DeepMerger.js.map +1 -1
  116. package/utilities/internal/getStoreKeyName.js +1 -0
  117. package/utilities/internal/getStoreKeyName.js.map +1 -1
  118. package/utilities/internal/globals/global.js +2 -2
  119. package/utilities/internal/globals/global.js.map +1 -1
  120. package/version.js +1 -1
  121. package/version.js.map +1 -1
@@ -272,24 +272,24 @@ you have an infinite render loop in your application.`
272
272
  message: "No fragment named %s"
273
273
  },
274
274
 
275
- 53: {
275
+ 55: {
276
276
  file: "@apollo/client/local-state/LocalState.js",
277
277
  message: "Could not resolve __typename on object %o returned from resolver '%s'. '__typename' needs to be returned to properly resolve child fields."
278
278
  },
279
279
 
280
- 54: {
280
+ 56: {
281
281
  file: "@apollo/client/local-state/LocalState.js",
282
282
  condition: "fragment",
283
283
  message: `No fragment named %s`
284
284
  },
285
285
 
286
- 55: {
286
+ 57: {
287
287
  file: "@apollo/client/local-state/LocalState.js",
288
288
  condition: "cache.fragmentMatches",
289
289
  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`."
290
290
  },
291
291
 
292
- 57: {
292
+ 59: {
293
293
  file: "@apollo/client/link/persisted-queries/index.js",
294
294
  condition: "options &&\n (typeof options.sha256 === \"function\" ||\n typeof options.generateHash === \"function\")",
295
295
 
@@ -298,13 +298,13 @@ you have an infinite render loop in your application.`
298
298
  "parameter."
299
299
  },
300
300
 
301
- 58: {
301
+ 60: {
302
302
  file: "@apollo/client/link/persisted-queries/index.js",
303
303
  condition: "forward",
304
304
  message: "PersistedQueryLink cannot be the last link in the chain."
305
305
  },
306
306
 
307
- 59: {
307
+ 61: {
308
308
  file: "@apollo/client/link/http/checkFetcher.js",
309
309
  condition: "fetcher || typeof fetch !== \"undefined\"",
310
310
 
@@ -322,24 +322,30 @@ const client = new ApolloClient({
322
322
  `
323
323
  },
324
324
 
325
- 60: {
325
+ 62: {
326
326
  file: "@apollo/client/link/http/parseAndCheckHttpResponse.js",
327
327
  condition: "response.body && typeof response.body.getReader === \"function\"",
328
328
  message: "Unknown type for `response.body`. Please use a `fetch` implementation that is WhatWG-compliant and that uses WhatWG ReadableStreams for `body`."
329
329
  },
330
330
 
331
- 63: {
331
+ 65: {
332
332
  file: "@apollo/client/link/core/ApolloLink.js",
333
333
  message: "request is not implemented"
334
334
  },
335
335
 
336
- 64: {
336
+ 66: {
337
+ file: "@apollo/client/incremental/handlers/graphql17Alpha9.js",
338
+ condition: "pending",
339
+ message: "Could not find pending chunk for incremental value. Please file an issue for the Apollo Client team to investigate."
340
+ },
341
+
342
+ 67: {
337
343
  file: "@apollo/client/incremental/handlers/notImplemented.js",
338
344
  condition: "!hasDirectives([\"defer\"], request.query)",
339
345
  message: "`@defer` is not supported without specifying an incremental handler. Please pass a handler as the `incrementalHandler` option to the `ApolloClient` constructor."
340
346
  },
341
347
 
342
- 65: {
348
+ 68: {
343
349
  file: "@apollo/client/core/ApolloClient.js",
344
350
  condition: "options.cache",
345
351
 
@@ -348,7 +354,7 @@ const client = new ApolloClient({
348
354
  "For more information, please visit: https://go.apollo.dev/c/docs"
349
355
  },
350
356
 
351
- 66: {
357
+ 69: {
352
358
  file: "@apollo/client/core/ApolloClient.js",
353
359
  condition: "options.link",
354
360
 
@@ -357,7 +363,7 @@ const client = new ApolloClient({
357
363
  "For more information, please visit: https://go.apollo.dev/c/docs"
358
364
  },
359
365
 
360
- 67: {
366
+ 70: {
361
367
  file: "@apollo/client/core/ApolloClient.js",
362
368
  condition: "options.fetchPolicy !== \"cache-and-network\"",
363
369
 
@@ -367,7 +373,7 @@ const client = new ApolloClient({
367
373
  "using a different fetchPolicy, such as cache-first or network-only."
368
374
  },
369
375
 
370
- 68: {
376
+ 71: {
371
377
  file: "@apollo/client/core/ApolloClient.js",
372
378
  condition: "options.fetchPolicy !== \"standby\"",
373
379
 
@@ -376,7 +382,7 @@ const client = new ApolloClient({
376
382
  "as cache-first or network-only."
377
383
  },
378
384
 
379
- 69: {
385
+ 72: {
380
386
  file: "@apollo/client/core/ApolloClient.js",
381
387
  condition: "options.query",
382
388
 
@@ -384,158 +390,158 @@ const client = new ApolloClient({
384
390
  "in the query option."
385
391
  },
386
392
 
387
- 70: {
393
+ 73: {
388
394
  file: "@apollo/client/core/ApolloClient.js",
389
395
  condition: "options.query.kind === \"Document\"",
390
396
  message: 'You must wrap the query string in a "gql" tag.'
391
397
  },
392
398
 
393
- 71: {
399
+ 74: {
394
400
  file: "@apollo/client/core/ApolloClient.js",
395
401
  condition: "!options.returnPartialData",
396
402
  message: "returnPartialData option only supported on watchQuery."
397
403
  },
398
404
 
399
- 72: {
405
+ 75: {
400
406
  file: "@apollo/client/core/ApolloClient.js",
401
407
  condition: "!options.pollInterval",
402
408
  message: "pollInterval option only supported on watchQuery."
403
409
  },
404
410
 
405
- 73: {
411
+ 76: {
406
412
  file: "@apollo/client/core/ApolloClient.js",
407
413
  condition: "!options.notifyOnNetworkStatusChange",
408
414
  message: "notifyOnNetworkStatusChange option only supported on watchQuery."
409
415
  },
410
416
 
411
- 74: {
417
+ 77: {
412
418
  file: "@apollo/client/core/ApolloClient.js",
413
419
  condition: "optionsWithDefaults.mutation",
414
420
  message: "The `mutation` option is required. Please provide a GraphQL document in the `mutation` option."
415
421
  },
416
422
 
417
- 75: {
423
+ 78: {
418
424
  file: "@apollo/client/core/ApolloClient.js",
419
425
  condition: "optionsWithDefaults.fetchPolicy === \"network-only\" ||\n optionsWithDefaults.fetchPolicy === \"no-cache\"",
420
426
  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."
421
427
  },
422
428
 
423
- 78: {
429
+ 81: {
424
430
  file: "@apollo/client/core/ObservableQuery.js",
425
431
  condition: "this.options.fetchPolicy !== \"cache-only\"",
426
432
  message: "Cannot execute `fetchMore` for 'cache-only' query '%s'. Please use a different fetch policy."
427
433
  },
428
434
 
429
- 79: {
435
+ 82: {
430
436
  file: "@apollo/client/core/ObservableQuery.js",
431
437
  condition: "updateQuery",
432
438
  message: "You must provide an `updateQuery` function when using `fetchMore` with a `no-cache` fetch policy."
433
439
  },
434
440
 
435
- 83: {
441
+ 86: {
436
442
  file: "@apollo/client/core/QueryManager.js",
437
443
  message: "QueryManager stopped while query was in flight"
438
444
  },
439
445
 
440
- 84: {
446
+ 87: {
441
447
  file: "@apollo/client/core/QueryManager.js",
442
448
  condition: "this.localState",
443
449
  message: "Mutation '%s' contains `@client` fields with variables provided by `@export` but local state has not been configured."
444
450
  },
445
451
 
446
- 85: {
452
+ 88: {
447
453
  file: "@apollo/client/core/QueryManager.js",
448
454
  message: "Store reset while query was in flight (not completed in link chain)"
449
455
  },
450
456
 
451
- 88: {
457
+ 91: {
452
458
  file: "@apollo/client/core/QueryManager.js",
453
459
  condition: "!this.getDocumentInfo(query).hasClientExports || this.localState",
454
460
  message: "Subscription '%s' contains `@client` fields with variables provided by `@export` but local state has not been configured."
455
461
  },
456
462
 
457
- 89: {
463
+ 92: {
458
464
  file: "@apollo/client/core/QueryManager.js",
459
465
  condition: "this.localState",
460
466
  message: "%s '%s' contains `@client` fields but local state has not been configured."
461
467
  },
462
468
 
463
- 90: {
469
+ 93: {
464
470
  file: "@apollo/client/core/QueryManager.js",
465
471
  condition: "!hasIncrementalDirective",
466
472
  message: "%s '%s' contains `@client` and `@defer` directives. These cannot be used together."
467
473
  },
468
474
 
469
- 91: {
475
+ 94: {
470
476
  file: "@apollo/client/core/QueryManager.js",
471
477
  condition: "this.localState",
472
478
  message: "Query '%s' contains `@client` fields with variables provided by `@export` but local state has not been configured."
473
479
  },
474
480
 
475
- 93: {
481
+ 96: {
476
482
  file: "@apollo/client/core/QueryManager.js",
477
483
  condition: "this.localState",
478
484
  message: "Query '%s' contains `@client` fields but local state has not been configured."
479
485
  },
480
486
 
481
- 94: {
487
+ 97: {
482
488
  file: "@apollo/client/core/QueryManager.js",
483
489
  condition: "didEmitValue",
484
490
  message: "The link chain completed without emitting a value. This is likely unintentional and should be updated to emit a value before completing."
485
491
  },
486
492
 
487
- 95: {
493
+ 98: {
488
494
  file: "@apollo/client/cache/inmemory/entityStore.js",
489
495
  condition: "typeof dataId === \"string\"",
490
496
  message: "store.merge expects a string ID"
491
497
  },
492
498
 
493
- 98: {
499
+ 101: {
494
500
  file: "@apollo/client/cache/inmemory/key-extractor.js",
495
501
  condition: "extracted !== void 0",
496
502
  message: `Missing field '%s' while extracting keyFields from %s`
497
503
  },
498
504
 
499
- 99: {
505
+ 102: {
500
506
  file: "@apollo/client/cache/inmemory/policies.js",
501
507
  condition: "!old || old === which",
502
508
  message: `Cannot change root %s __typename more than once`
503
509
  },
504
510
 
505
- 102: {
511
+ 105: {
506
512
  file: "@apollo/client/cache/inmemory/policies.js",
507
513
  message: "Cannot automatically merge arrays"
508
514
  },
509
515
 
510
- 103: {
516
+ 106: {
511
517
  file: "@apollo/client/cache/inmemory/readFromStore.js",
512
518
  message: `No fragment named %s`
513
519
  },
514
520
 
515
- 104: {
521
+ 107: {
516
522
  file: "@apollo/client/cache/inmemory/readFromStore.js",
517
523
  condition: "!isReference(value)",
518
524
  message: `Missing selection set for object of type %s returned for query field %s`
519
525
  },
520
526
 
521
- 105: {
527
+ 108: {
522
528
  file: "@apollo/client/cache/inmemory/writeToStore.js",
523
529
  message: `Could not identify object %s`
524
530
  },
525
531
 
526
- 107: {
532
+ 110: {
527
533
  file: "@apollo/client/cache/inmemory/writeToStore.js",
528
534
  message: `No fragment named %s`
529
535
  }
530
536
  };
531
537
 
532
538
  export const devDebug = {
533
- 76: {
539
+ 79: {
534
540
  file: "@apollo/client/core/ApolloClient.js",
535
541
  message: `In client.refetchQueries, Promise.all promise rejected with error %o`
536
542
  },
537
543
 
538
- 82: {
544
+ 85: {
539
545
  file: "@apollo/client/core/ObservableQuery.js",
540
546
  message: `Missing cache result fields: %o`
541
547
  }
@@ -571,30 +577,40 @@ export const devWarn = {
571
577
 
572
578
  50: {
573
579
  file: "@apollo/client/local-state/LocalState.js",
574
- 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."
580
+ message: "The '%s' field resolves the value from the cache, for example from a 'read' function, but a 'no-cache' fetch policy was used. The field value has been set to `null`. Either define a local resolver or use a fetch policy that uses the cache to ensure the field is resolved correctly."
575
581
  },
576
582
 
577
583
  51: {
578
584
  file: "@apollo/client/local-state/LocalState.js",
579
- message: "The '%s' field had no cached value and only forced resolvers were run. The value was set to `null`."
585
+ message: "Could not find a resolver for the '%s' field nor does the cache resolve the field. The field value has been set to `null`. Either define a resolver for the field or ensure the cache can resolve the value, for example, by adding a 'read' function to a field policy in 'InMemoryCache'."
580
586
  },
581
587
 
582
588
  52: {
589
+ file: "@apollo/client/local-state/LocalState.js",
590
+ 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."
591
+ },
592
+
593
+ 53: {
594
+ file: "@apollo/client/local-state/LocalState.js",
595
+ message: "The '%s' field had no cached value and only forced resolvers were run. The value was set to `null`."
596
+ },
597
+
598
+ 54: {
583
599
  file: "@apollo/client/local-state/LocalState.js",
584
600
  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."
585
601
  },
586
602
 
587
- 56: {
603
+ 58: {
588
604
  file: "@apollo/client/link/ws/index.js",
589
605
  message: "`WebSocketLink` uses the deprecated and unmaintained `subscriptions-transport-ws` library. This link is no longer maintained and will be removed in a future major version of Apollo Client. We recommend switching to `GraphQLWsLink` which uses the `graphql-ws` library to send GraphQL operations through WebSocket connections (https://the-guild.dev/graphql/ws)."
590
606
  },
591
607
 
592
- 61: {
608
+ 63: {
593
609
  file: "@apollo/client/link/core/ApolloLink.js",
594
610
  message: "[ApolloLink.split]: The test function returned a non-boolean value which could result in subtle bugs (e.g. such as using an `async` function which always returns a truthy value). Got `%o`."
595
611
  },
596
612
 
597
- 62: {
613
+ 64: {
598
614
  file: "@apollo/client/link/core/ApolloLink.js",
599
615
 
600
616
  message: "The terminating link provided to `ApolloLink.execute` called `forward` instead of handling the request. " +
@@ -603,34 +619,34 @@ export const devWarn = {
603
619
  "If you are using a split link, ensure each branch contains a terminating link that handles the request."
604
620
  },
605
621
 
606
- 77: {
622
+ 80: {
607
623
  file: "@apollo/client/core/ObservableQuery.js",
608
624
 
609
625
  message: `Called refetch(%o) for query %o, which does not declare a $variables variable.
610
626
  Did you mean to call refetch(variables) instead of refetch({ variables })?`
611
627
  },
612
628
 
613
- 81: {
629
+ 84: {
614
630
  file: "@apollo/client/core/ObservableQuery.js",
615
631
  message: "Cannot poll on 'cache-only' query '%s' and as such, polling is disabled. Please use a different fetch policy."
616
632
  },
617
633
 
618
- 86: {
634
+ 89: {
619
635
  file: "@apollo/client/core/QueryManager.js",
620
636
  message: `Unknown query named "%s" requested in refetchQueries options.include array`
621
637
  },
622
638
 
623
- 87: {
639
+ 90: {
624
640
  file: "@apollo/client/core/QueryManager.js",
625
641
  message: `Unknown anonymous query requested in refetchQueries options.include array`
626
642
  },
627
643
 
628
- 92: {
644
+ 95: {
629
645
  file: "@apollo/client/core/QueryManager.js",
630
646
  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.'
631
647
  },
632
648
 
633
- 96: {
649
+ 99: {
634
650
  file: "@apollo/client/cache/inmemory/entityStore.js",
635
651
 
636
652
  message: "cache.modify: You are trying to write a Reference that is not part of the store: %o\n" +
@@ -638,24 +654,24 @@ Did you mean to call refetch(variables) instead of refetch({ variables })?`
638
654
  "`toReference(object, true)`"
639
655
  },
640
656
 
641
- 97: {
657
+ 100: {
642
658
  file: "@apollo/client/cache/inmemory/entityStore.js",
643
659
 
644
660
  message: "cache.modify: Writing an array with a mix of both References and Objects will not result in the Objects being normalized correctly.\n" +
645
661
  "Please convert the object instance %o to a Reference before writing it to the cache by calling `toReference(object, true)`."
646
662
  },
647
663
 
648
- 100: {
664
+ 103: {
649
665
  file: "@apollo/client/cache/inmemory/policies.js",
650
666
  message: `Inferring subtype %s of supertype %s`
651
667
  },
652
668
 
653
- 101: {
669
+ 104: {
654
670
  file: "@apollo/client/cache/inmemory/policies.js",
655
671
  message: `Undefined 'from' passed to readField with arguments %s`
656
672
  },
657
673
 
658
- 108: {
674
+ 111: {
659
675
  file: "@apollo/client/cache/inmemory/writeToStore.js",
660
676
 
661
677
  message: `Cache data may be lost when replacing the %s field of a %s object.
@@ -674,7 +690,7 @@ For more information about these options, please refer to the documentation:
674
690
  `
675
691
  },
676
692
 
677
- 109: {
693
+ 112: {
678
694
  file: "@apollo/client/cache/core/cache.js",
679
695
  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."
680
696
  }
@@ -691,12 +707,12 @@ export const devError = {
691
707
  message: "The result of getSnapshot should be cached to avoid an infinite loop"
692
708
  },
693
709
 
694
- 80: {
710
+ 83: {
695
711
  file: "@apollo/client/core/ObservableQuery.js",
696
712
  message: "Unhandled GraphQL subscription error"
697
713
  },
698
714
 
699
- 106: {
715
+ 109: {
700
716
  file: "@apollo/client/cache/inmemory/writeToStore.js",
701
717
  message: `Missing field '%s' while writing result %o`
702
718
  }
@@ -100,7 +100,7 @@ export class ApolloLink {
100
100
  const result = test(operation);
101
101
  if (__DEV__) {
102
102
  if (typeof result !== "boolean") {
103
- __DEV__ && invariant.warn(61, result);
103
+ __DEV__ && invariant.warn(63, result);
104
104
  }
105
105
  }
106
106
  return result ?
@@ -142,7 +142,7 @@ export class ApolloLink {
142
142
  static execute(link, request, context) {
143
143
  return link.request(createOperation(request, context), () => {
144
144
  if (__DEV__) {
145
- __DEV__ && invariant.warn(62);
145
+ __DEV__ && invariant.warn(64);
146
146
  }
147
147
  return EMPTY;
148
148
  });
@@ -246,7 +246,7 @@ export class ApolloLink {
246
246
  * > request instead.
247
247
  */
248
248
  request(operation, forward) {
249
- throw newInvariantError(63);
249
+ throw newInvariantError(65);
250
250
  }
251
251
  /**
252
252
  * @internal
@@ -1,5 +1,5 @@
1
1
  import { invariant } from "@apollo/client/utilities/invariant";
2
2
  export const checkFetcher = (fetcher) => {
3
- invariant(fetcher || typeof fetch !== "undefined", 59);
3
+ invariant(fetcher || typeof fetch !== "undefined", 61);
4
4
  };
5
5
  //# sourceMappingURL=checkFetcher.js.map
@@ -33,7 +33,7 @@ async function* consumeMultipartBody(response) {
33
33
  /;\s*boundary=(?:'([^']+)'|"([^"]+)"|([^"'].+?))\s*(?:;|$)/i);
34
34
  const boundary = "\r\n--" + (match?.findLast((val) => !!val) || "-");
35
35
  let buffer = "";
36
- invariant(response.body && typeof response.body.getReader === "function", 60);
36
+ invariant(response.body && typeof response.body.getReader === "function", 62);
37
37
  const stream = response.body;
38
38
  const reader = stream.getReader();
39
39
  let done = false;
@@ -66,7 +66,7 @@ export class PersistedQueryLink extends ApolloLink {
66
66
  // hashing with something other than SHA-256.
67
67
  invariant(options &&
68
68
  (typeof options.sha256 === "function" ||
69
- typeof options.generateHash === "function"), 57);
69
+ typeof options.generateHash === "function"), 59);
70
70
  const { sha256,
71
71
  // If both a `sha256` and `generateHash` option are provided, the
72
72
  // `sha256` option will be ignored. Developers can configure and
@@ -92,7 +92,7 @@ export class PersistedQueryLink extends ApolloLink {
92
92
  return hash;
93
93
  }
94
94
  super((operation, forward) => {
95
- invariant(forward, 58);
95
+ invariant(forward, 60);
96
96
  const { query } = operation;
97
97
  return new Observable((observer) => {
98
98
  let subscription;
package/link/ws/index.js CHANGED
@@ -32,7 +32,7 @@ export class WebSocketLink extends ApolloLink {
32
32
  constructor(paramsOrClient) {
33
33
  super();
34
34
  if (__DEV__) {
35
- __DEV__ && invariant.warn(56);
35
+ __DEV__ && invariant.warn(58);
36
36
  }
37
37
  if (paramsOrClient instanceof SubscriptionClient) {
38
38
  this.subscriptionClient = paramsOrClient;
@@ -1,5 +1,5 @@
1
1
  import type { DocumentNode, FieldNode, FormattedExecutionResult } from "graphql";
2
- import type { ApolloClient, DefaultContext, OperationVariables, TypedDocumentNode } from "@apollo/client";
2
+ import type { ApolloClient, DefaultContext, OperationVariables, TypedDocumentNode, WatchQueryFetchPolicy } from "@apollo/client";
3
3
  import type { FragmentMap, NoInfer, RemoveIndexSignature } from "@apollo/client/utilities/internal";
4
4
  type InferContextValueFromResolvers<TResolvers> = TResolvers extends {
5
5
  [typename: string]: infer TFieldResolvers;
@@ -155,7 +155,7 @@ export declare class LocalState<TResolvers extends LocalState.Resolvers = LocalS
155
155
  * ```
156
156
  */
157
157
  addResolvers(resolvers: TResolvers): void;
158
- execute<TData = unknown, TVariables extends OperationVariables = OperationVariables>({ document, client, context, remoteResult, variables, onlyRunForcedResolvers, returnPartialData, }: {
158
+ execute<TData = unknown, TVariables extends OperationVariables = OperationVariables>({ document, client, context, remoteResult, variables, onlyRunForcedResolvers, returnPartialData, fetchPolicy, }: {
159
159
  document: DocumentNode | TypedDocumentNode<TData, TVariables>;
160
160
  client: ApolloClient;
161
161
  context: DefaultContext | undefined;
@@ -163,6 +163,7 @@ export declare class LocalState<TResolvers extends LocalState.Resolvers = LocalS
163
163
  variables: TVariables | undefined;
164
164
  onlyRunForcedResolvers?: boolean;
165
165
  returnPartialData?: boolean;
166
+ fetchPolicy: WatchQueryFetchPolicy;
166
167
  }): Promise<FormattedExecutionResult<TData>>;
167
168
  getExportedVariables<TVariables extends OperationVariables = OperationVariables>({ document, client, context, variables, }: {
168
169
  document: DocumentNode | TypedDocumentNode<any, TVariables>;
@@ -64,7 +64,7 @@ export class LocalState {
64
64
  addResolvers(resolvers) {
65
65
  this.resolvers = mergeDeep(this.resolvers, resolvers);
66
66
  }
67
- async execute({ document, client, context, remoteResult, variables = {}, onlyRunForcedResolvers = false, returnPartialData = false, }) {
67
+ async execute({ document, client, context, remoteResult, variables = {}, onlyRunForcedResolvers = false, returnPartialData = false, fetchPolicy, }) {
68
68
  if (__DEV__) {
69
69
  invariant(hasDirectives(["client"], document), 47);
70
70
  validateCacheImplementation(client.cache);
@@ -78,12 +78,14 @@ export class LocalState {
78
78
  }
79
79
  const { selectionsToResolve, exportedVariableDefs, operationDefinition, fragmentMap, } = this.collectQueryDetail(document);
80
80
  const rootValue = remoteResult ? remoteResult.data : {};
81
- const diff = client.cache.diff({
82
- query: toQueryOperation(document),
83
- variables,
84
- returnPartialData: true,
85
- optimistic: false,
86
- });
81
+ const diff = fetchPolicy === "no-cache" ?
82
+ { result: null, complete: false }
83
+ : client.cache.diff({
84
+ query: toQueryOperation(document),
85
+ variables,
86
+ returnPartialData: true,
87
+ optimistic: false,
88
+ });
87
89
  const requestContext = { ...client.defaultContext, ...context };
88
90
  const execContext = {
89
91
  client,
@@ -105,6 +107,7 @@ export class LocalState {
105
107
  exportedVariableDefs,
106
108
  diff,
107
109
  returnPartialData,
110
+ fetchPolicy,
108
111
  };
109
112
  const localResult = await this.resolveSelectionSet(operationDefinition.selectionSet, false, rootValue, execContext, []);
110
113
  const errors = (remoteResult?.errors ?? []).concat(execContext.errors);
@@ -241,7 +244,8 @@ export class LocalState {
241
244
  return this.resolveSelectionSet(field.selectionSet, false, result, execContext, path);
242
245
  }
243
246
  async resolveClientField(field, isClientFieldDescendant, rootValue, execContext, parentSelectionSet, path) {
244
- const { client, diff, variables, operationDefinition, phase, returnPartialData, onlyRunForcedResolvers, } = execContext;
247
+ const { client, diff, variables, operationDefinition, phase, onlyRunForcedResolvers, fetchPolicy, } = execContext;
248
+ let { returnPartialData } = execContext;
245
249
  const isRootField = parentSelectionSet === operationDefinition.selectionSet;
246
250
  const fieldName = field.name.value;
247
251
  const typename = isRootField ?
@@ -263,7 +267,17 @@ export class LocalState {
263
267
  if (fieldFromCache !== undefined) {
264
268
  return fieldFromCache;
265
269
  }
270
+ if (client.cache.resolvesClientField?.(typename, fieldName)) {
271
+ if (fetchPolicy === "no-cache") {
272
+ __DEV__ && invariant.warn(50, resolverName);
273
+ return null;
274
+ }
275
+ // assume the cache will handle returning the correct value
276
+ returnPartialData = true;
277
+ return;
278
+ }
266
279
  if (!returnPartialData) {
280
+ __DEV__ && invariant.warn(51, resolverName);
267
281
  return null;
268
282
  }
269
283
  });
@@ -329,13 +343,13 @@ export class LocalState {
329
343
  if (result === undefined && !returnPartialData) {
330
344
  if (__DEV__ && phase === "resolve") {
331
345
  if (resolver && !onlyRunForcedResolvers) {
332
- __DEV__ && invariant.warn(50, resolverName);
346
+ __DEV__ && invariant.warn(52, resolverName);
333
347
  }
334
348
  else if (onlyRunForcedResolvers) {
335
- __DEV__ && invariant.warn(51, resolverName);
349
+ __DEV__ && invariant.warn(53, resolverName);
336
350
  }
337
351
  else {
338
- __DEV__ && invariant.warn(52, fieldName, rootValue);
352
+ __DEV__ && invariant.warn(54, fieldName, rootValue);
339
353
  }
340
354
  }
341
355
  result = null;
@@ -347,7 +361,7 @@ export class LocalState {
347
361
  return this.resolveSubSelectedArray(field, true, result, execContext, path);
348
362
  }
349
363
  if (phase === "resolve" && !result.__typename) {
350
- this.addError(newInvariantError(53, result, resolverName), path, execContext, { resolver: resolverName });
364
+ this.addError(newInvariantError(55, result, resolverName), path, execContext, { resolver: resolverName });
351
365
  return null;
352
366
  }
353
367
  return this.resolveSelectionSet(field.selectionSet, true, result, execContext, path);
@@ -458,7 +472,7 @@ export class LocalState {
458
472
  },
459
473
  FragmentSpread(spread, _, __, ___, ancestors) {
460
474
  const fragment = fragmentMap[spread.name.value];
461
- invariant(fragment, 54, spread.name.value);
475
+ invariant(fragment, 56, spread.name.value);
462
476
  const { selectionsToResolve: fragmentSelections } = traverse(fragment);
463
477
  if (fragmentSelections.size > 0) {
464
478
  // Fragment for this spread contains @client directive (either directly or transitively)
@@ -517,7 +531,7 @@ function getExportedVariableName(directive) {
517
531
  }
518
532
  }
519
533
  function validateCacheImplementation(cache) {
520
- invariant(cache.fragmentMatches, 55);
534
+ invariant(cache.fragmentMatches, 57);
521
535
  }
522
536
  function getCacheResultAtPath(diff, path) {
523
537
  if (diff.result === null) {