Apollo-link-rest: Type 'RestLink' is missing the following properties from type 'ApolloLink': split, concat

Created on 14 Jun 2020  ·  4Comments  ·  Source: apollographql/apollo-link-rest


On version 0.8.0-beta.0 the RestLink implementation is broken. I followed this tutorial but the first code block already breaks:

// Create a RestLink for the Github API
const link = new RestLink({ uri: 'https://api.github.com' });

// Configure the ApolloClient with the recommended cache and our RestLink
const client = new ApolloClient({
  cache: new InMemoryCache(),
  link,
}); 

results in the following TypeScript error:

Type 'RestLink' is missing the following properties from type 'ApolloLink': split, concat

details:

{
    "resource": "/*redacted*/src/file.ts",
    "owner": "typescript",
    "code": "2739",
    "severity": 8,
    "message": "Type 'RestLink' is missing the following properties from type 'ApolloLink': split, concat",
    "source": "ts",
    "startLineNumber": 11,
    "startColumn": 3,
    "endLineNumber": 11,
    "endColumn": 7,
    "relatedInformation": [
        {
            "startLineNumber": 17,
            "startColumn": 5,
            "endLineNumber": 17,
            "endColumn": 9,
            "message": "The expected type comes from property 'link' which is declared here on type 'ApolloClientOptions<NormalizedCacheObject>'",
            "resource": "/*redacted*/node_modules/apollo-client/ApolloClient.d.ts"
        }
    ]
}

This behaviour is reproducable on the codesandbox example by upgrading the apollo-link-rest dependency to 0.8.0-beta.0.

Reverting back to v0.7.3 resolves the issue.

Most helpful comment

Oke, I didn't know that. I just followed the docs. I will close the issue. It's good to have this documented for others who run in to the same problem. It probably happens to more people since lots of people just npm install (or yarn) the latest version and it won't work.

All 4 comments

Thanks @lextas — the beta is only intended for use with Apollo-client 3.0 (and related Apollo packages at compatible versions).

Unfortunately due to world events, Apollo-client 3.0 has been delayed, and I’m not currently aware when they plan to ship.

Oke, I didn't know that. I just followed the docs. I will close the issue. It's good to have this documented for others who run in to the same problem. It probably happens to more people since lots of people just npm install (or yarn) the latest version and it won't work.

Hmm, so what versions should I be using? I just followed the set-up guide for this and am running in to this issue.

    "apollo-cache-inmemory": "^1.6.6",
    "apollo-client": "^2.6.10",
    "apollo-link": "^1.2.14",
    "apollo-link-rest": "^0.8.0-beta.0",

@Andrew1431 -- with those versions of the other packages, you want "apollo-link-rest": "^0.7.0"

Was this page helpful?
0 / 5 - 0 ratings