當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。