Apollo-link-rest: タイプ「RestLink」には、タイプ「ApolloLink」から次のプロパティがありません:split、concat

作成日 2020年06月14日  ·  4コメント  ·  ソース: apollographql/apollo-link-rest


バージョン0.8.0-beta.0では、 RestLink実装が壊れています。 私はこのチュートリアルに従い

// 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,
}); 

次のTypeScriptエラーが発生します。

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

詳細:

{
    "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"
        }
    ]
}

この動作は、 apollo-link-rest依存関係を0.8.0-beta.0アップグレードすることにより、コードサンドボックスの例で再現できます。

v0.7.3戻すと、問題が解決します。

最も参考になるコメント

桶、知らなかった。 ドキュメントをフォローしました。 問題を解決します。 同じ問題に遭遇した他の人のためにこれを文書化しておくのは良いことです。 多くの人が最新バージョンをnpm install (またはyarn )しているだけで、機能しないため、おそらくより多くの人に起こります。

全てのコメント4件

ありがとう@ lextas—ベータ版はApollo-client 3.0(および互換性のあるバージョンの関連するApolloパッケージ)での使用のみを目的としています。

残念ながら、世界的な出来事のために、Apollo-client 3.0は遅れており、彼らがいつ出荷する予定かは現在わかりません。

桶、知らなかった。 ドキュメントをフォローしました。 問題を解決します。 同じ問題に遭遇した他の人のためにこれを文書化しておくのは良いことです。 多くの人が最新バージョンをnpm install (またはyarn )しているだけで、機能しないため、おそらくより多くの人に起こります。

うーん、それで私はどのバージョンを使うべきですか? このためのセットアップガイドに従ったところ、この問題が発生しています。

    "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--他のパッケージのこれらのバージョンでは、 "apollo-link-rest": "^0.7.0"

このページは役に立ちましたか?
0 / 5 - 0 評価