1 | import { 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 | */
|
11 | export async function reachWithDispatch (path, query, queryParams = {}, actionCreator) {
|
12 | try{
|
13 | let response = await transport(path, query, queryParams);
|
14 | return dispatch => {
|
15 | return dispatch(actionCreator(response));
|
16 | }
|
17 | } catch (error) {
|
18 | console.log(error);
|
19 | }
|
20 | }
|