我想用redux observable管理我的提取,但我找不到任何例子。有人对此有答案吗?
通过apollo vanillaJS,这是获取查询结果的方法:
../../../../../../../etc/passwd
现在我需要在redux observable中插入它来管理答案:
const opts = {uri: 'http://localhost:8080/graphql'};
const networkInterface = createNetworkInterface(opts);
const client = new ApolloClient({
networkInterface});
let query = gql`query {
viewer {
id
firstName
lastName
defaultTimeZoneId
defaultLanguage
}
}`;
client.query({query}).then((results) => {})
//return a promise
由于
答案 0 :(得分:1)
您可以像这样使用运算符fromPromise
:
const fetchQuestionsEpic = action$ =>
action$.ofType(FETCH_QUESTIONS)
.mergeMap(() =>
Observable.fromPromise(fetchQuestions())
.map(questions => ({ type: QUESTIONS_FETCHED, questions })),
);
此回购符合一些良好做法github.com/voteetvous