-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
integration with ngrx #593
Comments
@olaf89 in theory it shouldn't be too hard to integrate it with ngrx. The only code that would have to be modified is the place where Apollo client writes to the store with reducers and then the place where it reads from the store. We might abstract it at some point in the future, so people can plug in their own preferred state store with relatively little effort. |
any updates on that topic? |
@helfer i think that this is the correct aproach, wanted to ofer it myself then ive seen this (abstracting store) |
@SebastianSchenk We haven't done any work specifically to make it possible, but i did discuss this with Sashko and we concluded that the easiest way to do this would be to assume that the store is a redux store and then build adapters for other stores. |
any update on this one? |
@helfer ngrx/store is basically a re-implementation of redux using observables. In addition, it plays nicely with angular2's dependency injection. From what I've read so far, it seems to me that ngrx/store is the best way to use Redux in angular2 applications. However, isn't it a common use case to switch the store? I mean, if someone is using react for example, he most likely will use redux already. If this user is not able to pass his own store to apollo, he will end up having two stores, which is not recommended according to Redux documentation. |
IMO we just need to let the user provide the store. |
This is redux only, |
Can the store interface just be the redux interface? That's what we have now. |
This is the ngrx store https://github.com/ngrx/store/blob/master/src/store.ts https://github.com/reactjs/redux/blob/85e2368ea9ff9b308fc873921ddf41929638f130/docs/api/Store.md I think ngrx store interface is missing the getState function |
@helfer I am a core maintainer of @ngrx/store. Let me know what APIs we need to expose to make integration possible. |
I see this one is still not assigned to anyone if you need help let me know too |
@MikeRyan52 I just talked to @stubailo and it seems all we really need is the equivalent of I think the easiest way would be if someone wrote a thin adapter for ngrx/store that just maps the methods we need to the ones that ngrx/store exposes. Any thoughts? |
@helfer We can cast ngrx/store to that interface. We will need to find a suitable location for that code to live. |
I will try to see whether I can build a demo first using existing Angular2-Apollo and ngrx API, like how I wrap Angular2-Meteor API and use with ngrx before. |
Hey, any updates on this one? |
@dogancana I don't know, it hasn't come up since. @hongbo-miao did you talk to Uri and publish your code yet? |
Oh, before I got an |
What steps did you take to accomplish this @hongbo-miao ? |
I put the code here: https://github.com/Hongbo-Miao/apollo-chat The two issues I met before have been fixed in latest Apollo. For Apollo Redux store, is there a need to interact with Apollo Redux store directly? If not, we can just leave it there, and just mirror that part into ngrx(?) UPDATE: add screenshot |
@hongbo-miao I didn't see how you merge two stores in there. And with a lot of hacks I was able to combine them together. Steps are: But I wouldn't use this way. Too much hacks. And in the end, you will have two stores, one of which is not used |
Hi @dogancana I added screenshot. I do "combine" them, but still two stores exist. Do you mean meta reducer? Because middleware is removed since ngrx/store v2 Although right now it works. To use only one store and make it clean, the source codes/API still need to be updated. |
Yea, I think most of us would like to have only one store. |
has anyone been assigned to work on this one? |
@nakedcity nobody is currently working on it, as far as I know. |
@Urigo here you go https://github.com/apollostack/angular2-docs/pull/30 @petercn imho ngrx/store should make itself compatible, i.e. implement the original Redux APIs where needed. That's actually what @MikeRyan52 already tried to do with his snippet. I failed to make it work myself, though I believe that for people with more insight into ngrx/store it's probably not a job that's too hard to finish. Yet after looking more closely at ng2-redux, I wonder what the real differences are in terms of fitting "better" into Angular. Both let you use RxJS for getting data out of the store, "Effects" and "Epics" for handling of side effects as well as router state integration. That's all I really need, the rest is redux code anyway. Or am I missing something big here? It took me less than 2 hours to migrate from ngrx/store to ng2-redux because they're so similar. I'm quite happy with this stack for now, especially since Apollo client is taking care of data normalization for me which is probably the feature I'm most excited about. Otherwise I might have ditched Redux completely and went with MobX which is way less verbose and much easier to grasp if you've not been living in Functional Programming land for the past couple of years. |
I agree with @alexthewilde very similar integration plus people used to redux will not have to learn another API, regarding the plus of ngrx you can see robwormald explanation on ngrx/store#16 |
Guys, now any update? Any estimates or at least when will it be started? We are picking a new stack for rewriting of our product and this would be handy. If nobody considers that a priority, we will have to pick something else... |
@Draccoz we do have a plan to encapsulate the store so anyone could use their own store, can't give you exact date but I believe we want to do that before 1.0. My main question is, while planning your new stack, why is that a blocking issue? |
I think the double store for one app is not a good practice |
Ok, that is always some detail ^^. |
@Draccoz give ng2-redux a try. It's giving you the same APIs as ngrx/store but can be integrated with Apollo, see this example app. |
Might do so, I am currently investigating all the options :). We stayed away from facebook official components, because of the patent clause, but just discovered Redux has no patent on it ^^. |
yep, hope we'll get to it soon. |
I also want to note that we have been discussing making the internal store implementation interchangeable. Mainly our discussions revolve around interchanging a Redux store and a Vanilla-js store, but a ngrx store could be implemented by the community when we settle on an interface we like. Stay tuned, this may not come out for a bit. In the meantime a contributor week contribution could get us where you want. |
is there anything new on this topic? |
@dmatejka This is not going to be part of 1.0, but after that we're going to start working on making the store API external so any store can be plugged in. I expect it to be ready for public testing in about three weeks to one month. |
Hi been looking at using Apollo with ngrx, @MikeRyan52 has any work been done on ngrx to make the two compatible? I am very happy with ngrx so far but would unfortunatly have to change to ng2-redux if it is not compatible with Apollo |
@jusefb It has always been "compatible". This discussion is about having Apollo Client nested in the same store. |
I see, very sorry for asking silly questions. That is great news thank you very much. |
@helfer any updates on this? |
It's still on our radar but will probably take a while. Let's focus all discussion around this in #1432 |
Hi |
Anybody know if there is a way of work with ngrx and any other api client to make request to graph api??? |
@KevinOrtiz you can use the apollo-angular-cache-ngrx cache package to work with ngrx but the results are much slower imo. |
So, you believe is possible work with apollo client and ngrx together without apollo-angular-cache-ngrx ?? @Dunos |
not sure what you mean @KevinOrtiz ... you can just pass your graphQL responses to your stores |
Couldn't make that work. Would you mind showing us how you did it? |
Is this possible now? |
Yes! I managed to do it a year ago. It looks ugly but works. |
@danielchikaka thank you very much for the reply.
I feared as much. For me personally it doesn't make much sense to adopt a whole new eco system without at least second class angular support. |
Hi!
Is it possible to integrate apollo client with ngrx instead of redux?
Thanks in advance!
The text was updated successfully, but these errors were encountered: