在版本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,
});
导致以下打字稿错误:
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
可以解决该问题。
感谢@lextas — 测试版仅适用于 Apollo-client 3.0(以及兼容版本的相关 Apollo 包)。
不幸的是,由于世界事件,Apollo 客户端 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"
最有用的评论
好吧,我不知道。 我只是按照文档。 我将关闭问题。 对于遇到相同问题的其他人,最好将其记录下来。 它可能发生在更多人身上,因为很多人只是
npm install
(或yarn
)最新版本,它不会工作。