【发布时间】:2021-07-17 05:46:45
【问题描述】:
我的代码如下
hotels: Observable<Hotel[]>;
a = {
Query: gql`
query getHotels {
getHotels {
id
hotel_name
street
city
postalcode
price
email
}
}
`,
};
constructor(private apollo: Apollo) {}
ngOnInit() {
this.hotels = this.apollo
.watchQuery<Query>(this.a)
我得到的错误是
Type '{ 查询:DocumentNode; }' 与类型 'WatchQueryOptions'.ts(2559) 没有共同的属性
可能的原因和可能的解决方案是什么? 任何线索将不胜感激。
我的 types.ts 是
import { type } from "os";
export type Hotel = {
id: string;
hotel_name: string;
street: string;
city: string;
postalcode: string;
price: string;
email: string;
};
export type Query = {
allHotels: Hotel[];
};
【问题讨论】: