Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running into import issues with @graphql-mesh/apollo-link #4196

Open
4 tasks
paales opened this issue Jul 26, 2022 · 0 comments
Open
4 tasks

Running into import issues with @graphql-mesh/apollo-link #4196

paales opened this issue Jul 26, 2022 · 0 comments

Comments

@paales
Copy link

paales commented Jul 26, 2022

Issue workflow progress

Progress of the issue based on the Contributor Workflow

Make sure to fork this template and run yarn generate in the terminal.

Please make sure Mesh package versions under package.json matches yours.

  • 2. A failing test has been provided
  • 3. A local solution has been provided
  • 4. A pull request is pending review

Describe the bug

Running into this issue: apollographql/apollo-client#9925 (comment)

To Reproduce
Steps to reproduce the behavior:

I'm using it in next.js, don't know if that makes a difference.

Additional context

If I follow the trail of the comments of the original issue

Which led me to this PR ardatan/graphql-tools#4539

Then this comment ardatan/graphql-tools#4539 (comment)

And then ardatan/graphql-tools@ff3c071

After applying the following patch, it seems to work as expected:

diff --git a/node_modules/@graphql-mesh/apollo-link/index.mjs b/node_modules/@graphql-mesh/apollo-link/index.mjs
index d1e2b34..fbf27e3 100644
--- a/node_modules/@graphql-mesh/apollo-link/index.mjs
+++ b/node_modules/@graphql-mesh/apollo-link/index.mjs
@@ -1,6 +1,8 @@
-import { ApolloLink, Observable } from '@apollo/client/core';
 import { isAsyncIterable } from '@graphql-tools/utils';
 import { getOperationAST } from 'graphql';
+import * as apolloImport from '@apollo/client';
+
+const apollo = apolloImport?.default ?? apolloImport;
 
 const ROOT_VALUE = {};
 function createMeshApolloRequestHandler(options) {
@@ -10,7 +12,7 @@ function createMeshApolloRequestHandler(options) {
             throw new Error('GraphQL operation not found');
         }
         const operationFn = operationAst.operation === 'subscription' ? options.subscribe : options.execute;
-        return new Observable(observer => {
+        return new apollo.Observable(observer => {
             Promise.resolve()
                 .then(async () => {
                 const results = await operationFn(operation.query, operation.variables, operation.getContext(), ROOT_VALUE, operation.operationName);
@@ -38,7 +40,7 @@ function createMeshApolloRequestHandler(options) {
         });
     };
 }
-class MeshApolloLink extends ApolloLink {
+class MeshApolloLink extends apollo.ApolloLink {
     constructor(options) {
         super(createMeshApolloRequestHandler(options));
     }
This was referenced Apr 30, 2024
This was referenced May 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant