TypeScript @-graphql.clientAccess类(方法)实例源码

下面列出了TypeScript @-graphql.clientAccess 类(方法)源码代码实例,从而了解它的用法。

作者:Zulus    项目:Budgetariu   
return (dispatch: Redux.Dispatch<any, IState>, getState: () => IState) => {
            dispatch(startLoading("wallets"));
            const query = WALLETS_GET_QUERY;
            const variables = queryData;
            clientAccess.query({query, variables})
                .then(response => {
                    const answer = response.data as any;
                    clientAccess.cache.reset();
                    if (!answer || !answer.wallets) {
                        throw Error("Server returns empty response");
                    } else {
                        dispatch(endLoading("wallets"));
                        dispatch(walletsLoadSuccess(answer.wallets as any));
                    }
                })
                .catch((err: any) => {

                        if (err.graphQLErrors && err.graphQLErrors.length) {
                            err.graphQLErrors.forEach((e: any) => dispatch(this.fetchFailed.execute(e.message)));
                        } else {
                            dispatch(this.fetchFailed.execute(err.message));
                        }
                    }
                );
        };

作者:Zulus    项目:Budgetariu   
return (dispatch: Redux.Dispatch<any, IState>, getState: () => IState) => {
     dispatch(startLoading("transactions"));
     const mutation = TRANSACTION_DELETE_MUTATION;
     const variables = {id};
     clientAccess.mutate({mutation, variables})
         .then(response => {
             const answer = (response.data as any);
             clientAccess.cache.reset();
             if (!answer) {
                 throw Error("Server returns empty response");
             } else {
                 dispatch(endLoading("transactions"));
                 dispatch(removeTransactionFromSelectedWallet(id));
                 dispatch(transactionDeleteSuccess(id));
             }
         })
         .catch((err: any) => {
                 if (err.graphQLErrors && err.graphQLErrors.length) {
                     err.graphQLErrors.forEach((e: any) => dispatch(this.fetchFailed.execute(e.message, "transactions")));
                 } else {
                     dispatch(this.fetchFailed.execute(err.message, "transactions"));
                 }
             }
         );
 };


问题


面经


文章

微信
公众号

扫码关注公众号