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


TypeScript apollo-link.Observable类代码示例

本文整理汇总了TypeScript中apollo-link.Observable的典型用法代码示例。如果您正苦于以下问题:TypeScript Observable类的具体用法?TypeScript Observable怎么用?TypeScript Observable使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: ApolloLink

 const http = new ApolloLink(operation => {
   if (operation.operationName === 'SampleQuery') {
     return Observable.of({
       data: { user: { __typename: 'User', firstName: 'John' } },
     });
   }
   if (operation.operationName === 'SampleMutation') {
     return Observable.of({
       data: { updateUser: { __typename: 'User', firstName: 'Harry' } },
     });
   }
 });
开发者ID:petermichuncc,项目名称:scanner,代码行数:12,代码来源:advanced.ts

示例2: ApolloLink

 const link = new ApolloLink((operation: Operation): Observable<{}> => {
   if (operation.operationName === 'SampleQuery') {
     return Observable.of({
       data: { user: { __typename: 'User', firstName: 'John' } },
     });
   }
   if (operation.operationName === 'SampleMutation') {
     return Observable.of({
       data: { updateUser: { __typename: 'User', firstName: 'Harry' } },
     });
   }
   return Observable.of({
     errors: [new Error(`Unknown operation ${operation.operationName}`)],
   })
 });
开发者ID:apollostack,项目名称:apollo-client,代码行数:15,代码来源:general.ts

示例3: ApolloLink

 const nextLink = new ApolloLink(operation => {
   const { schemas } = operation.getContext();
   expect(schemas).toMatchSnapshot();
   return Observable.of({
     data: { foo: { bar: true, __typename: 'Bar' } },
   });
 });
开发者ID:petermichuncc,项目名称:scanner,代码行数:7,代码来源:initialization.ts

示例4: ApolloLink

 const link = new ApolloLink(() =>
   Observable.of({
     data: {
       currentAuthor: testAuthor,
       postCount: testPostCount,
     },
   }),
开发者ID:apollostack,项目名称:apollo-client,代码行数:7,代码来源:export.ts

示例5: expect

 const batchHandler = jest.fn(op => {
   try {
     expect(op.length).toBe(2);
   } catch (e) {
     done.fail(e);
   }
   return Observable.of(result);
 });
开发者ID:SET001,项目名称:apollo-link,代码行数:8,代码来源:batchLink.ts

示例6: ApolloLink

 const mockLink = new ApolloLink(operation =>
   Observable.of({
     errors: [
       {
         message: 'resolver blew up',
       },
     ],
   }),
开发者ID:SET001,项目名称:apollo-link,代码行数:8,代码来源:index.ts

示例7: ApolloLink

 const terminating = new ApolloLink(operation => {
   try {
     expect(operation.query).toEqual(query);
   } catch (e) {
     done.fail(e);
   }
   return Observable.of(operation.variables.count);
 });
开发者ID:SET001,项目名称:apollo-link,代码行数:8,代码来源:batchLink.ts

示例8: ApolloLink

 const link = new ApolloLink(() =>
   Observable.of({
     data: {
       launch: {
         id: 1,
         __typename: 'Launch',
       },
     },
   }),
开发者ID:apollostack,项目名称:apollo-client,代码行数:9,代码来源:resolvers.ts


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