本文整理汇总了TypeScript中apollo-angular.Apollo.query方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Apollo.query方法的具体用法?TypeScript Apollo.query怎么用?TypeScript Apollo.query使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类apollo-angular.Apollo
的用法示例。
在下文中一共展示了Apollo.query方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: getPage
getPage(paging) {
return this.apollo.query({
query: getPage,
variables: { offset: paging.offset, first: paging.first },
fetchPolicy: 'no-cache'
});
}
示例2: ngOnInit
ngOnInit() {
this.author$ = this.apollo
.query<any>({
query: authorQuery,
variables: {
id: 2,
},
fetchPolicy: 'network-only',
})
.pipe(map(result => result.data.author));
}
示例3: constructor
constructor(apollo: Apollo) {
this.say$ = apollo
.query<any>({
query: gql`
{
hello
}
`,
}).pipe(
map(result => result.data.hello)
)
}
示例4: filter
filter(pattern: string) {
return this.apollo.query({
query: gql`
query {
allTags {
nodes {
id
name
}
}
}`,
fetchPolicy: 'no-cache'
});
}
示例5: getComments
getComments(postId: number, parentId: Number, offset: number, first: number, offsetReplies: number, firstReplies: number) {
return this.apollo.query({
query: gql`
query ($postId: Int, $parentId: Int, $offset: Int, $first: Int, $offsetReplies: Int, $firstReplies: Int) {
allPostComments(offset: $offset, first: $first, condition: {postId: $postId, parentId: $parentId}, orderBy: CREATED_AT_DESC) {
totalCount
pageInfo {
hasNextPage
}
nodes {
id
content
parentId
postCommentsByParentId(offset: $offsetReplies, first: $firstReplies, orderBy: CREATED_AT_DESC) {
totalCount
pageInfo {
hasNextPage
}
nodes {
id
content
parentId
postCommentsByParentId {
totalCount
pageInfo {
hasNextPage
}
}
}
}
}
}
}
`,
variables: {
postId: postId,
parentId: parentId,
offset: offset,
first: first,
offsetReplies: offsetReplies,
firstReplies: firstReplies
}
});
}
示例6: get
get(query: string, options?: QueryOptions<any>): Observable<any> {
// return this.http.get<any>(`/api/graph/?query=${CommonService.compressString(query)}`, options);
return this.apollo.query<any>(Object.assign({ query: gql`${query}` }, options));
// return this.apollo.watchQuery<any>(Object.assign({ query: gql`${query}` }, options)).valueChanges;
}
示例7: get
get(id: number) {
return this.apollo.query({
query: getById,
variables: { id: id }
});
}
示例8: getUserProfile
getUserProfile() {
return this.apollo.query({
query: getUserProfile
});
}