question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Using redux-observable

See original GitHub issue

I read almost entirely the apollo client docs and I couldn’t find anything on using redux-observable with it.

I know the usual way to make queries with apollo is with the connect() method connecting the query and the class but with redux-observable, you need to be able to call the query/mutation directly in the epic which is in a different js file.

Basically we would have to call the query in the epic and if it’s successful, update redux store and return the query information received to the component. Else we would return nothing. I see no way of doing this in my current implementation because only the component knows the query.


Do you guys have already thought about a way you could integrate redux-observable with apollo or is it on hold for now?

Thank you

(First time posting an ‘issue’)

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

6reactions
vpageaucommented, Feb 25, 2018

@loganpowell It’s not a problem. Yes this approach has worked out fine so far. I recommend it to anyone using both apollo-client and redux-observable together.

3reactions
ghostcommented, Jul 4, 2017

Ok I successfully changed the actionCreator logic to mutate using the client directly.

import { client } from '../../services/network'          //new client instance
import { languageMutation} from '../mutation'     //mutation to do (using gql)
import { changeLanguageFulfilled, changeLanguageError} from '../actions/navigationBarActions';    //import actions to use in the epic

export const languageEpic = (action$) => {
  return action$.ofType('CHANGE_LANGUAGE')
    .mergeMap(action => client.mutate({
      mutation: languageMutation,
      variables: { id: action.id,  defaultLanguage: action.selected_language, defaultTimeZoneId: action.selected_timeZone }
    }).then(result => changeLanguageFulfilled(result))
      .catch(error => changeLanguageError(error))
  );
};

I use return here to call my reducer and then update my redux store.

Thank you for your help 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Introduction · redux-observable
RxJS-based middleware for Redux. Compose and cancel async actions to create side effects and more. https://redux-observable.js.org. Note: this project is quite ...
Read more >
Reactive Apps with Redux, RxJS, and Redux-Observable
redux -observable is a library for handling asynchronous tasks in Redux. It works by capturing a dispatched action from Redux and does some...
Read more >
A beginner's guide to redux-observable - LogRocket Blog
Redux -Observable is a Redux middleware that allows you to filter and map actions using RxJS operators. RxJS operators like filter() and ...
Read more >
Should I use redux-observable? Also what is it? Also let's be ...
redux -observable is a powerful framework. It effectively decouples the ui of a project from it's behaviors, and guides it toward a more ......
Read more >
Redux-Observable will solve your state problems. - ITNEXT
Redux-Observable is an amazingly powerful middleware for Redux using RxJS. Using Redux-Observable requires knowing or learning RxJS which is itself a major ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found