本文整理匯總了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
});
}