Hi, I had just finished my first react redux application that get/post to a java ee api rest server with a mysql database.
Now I am trying apollo and I want to migrate my app to use apollo (server and client).
Currently I succesfully build my apollo server with a sequelize and mysql (to replace completelly the java ee tier by apollo server), and I am able to perform queries to apollo server using the graphiql console.
Now I want to refactor my redux react applications. Iv been reading the documentation of apollo client but it is not clear for me how to refactor my current actions creators, like for example:
action:
export function fetchPersons() {
return dispatch => {
dispatch(beginAjaxCall());
return restApi.fetchData("persons")
.then(response => response.json())
.then(persons => dispatch(fetchPersonsSuccess(persons)));
};
}
and a reducer:
export default function persons(state = initialState.persons, action) {
switch (action.type) {
case types.FETCH_PERSONS_SUCCESS:
return action.persons;
default:
return state;
}
}
How do I implement the same using apollo client queries? Can I keep using my actions creators and replace the api call for for example a call to a apollo query/mutation or must I use only the mapQueriesToProps and fire the query/mutation from my container component?