Mar*_*cel 5 rxjs apollo graphql angular
我目前正在研究Angular(5)和GraphQL的一些基本内容,我遇到了调用watchQuery方法的一些问题.一旦我调用该方法,我的组件崩溃并返回以下错误:
ERROR TypeError: Object(...) is not a function
我在网上搜索了一个解决方案,但我找不到合适的解决方案.我的环境包含以下库:
我有一个带有一些导入和链接的sharedModule:
export class SharedModule {
constructor(apollo: Apollo, httpLink: HttpLink) {
apollo.create({
link: httpLink.create({uri: 'baseUri/graphql'}),
cache: new InMemoryCache()
});
}
}
Run Code Online (Sandbox Code Playgroud)
我在列表组件中有以下代码:
getMovies() {
this.movies = this.apollo.watchQuery<Query>({ // <= where my error occurs
query: gql`
query {
movies {
id
title
genres
}
}
`
})
.valueChanges
.pipe(map((result) => result.data.movies));
}
Run Code Online (Sandbox Code Playgroud)
完整错误包含以下代码行:
ERROR TypeError: Object(...) is not a function
at new QueryRef (QueryRef.js:6)
at ApolloBase.watchQuery (Apollo.js:30)
at MovieListComponent.getMovies (movie-list.component.ts:37)
at MovieListComponent.ngOnInit (movie-list.component.ts:29)
Run Code Online (Sandbox Code Playgroud)
如果有人有任何建议或问题,请告诉我.
| 归档时间: |
|
| 查看次数: |
1758 次 |
| 最近记录: |