Here's how you can batch graphql-requests
' using the batchRequests
function in redux-saga
.
export default ({ gqlClient } = {}) => {
function* getDashboardData() {
while (true) {
try {
yield take(dashboardActions.getDashboardDataPending.type);
yield call([gqlClient, gqlClient.batchRequests],
[{ document: queries.home.getUserData, variables: { period: 'day', date: 'last30' } },
{ document: queries.home.getRevenueData, variables: { period: 'day', date: 'last60' } }]
);
...
}
}
}
}