UNPKG

719 BJavaScriptView Raw
1import { transport } from './utils/transport.js';
2
3/**
4 * [reachWithDispatch description]
5 * @param {[String]} path [path to the GraphQL server]
6 * @param {[Object]} query [The query that GraphQL will use to fetch your data]
7 * @param {[object]} queryParams = {} [should contain object with different query params]
8 * @param {[type]} actionCreator = ( [The actionCreator to dispatch]
9 * @return {[function]} [dispatch to store]
10 */
11export function reachWithDispatch (path, query, queryParams = {}, token, actionCreator) {
12 return transport(path, query, queryParams, token)
13 .then((res) => {
14 return dispatch => {
15 return dispatch(actionCreator(res));
16 }
17 });
18}