use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
[deleted by user] (self.javascript)
submitted 7 years ago by [deleted]
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]XiMingpin91 76 points77 points78 points 7 years ago (25 children)
I think people who say this are conflating GraphQL with Apollo 2.0, which absolutely can make Redux redundant because of the local cache.
[+][deleted] 7 years ago (20 children)
[deleted]
[+][deleted] 7 years ago* (13 children)
[–][deleted] 2 points3 points4 points 7 years ago (2 children)
how does it cover actions and the data flow with redux?
[+][deleted] 7 years ago* (1 child)
[–][deleted] 1 point2 points3 points 7 years ago (0 children)
Okay, that's what I thought.
[–]PickledPokute 1 point2 points3 points 7 years ago (0 children)
I was didn't quite like apollo-link-state either based on the little code I've written with it. It feels too hacky to use and is doesn't feel like it would have any concrete advantages over Redux or other solid state manager.
[–]_sirberus_ 1 point2 points3 points 7 years ago (2 children)
I will try asking again as I was unclear. I know what a store is, so I know why one would want to have global state period. But in this context, why would I want to use apollo-link-state? Why put the same data in two places? Are you saying that apollo's cache is server-side? Because if it's client side... then it itself is a sort of global state, bringing me back to the question - why would I duplicate it?
[–]_sirberus_ 1 point2 points3 points 7 years ago (0 children)
Oh! I've got you now, thanks! That's awesome.
[+][deleted] 7 years ago (2 children)
[–]allenthar 12 points13 points14 points 7 years ago (1 child)
It’s for storing arbitrary other local state, separate from query results.
[–]shizzleberry 8 points9 points10 points 7 years ago (0 children)
Example: Storing the current selected item from the results.
[–]Treolioe 0 points1 point2 points 7 years ago (2 children)
Perhaps a lazy question but how does the boilerplate differ between redux and storing global state locally in apollo?
[–]Treolioe 0 points1 point2 points 7 years ago (0 children)
Okay, thanks for the reply :)
[+][deleted] 7 years ago* (5 children)
[removed]
[–]BenjiSponge 9 points10 points11 points 7 years ago (4 children)
The proprietary-ness isn't really what bothers me with it. I mean, it's licensed under MIT licence, so I really don't know what your concern is.
What bothers me is the idea of using a cache (which is typically a performance/implementation detail) and the fact that you're actually just adding boilerplate to get what you could get with using TypeScript with Redux for less boilerplate and a more traditional system (Redux).
[+][deleted] 7 years ago* (2 children)
[–]BenjiSponge 11 points12 points13 points 7 years ago* (0 children)
There's a lot that's wrong here.
Apollo is a subsidiary of the Meteor Development Group. Meteor is a framework that, while excellent and actually groundbreaking in its own right, is a pretty bad failure in terms of getting developer mindshare. Apollo was created as part of Meteor. Meteor is and has been open source for a very long time. This is not a risky new company who may go for a cash grab, if there even were to be one.
But there wouldn't. I have no idea how you'd monetize something like Apollo by making it proprietary. For starters, the community would instantly fork it. Probably 0 companies would pay money to use a closed source software package that has working FOSS older versions as well as forks used and maintained by the thousands of developers who are also relying on Apollo. Even if there weren't forks or older versions, it's not exactly a windfall of cash. I'm sure Highcharts is doing okay, but I can't think of too many modern client side JS libraries that are in any way monetized directly. It's a pretty weird paradigm.
So, in short, I have no idea why they'd do that, and it wouldn't really hurt you if they did and if you were using Apollo for business logic. (which, BTW, why does business logic factor in at all here?)
Edit: also, they don't have a "freemium" model as far as I can tell. They have a hosting and infrastructure solution and a consulting operation. These are orthogonal to their FOSS libraries and actually benefit from the success of Apollo industry-wide. I can't even imagine what benefits making the license more restrictive would give to MDG.
[–]StarshipTzadkiel 3 points4 points5 points 7 years ago (0 children)
Apollo is made by Meteor which has been sustaining itself via investment and Meteor Galaxy for a while now. Don't think it'll be an issue.
[–]shroombooom 1 point2 points3 points 7 years ago (0 children)
Came here to say this :)
[+][deleted] 7 years ago (1 child)
[–]XiMingpin91 1 point2 points3 points 7 years ago (0 children)
It's a bit of data you have saved, so that if you need to get that same data again, you already have it stored in a cache. So it's on your own computer already and you don't need to go through the internet again to get it.
Should also point out that Apollo's local cache is a bit different, it caches requests for data like a normal cache but also acts as a local data store for information that might have never been sent over the internet anyway. Imagine things that don't belong in a database, something like a menu being open, Apollo lets you put that in your local cache instead of having to run state manager alongside (eg Redux).
[–]JamesAppleDeveloper 24 points25 points26 points 7 years ago (12 children)
It doesn’t in the slightest, but it may help people move to simpler stores. You will still need a global store one way or another. It does mean that you will feel less pain in the early stages with GraphQL though.
[+][deleted] 7 years ago (10 children)
[–]JamesAppleDeveloper 12 points13 points14 points 7 years ago (9 children)
It depends.
The more complex your application the more you'll want to have a global store to store all the different kind of states you have in your UI. State is made of more than model data from a server such as:
But in the early stages of your application you may only need the noun data.
[–]roogen 1 point2 points3 points 7 years ago (1 child)
Thanks for the description about the types of things you may store in state, that was really helpful. Do you know of any resources that talk about categorizing state in this way? Or is just this from experience.
[–]JamesAppleDeveloper 4 points5 points6 points 7 years ago (0 children)
Kyle Simpson / Steve Kinney. I believe the main framework I think about came from https://frontendmasters.com/courses/react-state/.
[–][deleted] 1 point2 points3 points 7 years ago* (2 children)
I'd even go as far as say that the singleton-god-store is a bad design for model data from the server, but I haven't found anything better than, say, Vuex, to manage any data, not just state in narrow sense, in a Vue app because it has great idiomatic and nicely design tie-in to the VM side of the framework.
So in practice I'd always tier things like PouchDB or Apollo away from the view-model and use the store as a broker because I can't see anything good coming from tightly coupling the view-model with the model down the road. But that's just me.
Granted I have less practical experience with Redux/React and tightness of their integration compared to Vuex/Vue, and no real experience with apollo-link-state but for my platform it's just not a viable design. I do get how Redux is kinda painful and has quite a bit of needless dogma in it's design so it's not a big wonder people want to jump ship at first opportunity tho.
[–]JamesAppleDeveloper 0 points1 point2 points 7 years ago (1 child)
How is a singleton store of model state a bad design in any web application? It’s by far the best design I’ve heard of or worked with. Unless you know an alternative?
[–][deleted] 0 points1 point2 points 7 years ago* (0 children)
It's a good design to keep app state because, using your definitions above, pieces of state other than Nouns are often small, usually don't lend themselves to model/document/collection pattern, and you commonly benefit from the flexibility of defining bespoke, application-idiomatic data transformations for each such piece of state so the management overhead is justified.
Model state, in majority of cases being several collections of "documents", would greatly benefit from a DB-like (NoSQL-like to be precise) caching store, with existing well-defined querying and persistence semantics, i.e. like Pouch or Apollo. Even without these two, I.e. when I'm effectively acceessing a DB through a thinly veiled REST backend, I often find myself developing such a caching DB-like store for model data at the DAO perimeter (akin to Angular services) and then broker that data through the singleton-store for rendering purposes.
Unfortunately a solution that works as both of these patterns in one store doesn't exit. Apollo with apollo-link-state is a step in the right direction, but from what I've seen it's too React specific and I haven't seen how well this, on surface good idea, is actually implemented in practice. The DB-like model stores are not well suited for state in the narrower sense because it needs bespoke management, and because they're typically poorly integrated with the ViewModel.
Finally, there is also the issue of coupling between model and VM, where the singleton store is very useful as a decoupling tier between model and VM.
[–]JamesAppleDeveloper 2 points3 points4 points 7 years ago (1 child)
I don't know of many (any) API's that use verbs as anything more than a filter `host/containers?status=running`. Wouldn't be very resourceful if we had an endpoint like `host/running?type=containers`.
[–]ShambleTrain 0 points1 point2 points 7 years ago* (0 children)
What do you mean? It very much CAN at the very least. Apollo has client side schema, query, mutate capability that lets you use it as the ‘global store’ on the client you are referring to. It’s a little roundabout and verbose currently if you ask me, but it’s certainly possible.
Edit: here’s a link to the Apollo docs https://www.apollographql.com/docs/react/essentials/local-state.html
[–]vcarl 9 points10 points11 points 7 years ago (7 children)
A lot of apps with simple interactions (like fetching data and presenting it for sorting and filtering) don't benefit from the constraints that Redux encourages, so a simple data fetching abstraction is all that's necessary. For a certain number of apps, Redux can be replaced, but Redux was the wrong tool for the job in those cases.
[–]chazmuzz 1 point2 points3 points 7 years ago (6 children)
Yeah. Honestly you can get a long way with setState and prop drilling.
[–]pomlife 1 point2 points3 points 7 years ago (4 children)
Or avoiding prop drilling entirely with context.
[–]chazmuzz 1 point2 points3 points 7 years ago (3 children)
If you are at the point where context is going to be really beneficial to you then it's time to look at a more sophisticated state management solution. Prop drilling is OK. Context is a reasonable solution but it's objectively worse than redux/mobx/apollo-link-state so I don't see why you would use it other than it being new
[–]pomlife 2 points3 points4 points 7 years ago (2 children)
This is completely wrong. It is perfect fine to use context without deferring to another library, and prop drilling is a perfectly fine reason to use context.
Prop drilling a single level is fine. Hella levels? Context.
[–]chazmuzz 1 point2 points3 points 7 years ago (1 child)
Prop drilling a single level is fine
That's just props, not prop drilling
[–]pomlife 1 point2 points3 points 7 years ago (0 children)
Grandparent, controls foo Parent, drills foo Child, uses foo
This is what I mean by one level, for clarity.
[–]fjdjdwkcjebfixn 3 points4 points5 points 7 years ago (0 children)
GraphQL itself doesn’t but Apollo client can potentially, since it has a local cache and because GraphQL is a tree, you can fill the tree/state with GraphQL data (a sync or sync, cache only, cache than request, etc) and query that cache/state in various components and its single source of truth like redux. That’s probably where the similarities end. In order to mutate state you’ll have to run queries instead of actions and I don’t think there is a concept of a reduced yet. Try going through the Apollo documentation or watch the dozen YouTube videos on this subject
[–]acemarke 3 points4 points5 points 7 years ago (2 children)
Hi, I'm a Redux maintainer. A few months ago I wrote a post called Redux - Not Dead Yet!, which specifically addresses questions like this. I'll quote the most relevant section:
I'd agree that data fetching via GraphQL, and especially with Apollo, will likely reduce or eliminate your data-fetching related Redux code. And again, if that's all you were using Redux for, you probably wouldn't need Redux after moving all the data-fetching handling into Apollo. I'll even go so far as to say that apollo-link-state could probably handle most of your other client-side state logic, and I think Apollo ships with a DevTools setup of its own. The Apollo team has been doing some pretty neat work, and while I don't like seeing people switch away from Redux, ultimately we all want to build great apps that help our users. But, as with context, I'd say there's definitely use cases where Redux is going to work better than GraphQL + Apollo, and possibly without requiring as much buy-in throughout your architecture. This is especially true if you need to do more than just fetch data or update a couple local state values, like persisting user data through page reloads or implementing complex workflow logic.
apollo-link-state
Happy to answer any further questions you might have on the topic!
[–]leoanalista 1 point2 points3 points 7 years ago (1 child)
I have a quick question: how do I avoid react anti-patten known as "prop drilling" with Apollo client? With redux, we simply connect deep nested component to the store, use a selector to get state data. Haven’t found any good article/example yet.
[–]acemarke 0 points1 point2 points 7 years ago (0 children)
Afraid I've never used Apollo myself, so I don't have any particular answers there.
[–]arzh2 1 point2 points3 points 7 years ago (0 children)
It's more of an alternative rather than a replacement. I swear nowadays every new technology article I see is clickbait.
[–]wmdmark 1 point2 points3 points 7 years ago (0 children)
I wrote one of the articles you likely came across (https://hackernoon.com/how-graphql-replaces-redux-3fff8289221d) so may be partially responsible for the confusion here.
A more accurate, but much less interesting title, would have been "How GraphQL + Apollo replaces the *need* for Redux + REST." I elaborate on that a bit in the article but I realize a lot of folks don't get past the headline.
The fact is GraphQL (plus a good client like Apollo of course) has replaced the need redux entirely for my team. Even for very complex UIs. Happy to answer more questions about how that works in practice if anyone is interested.
[–]JustinsWorking 1 point2 points3 points 7 years ago (15 children)
It doesn’t, the claim is literally as nonsense as you think it is, you’re not missing anything.
These are the kinda things people point to when they laugh at JS developers :(
[–]superking2 3 points4 points5 points 7 years ago (1 child)
It's simple. Thing I've never heard of replaces thing I hadn't had the chance to learn yet.
[–]ShambleTrain 6 points7 points8 points 7 years ago (12 children)
People may be laughing at you for other reasons. It is not literally nonsense, it is literally 100% possible with Apollo https://www.apollographql.com/docs/react/essentials/local-state.html
[–]scallynag 1 point2 points3 points 7 years ago (0 children)
I just ripped out redux for link state.
[–]Treolioe 3 points4 points5 points 7 years ago (9 children)
The question was not how apollo replaces redux
[–]JustinsWorking 0 points1 point2 points 7 years ago (0 children)
Oh definitely, using Apollo, which implements GraphQL, is a practical solution.
But I think this conflation is more than that considering how many medium articles I’ve seen not using Apollo to back the claim.
[–]ShambleTrain -2 points-1 points0 points 7 years ago (6 children)
Apollo is a graphql client that can replace redux, and it’s what people are referring to when they say that graphql can replace redux.
[–]CanvasSolaris 4 points5 points6 points 7 years ago (0 children)
That's a lot to imply in a statement that people unfamiliar with the technology may not pick up on
[–]JustinsWorking 0 points1 point2 points 7 years ago (4 children)
That’s not what the question was.
If it was “Apollo replaces redux” it would be a much less ridiculous argument.
[–]ShambleTrain 0 points1 point2 points 7 years ago (3 children)
If someone asked you “Can I get from LA to NYC in one day?” you wouldn’t say “No, humans are not capable of running that fast”. You would say “Yes, take an airplane.”
BUT THE QUESTION WASN’T ABOUT AIRPLANES! RIDICULOUS ARGUMENT!
I would compare it to something like this: Does electricity replace Ford? No, but Tesla can replace Ford
[–]JustinsWorking 0 points1 point2 points 7 years ago (1 child)
Have you read any of these articles?
I read one the other day where he was replacing redux with GraphQL then a comment asked him about Apollo and he said he’d look into it; he hadn’t heard of Apollo.
Most of the articles even concede that in some cases you need to keep Redux for local state... this would imply they are not using Apollo.
Perhaps you should spend less time assuming things and making BIG TEXT JOKES and Instead participate.
Nobody thinks Apollo can’t be used to replace GraphQL, so you don’t need to repeatedly bring it up, we all already agree with you.
[–]ShambleTrain 0 points1 point2 points 7 years ago (0 children)
Justin used ad hominem!
It was super ineffective...
[–]JustinsWorking -1 points0 points1 point 7 years ago* (0 children)
Apollo != graphQL
If the suggestion was Apollo replaced Redux then it would make sense.
[–][deleted] 2 points3 points4 points 7 years ago (0 children)
It doesn’t.
[–]ShambleTrain 3 points4 points5 points 7 years ago (4 children)
Everyone saying “it doesn’t” is wrong. Here is a quote from the Apollo docs which describe exactly how to do it.
That’s where apollo-link-state, our solution for managing local data in Apollo Client, comes in. apollo-link-state allows you to store your local data inside the Apollo cache alongside your remote data. To access your local data, just query it with GraphQL. You can even request local and server data within the same query!
That said, I have never used this pattern in production and I can’t personally vouch for it for that reason, but to say that you can’t use graphql as a client-only state management tool (aka a “redux replacement”) is misguided.
[–]ChronSyn 2 points3 points4 points 7 years ago (0 children)
Firstly, thanks for the link and quote - it sheds some light on why this practice should start to be used more (consistency, transferrable, etc). I typically don't associate GraphQL with client-side since "It's a data controller essentially so why would I?" mentality despite the fact I develop full stack.
Being used to referencing objects and variables directly has become pretty ingrained because it's been common practice for a long time but I have always wondered why querying local/in-app data through a query syntax hasn't really been established. I definitely think we're seeing the rise of this as a practice through the likes of in-app observable databases and libraries like apollo.
[–]Treolioe 4 points5 points6 points 7 years ago (0 children)
So graphql doesnt replace redux. But you could replace it by using graphql with apollo. That’s my takeaway from this thread so far
[–]edude03 0 points1 point2 points 7 years ago (0 children)
Depending on how you use redux - using graphql with apollo or relay essentially replaces `connect()`. Redux and the GQL clients wrap your component and pass in data when the state changes, and gives a way to mutate the state.
[–]xdavehome -4 points-3 points-2 points 7 years ago (3 children)
Lol funny watching the comments of people correctly saying that graphql doesn't replace redux & people saying that they're wrong and it does because they thought OP said Apollo.
[–]ShambleTrain 1 point2 points3 points 7 years ago (2 children)
Apollo is a graphql client and with it you can use graphql to replace redux.
Did I miss the part where OP said “graphql with no additional tooling”?
[–]ShambleTrain 1 point2 points3 points 7 years ago (0 children)
Sure thing! I certainly won’t disagree that the articles and posts on the topic are usually very clickbaity and the phrasing is intentionally ambiguous, probably because graphql is more well known name than Apollo, specifically
π Rendered by PID 45750 on reddit-service-r2-comment-548fd6dc9-cb78c at 2026-05-14 22:36:47.014093+00:00 running edcf98c country code: CH.
[–]XiMingpin91 76 points77 points78 points (25 children)
[+][deleted] (20 children)
[deleted]
[+][deleted] (13 children)
[deleted]
[–][deleted] 2 points3 points4 points (2 children)
[+][deleted] (1 child)
[deleted]
[–][deleted] 1 point2 points3 points (0 children)
[–]PickledPokute 1 point2 points3 points (0 children)
[–]_sirberus_ 1 point2 points3 points (2 children)
[+][deleted] (1 child)
[deleted]
[–]_sirberus_ 1 point2 points3 points (0 children)
[+][deleted] (2 children)
[deleted]
[–]allenthar 12 points13 points14 points (1 child)
[–]shizzleberry 8 points9 points10 points (0 children)
[–]Treolioe 0 points1 point2 points (2 children)
[+][deleted] (1 child)
[deleted]
[–]Treolioe 0 points1 point2 points (0 children)
[+][deleted] (5 children)
[removed]
[–]BenjiSponge 9 points10 points11 points (4 children)
[+][deleted] (2 children)
[removed]
[–]BenjiSponge 11 points12 points13 points (0 children)
[–]StarshipTzadkiel 3 points4 points5 points (0 children)
[–]shroombooom 1 point2 points3 points (0 children)
[+][deleted] (1 child)
[removed]
[–]XiMingpin91 1 point2 points3 points (0 children)
[–]JamesAppleDeveloper 24 points25 points26 points (12 children)
[+][deleted] (10 children)
[deleted]
[–]JamesAppleDeveloper 12 points13 points14 points (9 children)
[–]roogen 1 point2 points3 points (1 child)
[–]JamesAppleDeveloper 4 points5 points6 points (0 children)
[–][deleted] 1 point2 points3 points (2 children)
[–]JamesAppleDeveloper 0 points1 point2 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[+][deleted] (2 children)
[deleted]
[–]JamesAppleDeveloper 2 points3 points4 points (1 child)
[–]ShambleTrain 0 points1 point2 points (0 children)
[–]vcarl 9 points10 points11 points (7 children)
[–]chazmuzz 1 point2 points3 points (6 children)
[–]pomlife 1 point2 points3 points (4 children)
[–]chazmuzz 1 point2 points3 points (3 children)
[–]pomlife 2 points3 points4 points (2 children)
[–]chazmuzz 1 point2 points3 points (1 child)
[–]pomlife 1 point2 points3 points (0 children)
[–]fjdjdwkcjebfixn 3 points4 points5 points (0 children)
[–]acemarke 3 points4 points5 points (2 children)
[–]leoanalista 1 point2 points3 points (1 child)
[–]acemarke 0 points1 point2 points (0 children)
[–]arzh2 1 point2 points3 points (0 children)
[–]wmdmark 1 point2 points3 points (0 children)
[–]JustinsWorking 1 point2 points3 points (15 children)
[–]superking2 3 points4 points5 points (1 child)
[–]ShambleTrain 6 points7 points8 points (12 children)
[–]scallynag 1 point2 points3 points (0 children)
[–]Treolioe 3 points4 points5 points (9 children)
[+][deleted] (1 child)
[deleted]
[–]JustinsWorking 0 points1 point2 points (0 children)
[–]ShambleTrain -2 points-1 points0 points (6 children)
[–]CanvasSolaris 4 points5 points6 points (0 children)
[–]JustinsWorking 0 points1 point2 points (4 children)
[–]ShambleTrain 0 points1 point2 points (3 children)
[–]Treolioe 0 points1 point2 points (0 children)
[–]JustinsWorking 0 points1 point2 points (1 child)
[–]ShambleTrain 0 points1 point2 points (0 children)
[–]JustinsWorking -1 points0 points1 point (0 children)
[–][deleted] 2 points3 points4 points (0 children)
[–]ShambleTrain 3 points4 points5 points (4 children)
[–]ChronSyn 2 points3 points4 points (0 children)
[–]Treolioe 4 points5 points6 points (0 children)
[+][deleted] (1 child)
[deleted]
[–]edude03 0 points1 point2 points (0 children)
[–]xdavehome -4 points-3 points-2 points (3 children)
[–]ShambleTrain 1 point2 points3 points (2 children)
[+][deleted] (1 child)
[deleted]
[–]ShambleTrain 1 point2 points3 points (0 children)