question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

@apollo/client compatibility

See original GitHub issue

Hi! I tried apollo-link-debounce on @apollo/client, but the packages have slightly changed. In particular, ApolloLink is now part of @apollo/client (rather than apollo-link), and a few fields have been added (onError and setOnError, which seems to be very small functions - probably inheritable?).

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:9
  • Comments:12 (7 by maintainers)

github_iconTop GitHub Comments

6reactions
omermancommented, Mar 16, 2021

@1v4nx published ur work to npm because I would like to use it right away… -> https://www.npmjs.com/package/omerman-apollo-link-debounce

3reactions
bennypowerscommented, Sep 9, 2020

While we wait for the PR, you can apply this patch with patch-package (this patch also happens to convert the file to standard modules for better browser support)

patches/apollo-link-debounce+2.1.0.patch
diff --git a/node_modules/apollo-link-debounce/build/dist/DebounceLink.d.ts b/node_modules/apollo-link-debounce/build/dist/DebounceLink.d.ts
index 06bf050..c48a961 100644
--- a/node_modules/apollo-link-debounce/build/dist/DebounceLink.d.ts
+++ b/node_modules/apollo-link-debounce/build/dist/DebounceLink.d.ts
@@ -1,5 +1,4 @@
-import { ApolloLink, Operation, NextLink } from 'apollo-link';
-import { Observable } from 'zen-observable-ts';
+import { ApolloLink, Operation, NextLink, Observable } from '@apollo/client/core ';
 export default class DebounceLink extends ApolloLink {
     private debounceInfo;
     private defaultDelay;
diff --git a/node_modules/apollo-link-debounce/build/dist/DebounceLink.js b/node_modules/apollo-link-debounce/build/dist/DebounceLink.js
index f52668b..f66932c 100644
--- a/node_modules/apollo-link-debounce/build/dist/DebounceLink.js
+++ b/node_modules/apollo-link-debounce/build/dist/DebounceLink.js
@@ -1,4 +1,3 @@
-"use strict";
 var __extends = (this && this.__extends) || (function () {
     var extendStatics = Object.setPrototypeOf ||
         ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
@@ -9,10 +8,9 @@ var __extends = (this && this.__extends) || (function () {
         d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
     };
 })();
-exports.__esModule = true;
-var apollo_link_1 = require("apollo-link");
-var zen_observable_ts_1 = require("zen-observable-ts");
-var DebounceLink = (function (_super) {
+import { ApolloLink } from "@apollo/client/link/core";
+import { Observable } from "@apollo/client/utilities";
+const DebounceLink = (function (_super) {
     __extends(DebounceLink, _super);
     function DebounceLink(defaultDelay) {
         var _this = _super.call(this) || this;
@@ -63,7 +61,7 @@ var DebounceLink = (function (_super) {
         if (!debounceKey) {
             return forward(operation);
         }
-        return new zen_observable_ts_1.Observable(function (observer) {
+        return new Observable(function (observer) {
             var debounceGroupId = _this.enqueueRequest({ debounceKey: debounceKey, debounceTimeout: debounceTimeout }, { operation: operation, forward: forward, observer: observer });
             return function () {
                 _this.unsubscribe(debounceKey, debounceGroupId, observer);
@@ -123,6 +121,6 @@ var DebounceLink = (function (_super) {
         dbi.currentGroupId++;
     };
     return DebounceLink;
-}(apollo_link_1.ApolloLink));
-exports["default"] = DebounceLink;
+}(ApolloLink));
+export default DebounceLink;
 //# sourceMappingURL=DebounceLink.js.map
\ No newline at end of file
diff --git a/node_modules/apollo-link-debounce/build/dist/index.d.ts b/node_modules/apollo-link-debounce/build/dist/index.d.ts
index bc94fdf..d45236d 100644
--- a/node_modules/apollo-link-debounce/build/dist/index.d.ts
+++ b/node_modules/apollo-link-debounce/build/dist/index.d.ts
@@ -1,2 +1,3 @@
 import DebounceLink from './DebounceLink';
+export { DebounceLink };
 export default DebounceLink;
diff --git a/node_modules/apollo-link-debounce/build/dist/index.js b/node_modules/apollo-link-debounce/build/dist/index.js
index 2f651f0..f5a365f 100644
--- a/node_modules/apollo-link-debounce/build/dist/index.js
+++ b/node_modules/apollo-link-debounce/build/dist/index.js
@@ -1,5 +1,3 @@
-"use strict";
-exports.__esModule = true;
-var DebounceLink_1 = require("./DebounceLink");
-exports["default"] = DebounceLink_1["default"];
-//# sourceMappingURL=index.js.map
\ No newline at end of file
+import DebounceLink from './DebounceLink.js';
+export { DebounceLink };
+export default DebounceLink;

By the way, I noticed you’re exporting CJS Modules with classes compiled down to ES5. Would you consider a further PR (after this one) that would change the output target to, say, ES2017 and the module format to standard ES Modules? That would help with bundle size and runtime performance. Legacy users would still be able to transpile at build-time as an app-level operation.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Migrating to Apollo Client 3.0 - Apollo GraphQL Docs
Apollo Client 3.0 introduces powerful improvements to its caching system. Most of these improvements are backward compatible, so most applications will continue ...
Read more >
class ApolloClient - Apollo GraphQL Docs
The ApolloClient class encapsulates Apollo's core client-side API. ... currently the default behavior, for backwards compatibility with Apollo Client 3.x.
Read more >
Introduction to Apollo Client - Apollo GraphQL Docs
Universally compatible: Use any build setup and any GraphQL API. Community driven: Share knowledge with thousands of developers in the GraphQL community.
Read more >
Federation-compatible subgraph implementations
The following open-source GraphQL server libraries and hosted solutions support acting as a subgraph in a federated supergraph. Their support is tracked in ......
Read more >
Integrating with React Native - Apollo GraphQL Docs
React Native Debugger supports the Apollo Client Devtools: Install React Native Debugger and open it. Enable "Debug JS Remotely" in your app. If...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found