5 ms·
It's nice to see some love for Apollo here. It's leagues better than Relay and has definitely been the biggest boon to my development stack in a while. That bei
by morgante 10y ago
It's nice to see some love for Apollo here. It's leagues better than Relay and has definitely been the biggest boon to my development stack in a while. That being said, the article should make it clearer that Apollo is perfectly usable just as a frontend client—you don't have to adopt the backend at all.
The Meteor team really deserves commendations for learning from some of the mistakes in building Meteor. Apollo specifically emphasizes incremental adoptability: you can drop it into an existing project and see benefits almost immediately, without having to refactor/rewrite any of your existing code.
I'd also like to provide a counterpoint to the inevitable complaints about the complexity and low-productivity of a JavaScript. In my experience, once you've paid the initial cost of learning these tools you can become extremely productive. As a freelance developer who is paid a flat rate for projects, I'm directly incentivized to find an efficient stack and the modern JavaScript stack is definitely it.
Specifically, my stack these days is Django + Graphene + React + Redux + Apollo. It's insanely high productivity: I can usually have the basics of an app built within a few hours of starting.
- k__ 10y agoI always thought relay was an alternative to redux
- morgante 10y agoNot really. Relay is mostly designed around querying a backend data store, not updating/managing client-side state.
- jameslk 10y agoRelay v2 will bring with it a way to manage client side state.
- morgante 10y agoInteresting. I didn't know that. If anything, that actually somewhat affirms my preference for Apollo. Since Apollo is built on top of Redux, you can use both in tandem without any problem instead of having to learn a whole new tool and refactor your application to use it.
- tiglionabbit 10y agoRelay already is a replacement for Redux. It wraps React components and it has a store. How could you even use Relay and Redux together?
- morgante 10y ago> Relay already is a replacement for Redux. It wraps React components and it has a store That's hardly the definition of a replacement for Redux. Relay v1 has absolutely no client-side state management support. I'm sorry but it's incredibly disingenuous to say they're substitutes at this point. Apparently v2 will have some client-side support. To be clear, I don't want to bash Relay. I really like GraphQL and have Relay to thank for helping me to get stated on it. I've just found it to have a lot of challenging complexity which is really hard to manage, especially compared to Apollo. Also, "replacing Redux" is really not a selling point. The Redux ecosystem is strong enough at this point that being able to work with it is a huge advantage. > How could you even use Relay and Redux together? Pretty easily. The nice thing about the React ecosystem is that things rarely conflict with each other. In my case, API data is updated/fetched via Relay while purely client-side info uses Redux.
- tiglionabbit 10y agoI suppose you have a class of data that is not trivial enough to store in a single component's state, but also not worth sending to the server. Personally, I'm happy to be rid of having to maintain this kind of state if I can.
- morgante 10y ago> I suppose you have a class of data that is not trivial enough to store in a single component's state, but also not worth sending to the server. Exactly. For example, one application I'm working on has a complicated multi-page form/wizard. Redux is great for keeping this manageable and in fact takes care of all the management for this without me also having to write code for managing it on the backend at all.
- rojobuffalo 10y agoRespectfully disagree--I like Relay better. And Relay 2 is including client-side state, so you don't need Redux. It has a steep learning curve and some initial setup overhead; but from a long-range perspective--I think it will have better performance and code comprehensibility. Maybe Apollo is better suited for freelancers though.
- tiglionabbit 10y agoI thought Relay already had client side state? Also what's Relay 2? Where are you finding information about it? My opinion of Relay right now is that it has way too many needless complications. It looks like it brought a ton of baggage from being used in Facebook that just gets in the way of general use. So I'm interested in an alternative. However, the real problem with all of this stuff is cache management. Properly managing the cache in the face of mutations is very complicated and it's impossible to be perfect anyway without some sort of pubsub.
- rojobuffalo 10y agoBy client-side state, I mean user interactions that affect variables used across the app that don't need to be persisted. Relay doesn't do that yet, as it only deals with persisted data. @josephsavona[1] and @wincent[2] are the guys putting information out about Relay 2. Greg Hurrell (@wincent) did a talk[3] about it in August. And since I'm linking to related resources, I just want to add a plug for an awesome project a friend is working on (and we're putting it into production on my startup project). @calebmer/postgraphql[4] let's you get a free GraphQL API from a PostgreSQL schema. [1]: https://github.com/josephsavona https://github.com/josephsavona [2]: https://github.com/wincent https://github.com/wincent [3]: https://www.youtube.com/watch?v=OEfUBN9dAI8 https://www.youtube.com/watch?v=OEfUBN9dAI8 [4]: https://github.com/calebmer/postgraphql https://github.com/calebmer/postgraphql
- morgante 10y ago@calebmer/postgraphql is an awesome project and really worth looking into! I actually built a system on top of it which automatically generated GraphQL change subscriptions through Postgres triggers.
- shabda 10y agoWhat part does Graphene play (assuming you mean https://github.com/graphql-python/graphene https://github.com/graphql-python/graphene). Are you building graphql based apis rather than rest ones?
- morgante 10y ago> Are you building graphql based apis rather than rest ones? Yes. The Django models are exposed through a GraphQL API (using Graphene), which I query using Apollo.
- bberrry 10y agoYou wouldn't happen to have a seed project with that stack by any chance? I would be very interested in trying it out.
- morgante 10y agoI haven't updated this to use GraphQL yet, but this is my standard project starter template: https://github.com/gigster-eng/python-starter https://github.com/gigster-eng/python-starter
- djmashko2 10y ago(Disclaimer: I work on Apollo) Yes, it was a bit surprising to see "Apollo" separate from "GraphQL" here, since our primary focus is to enable people to take advantage of GraphQL no matter their frontend and backend architecture. It makes the most sense to make a direct comparison between "Apollo" and "Relay", but they should both be considered a subset of "GraphQL", which is really the core technology that everyone is building on. However, excited that people like it, and we're excited to collaborate with everyone to make it the best way to use GraphQL in an application!
- k__ 10y agoDo you guys know something loke Apollo but on top of RxJS? I'm not a big fan of Redux anymore since I discovered observable streams.
- djmashko2 10y agoApollo returns the data in observable form. You never have to deal with Redux directly if you don't want to. Check out the Angular docs for more details.
- k__ 10y agoIt's also written in TypeScript, nice! A few days ago I was thinking about using GraphQL in future projects and didn't even find out about Apollo. So it combines data retrieval via GraphQL with client side state management via Redux?
- bdr 10y agoI'm curious: how do you think about client vs server side rendering? What happens where?
- morgante 10y agoFor apps which need it, everything generally happens in both places. The server-side render fetches all the appropriate data and displays a fully rendered version of the page. That being said, I think you should carefully consider whether server-side rendering is necessary for your application before adding it. It does complicate your stack and is not worth it unless either first-load performance or SEO are important to you.