How to make Redux Thunk and Apollo GraphQL work together

In my projects, Redux Thunk is used to store all asynchronous functions in action creators.

Now I'm trying to add Apollo GraphQL to my project, everything works fine, except that when adding mutations to my functional Component and calling them there, it breaks the redux thunk architecture.

How to solve it? I believe that I can create new methods for creating actions and pass mutations to them, but soon it will become a template, and it just doesn’t work for me.

+4
source share
1 answer

Apollo . , then catch . Apollo graphql async redux (thunks, sagas, epics), .

Apollo Client 1.0

, , Apollo (APOLLO_MUTATION_INIT, APOLLO_MUTATION_RESULT ..). , apollo, . . http://dev.apollodata.com/react/redux.html.

: Apollo Client 2.0

Apollo Client 2.0 (). 1.0 , https://www.npmjs.com/package/apollo-link-redux ( readme).

+2

Source: https://habr.com/ru/post/1673262/


All Articles