当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript Apollo.watchQuery方法代码示例

本文整理汇总了TypeScript中apollo-angular.Apollo.watchQuery方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Apollo.watchQuery方法的具体用法?TypeScript Apollo.watchQuery怎么用?TypeScript Apollo.watchQuery使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在apollo-angular.Apollo的用法示例。


在下文中一共展示了Apollo.watchQuery方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: ngOnInit

 ngOnInit() {
   this.apollo.watchQuery<QueryResponse>({
     query: CurrentProfile
   }).subscribe(({data}) => {
     this.currentProfile = data.profile;
   });
 }
开发者ID:dgayathiri,项目名称:mean,代码行数:7,代码来源:profile.component.ts

示例2: get

 get(): ApolloQueryObservable<PostsInterface> {
     // Query posts data with observable variables
     this.posts = this.apollo.watchQuery<PostsInterface>({
         query: GetPostsQuery,
     })
         // Return only posts, not the whole ApolloQueryResult
         .map(result => result.data.posts) as any;
     return this.posts;
 }
开发者ID:dgayathiri,项目名称:mean,代码行数:9,代码来源:posts.service.ts

示例3: findAll

 findAll(): Observable<Project[]> {
   if (!this.publisher) {
     this.publisher = this.apollo
       .watchQuery({
         query: allProjectsQuery,
       })
       .valueChanges.pipe(map((result: ApolloQueryResult<ProjectsResponse>) => result.data.allProjects));
   }
   return this.publisher;
 }
开发者ID:fischermatte,项目名称:geolud,代码行数:10,代码来源:project.service.ts

示例4: getMyChannels

  getMyChannels() {
    const user: any = this.authenticationService.getUser() || {};
    const variables: MyChannelsQuery.Variables = {
      userId: user.id
    };

    return this.apollo.watchQuery<MyChannelsQuery.Result>({
      query: myChannelsQuery,
      variables,
      fetchPolicy: 'cache-and-network',
    });
  }
开发者ID:RocketChat,项目名称:Rocket.Chat.PWA,代码行数:12,代码来源:channels.service.ts

示例5: ngOnInit

 ngOnInit() {
   this.installations$ = this.apollo
     .watchQuery<AppHomeQuery>({ query })
     .valueChanges.pipe(
       map(({ data }) =>
         data.installations
           .map(installation => ({
             ...installation,
             currentVersion: data.decidim.version
           }))
           .sort((a, b) => (a.name < b.name ? -1 : 1))
       )
     );
 }
开发者ID:isaacmg410,项目名称:decidim-monitor,代码行数:14,代码来源:app-home.component.ts

示例6: switchMap

 switchMap(({ version, tags }) =>
   this.apollo
     .watchQuery<AppSearchQuery>({
       query,
       variables: { version, tags: tags ? tags.split(",") : null }
     })
     .valueChanges.pipe(
       map(({ data }) =>
         data.installations
           .map(installation => ({
             ...installation,
             currentVersion: data.decidim.version
           }))
           .sort((a, b) => (a.name < b.name ? -1 : 1))
       )
     )
开发者ID:isaacmg410,项目名称:decidim-monitor,代码行数:16,代码来源:app-search.component.ts

示例7: ngOnInit

 ngOnInit() {
   this.posts = this.apollo.watchQuery<Query>({
     query: gql`
       query allPosts {
         posts {
           id
           title
           votes
           author {
             id
             firstName
             lastName
           }
         }
       }
     `,
   })
     .valueChanges
     .pipe(
       map(result => result.data.posts)
     );
 }
开发者ID:ramanujprasad,项目名称:ApolloAngularApp2,代码行数:22,代码来源:list.component.ts

示例8: getAllCourses

 getAllCourses(searchTerm: string) {
   return this.apollo.watchQuery <Query> ({
       pollInterval: 500,
       query: gql `
         query allCourses($searchTerm: String) {
           allCourses(searchTerm: $searchTerm) {
             id
             title
             author
             description
             topic
             url
             voteCount
           }
         }
     `,
       variables: {
         searchTerm: searchTerm
       }
     })
     .valueChanges
     .pipe(map(result => result.data.allCourses));
 }
开发者ID:corganfuzz,项目名称:appgraphi,代码行数:23,代码来源:course.service.ts

示例9: queryAll

 public queryAll(): Observable<ApolloQueryResult<any>> {
   return this.apollo.watchQuery({ query: UPLOADS }).valueChanges;
 }
开发者ID:ngocdiep,项目名称:nd,代码行数:3,代码来源:file-upload.service.ts


注:本文中的apollo-angular.Apollo.watchQuery方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。