本文整理汇总了TypeScript中apollo-link.Observable.of方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Observable.of方法的具体用法?TypeScript Observable.of怎么用?TypeScript Observable.of使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类apollo-link.Observable
的用法示例。
在下文中一共展示了Observable.of方法的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' } },
});
}
});
示例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}`)],
})
});
示例3: ApolloLink
const nextLink = new ApolloLink(operation => {
const { schemas } = operation.getContext();
expect(schemas).toMatchSnapshot();
return Observable.of({
data: { foo: { bar: true, __typename: 'Bar' } },
});
});
示例4: ApolloLink
const link = new ApolloLink(() =>
Observable.of({
data: {
currentAuthor: testAuthor,
postCount: testPostCount,
},
}),
示例5: expect
const batchHandler = jest.fn(op => {
try {
expect(op.length).toBe(2);
} catch (e) {
done.fail(e);
}
return Observable.of(result);
});
示例6: ApolloLink
const mockLink = new ApolloLink(operation =>
Observable.of({
errors: [
{
message: 'resolver blew up',
},
],
}),
示例7: ApolloLink
const terminating = new ApolloLink(operation => {
try {
expect(operation.query).toEqual(query);
} catch (e) {
done.fail(e);
}
return Observable.of(operation.variables.count);
});
示例8: ApolloLink
const link = new ApolloLink(() =>
Observable.of({
data: {
launch: {
id: 1,
__typename: 'Launch',
},
},
}),