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

Type 'QueueLink' is not assignable to type 'ApolloLink | RequestHandler' #50

Closed
sajadghawami opened this issue Nov 24, 2021 · 6 comments

Comments

@sajadghawami
Copy link

Hey there,

This is the code.

import QueueLink from "apollo-link-queue";
const queueLink = new QueueLink();

const client = (hostName: string, initialState?: any) => {
  return new ApolloClient({
    link: ApolloLink.from([
      errorLink,
      queueLink,
      retryLink,
      authLink.concat(createUploadLink({ uri: `${hostName}/api/graphql` })),
    ]),
    cache: cache.restore(initialState || {}),
  });
};

i am having the following error:

Bildschirmfoto 2021-11-24 um 14 45 45

Type 'QueueLink' is not assignable to type 'ApolloLink | RequestHandler'.
  Type 'QueueLink' is not assignable to type 'ApolloLink'.
    Types of property 'split' are incompatible.
      Type '(test: (op: import("/Users/gilga/Projekte/bliks/app/node_modules/apollo-link-queue/node_modules/@apollo/client/link/core/types").Operation) => boolean, left: import("/Users/gilga/Projekte/bliks/app/node_modules/apollo-link-queue/node_modules/@apollo/client/link/core/ApolloLink").ApolloLink | import("/Users/gilga/Pro...' is not assignable to type '(test: (op: import("/Users/gilga/Projekte/bliks/app/node_modules/@apollo/client/link/core/types").Operation) => boolean, left: import("/Users/gilga/Projekte/bliks/app/node_modules/@apollo/client/link/core/ApolloLink").ApolloLink | import("/Users/gilga/Projekte/bliks/app/node_modules/@apollo/client/link/core/types")....'.
        Types of parameters 'left' and 'left' are incompatible.
          Type 'import("/Users/gilga/Projekte/bliks/app/node_modules/@apollo/client/link/core/ApolloLink").ApolloLink | import("/Users/gilga/Projekte/bliks/app/node_modules/@apollo/client/link/core/types").RequestHandler' is not assignable to type 'import("/Users/gilga/Projekte/bliks/app/node_modules/apollo-link-queue/node_modules/@apollo/client/link/core/ApolloLink").ApolloLink | import("/Users/gilga/Projekte/bliks/app/node_modules/apollo-link-queue/node_modules/@apollo/client/link/core/types").RequestHandler'.
            Type 'ApolloLink' is not assignable to type 'ApolloLink | RequestHandler'.
              Type 'import("/Users/gilga/Projekte/bliks/app/node_modules/@apollo/client/link/core/ApolloLink").ApolloLink' is not assignable to type 'import("/Users/gilga/Projekte/bliks/app/node_modules/apollo-link-queue/node_modules/@apollo/client/link/core/ApolloLink").ApolloLink'.
                Types of property 'split' are incompatible.
                  Type '(test: (op: import("/Users/gilga/Projekte/bliks/app/node_modules/@apollo/client/link/core/types").Operation) => boolean, left: import("/Users/gilga/Projekte/bliks/app/node_modules/@apollo/client/link/core/ApolloLink").ApolloLink | import("/Users/gilga/Projekte/bliks/app/node_modules/@apollo/client/link/core/types")....' is not assignable to type '(test: (op: import("/Users/gilga/Projekte/bliks/app/node_modules/apollo-link-queue/node_modules/@apollo/client/link/core/types").Operation) => boolean, left: import("/Users/gilga/Projekte/bliks/app/node_modules/apollo-link-queue/node_modules/@apollo/client/link/core/ApolloLink").ApolloLink | import("/Users/gilga/Pro...'.
                    Types of parameters 'left' and 'left' are incompatible.
                      Type 'import("/Users/gilga/Projekte/bliks/app/node_modules/apollo-link-queue/node_modules/@apollo/client/link/core/ApolloLink").ApolloLink | import("/Users/gilga/Projekte/bliks/app/node_modules/apollo-link-queue/node_modules/@apollo/client/link/core/types").RequestHandler' is not assignable to type 'import("/Users/gilga/Projekte/bliks/app/node_modules/@apollo/client/link/core/ApolloLink").ApolloLink | import("/Users/gilga/Projekte/bliks/app/node_modules/@apollo/client/link/core/types").RequestHandler'.
                        Type 'ApolloLink' is not assignable to type 'ApolloLink | RequestHandler'.
                          Type 'import("/Users/gilga/Projekte/bliks/app/node_modules/apollo-link-queue/node_modules/@apollo/client/link/core/ApolloLink").ApolloLink' is not assignable to type 'import("/Users/gilga/Projekte/bliks/app/node_modules/@apollo/client/link/core/ApolloLink").ApolloLink'.
                            Property 'onError' is protected but type 'ApolloLink' is not a class derived from 'ApolloLink'.ts(2322)

The packages:

    "@apollo/client": "^3.3.11",
    "apollo-link-queue": "^3.1.0",

When i do a pm list | grep apollo-link i ll get the following:

Bildschirmfoto 2021-11-24 um 14 47 26

Any clue?
Thank you :)

@sajadghawami
Copy link
Author

My mistake!

@zpmyers
Copy link

zpmyers commented Dec 2, 2021

@sajadghawami What was your mistake? I seem to have the same issue.

@sajadghawami
Copy link
Author

@zpmyers

honestly, i am not 100% sure, but i think it was a version mismatch...
try updating them and don't forget to delete the node_modules folder ^^

@zpmyers
Copy link

zpmyers commented Dec 2, 2021

I think it has to do with the recent apollo update, I had mine set to use 3.4.16 and then allowed it to upgrade and it now doesn't have that issue. However, the apollo 3.5.x I ham running into some weird issues where it either queries twice or renders twice when a screen loads.

@zpmyers
Copy link

zpmyers commented Dec 3, 2021

I wonder if this has anything to do with it apollographql/apollo-client#9143

@sajadghawami
Copy link
Author

hmm not sure! are you using optimisticResponse and update in some sort?

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

2 participants