react-reach
Version:
A small library for react to communicate with GraphQL
19 lines (17 loc) • 719 B
JavaScript
import { transport } from './utils/transport.js';
/**
* [reachWithDispatch description]
* @param {[String]} path [path to the GraphQL server]
* @param {[Object]} query [The query that GraphQL will use to fetch your data]
* @param {[object]} queryParams = {} [should contain object with different query params]
* @param {[type]} actionCreator = ( [The actionCreator to dispatch]
* @return {[function]} [dispatch to store]
*/
export function reachWithDispatch (path, query, queryParams = {}, token, actionCreator) {
return transport(path, query, queryParams, token)
.then((res) => {
return dispatch => {
return dispatch(actionCreator(res));
}
});
}