當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript Apollo.create方法代碼示例

本文整理匯總了TypeScript中apollo-angular.Apollo.create方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Apollo.create方法的具體用法?TypeScript Apollo.create怎麽用?TypeScript Apollo.create使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在apollo-angular.Apollo的用法示例。


在下文中一共展示了Apollo.create方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: constructor

 constructor(
   private apollo: Apollo,
   private tokenService: TokenService,
   private modalService: ModalService
 ) {
   const uploadLink = createUploadLink({ uri: uri });
   const authLink = createAuthLink(tokenService);
   const errorLink = createErrorLink(modalService);
   apollo.create({
     link: ApolloLink.from([authLink, errorLink, uploadLink]),
     cache: new InMemoryCache(),
     queryDeduplication: true,
     defaultOptions: {
       mutate: {
         errorPolicy: 'all'
       },
       query: {
         errorPolicy: 'all'
       },
       watchQuery: {
         errorPolicy: 'all'
       }
     }
   });
 }
開發者ID:ngocdiep,項目名稱:nd,代碼行數:25,代碼來源:graphql.module.ts

示例2: constructor

 constructor(apollo: Apollo, httpLink: HttpLink) {
   apollo.create({
     // By default, this client will send queries to the
     // `/graphql` endpoint on the same host
     link: httpLink.create({ uri: Meteor.absoluteUrl('/graphql') }),
     cache: new InMemoryCache(),
   });
 }
開發者ID:Urigo,項目名稱:angular-meteor,代碼行數:8,代碼來源:app.module.ts

示例3: constructor

 constructor(
   apollo: Apollo,
   httpLink: HttpLink
 ) {
   // create Apollo
   apollo.create({
     link: httpLink.create({ uri }),
     cache: new InMemoryCache()
   });
 }
開發者ID:ramanujprasad,項目名稱:ApolloAngularApp2,代碼行數:10,代碼來源:graphql.module.ts

示例4: constructor

 constructor(apollo: Apollo, httpLink: HttpLink) {
   apollo.create({
     link: middlewareLink.concat(
       httpLink.create({
         uri: 'https://1jzxrj179.lp.gql.zone/graphql',
       }),
     ),
     cache: new InMemoryCache(),
   });
 }
開發者ID:kamilkisiela,項目名稱:apollo-angular-lazy-modules,代碼行數:10,代碼來源:app.module.ts

示例5: constructor

  constructor(apollo: Apollo, httpLink: HttpLink) {

    const uri = 'https://api.graph.cool/simple/v1/cjc9v2j990b9p01991mc14n8e';
    const http = httpLink.create({ uri });

    apollo.create({
      link: http,
      cache: new InMemoryCache()
    });
  }
開發者ID:spencermefford,項目名稱:hackernews-angular-apollo,代碼行數:10,代碼來源:apollo.config.ts

示例6: constructor

 constructor(apollo: Apollo, httpLink: HttpLink, ngrxCache: NgrxCache) {
   apollo.create({
     // By default, this client will send queries to the
     // `/graphql` endpoint on the same host
     link: httpLink.create({
       uri: "/api"
     }),
     cache: ngrxCache.create({})
   });
 }
開發者ID:isaacmg410,項目名稱:decidim-monitor,代碼行數:10,代碼來源:app.module.ts

示例7: constructor

  constructor(
    apollo: Apollo,
    httpLink: HttpLink
  ) {
    const link = requestLink(
      httpLink.create({
        uri: environment.graphql.http,
        withCredentials: true
      })
    );

    apollo.create({
      link,
      cache: new InMemoryCache
    });
  }
開發者ID:apollostack,項目名稱:GitHunt-angular2,代碼行數:16,代碼來源:graphql.module.ts

示例8: constructor

  constructor(
    apollo: Apollo,
    httpLink: HttpLink
  ) {
    const link = requestLink(
      httpLink.create({
        uri: `http://${environment.url}/graphql`,
        withCredentials: true,
      })
    );

    apollo.create({
      link,
      cache: new InMemoryCache,
    });
  }
開發者ID:Timmahh,項目名稱:questionable-bets,代碼行數:16,代碼來源:graphql.module.ts

示例9: constructor

  constructor(apollo: Apollo, httpLink: HttpLink) {
    const http = httpLink.create({ uri: `${environment.apiAddress}/graphql` });

    const middleware = setContext(() => ({
      headers: new HttpHeaders().set(
        'Sandwich-Auth-Token',
        localStorage.getItem('token') || ''
      )
    }));

    const error = onError(({ networkError, graphQLErrors }) => {
      console.error(networkError);

      window.location.pathname = '/login';
    });

    const link = middleware.concat(error).concat(http);

    apollo.create({
      link,
      cache: new InMemoryCache({
        dataIdFromObject: (o: any) => {
          let key;
          switch (o.__typename) {
            case 'user':
              key = `${o.__typename}-${o.userId},`;
              break;
            case 'week':
              key = `${o.__typename}-${o.weekId},`;
              break;
            case 'weekUserLink':
              key = `${o.__typename}-${o.weekId}-${o.userId},`;
              break;
            default:
              key = `${o.__typename}-${o.id},`;
              break;
          }

          return key;
        }
      })
    });
  }
開發者ID:FraserKillip,項目名稱:SC2_WEB,代碼行數:43,代碼來源:app.module.ts

示例10: constructor

 constructor(apollo : Apollo, httpLink : HttpLink) {
   apollo.create({
     link: httpLink.create({ uri: 'http://localhost:4000/graphql'}),
     cache: new InMemoryCache()
   })
 }
開發者ID:corganfuzz,項目名稱:appgraphi,代碼行數:6,代碼來源:app.module.ts


注:本文中的apollo-angular.Apollo.create方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。