Most apps are simple, don’t need to send much data around if you don’t put 3-10 user tracker in, and Rest is just really, really simple for most parts.
In every project I worked so far that used GraphQL, developers tend to not care about backwards compatibility of APIs because having tons of optional properties in query responses doesn’t feel nice.
As always, there are exceptions and if it makes sense, sure, go ahead. But be aware of the dependencies and the magic you get into your project. Oh, and don’t use it for file upload, that’s just painful.
But, I don't see how you build a VC funded business out of this - countless examples of infra companies trying to build a business out of OSS technology and they always struggle to get paid because they provide so much value for free.
Docker Inc's struggles come to mind here...
1. Build the best GraphQL developer tools we can, focusing on making developers happy. Make sure those tools are open source, and involve the GraphQL community as much as possible when building them, to make sure we're building tools developers actually want to use. With those tools available, make sure any developer who wants to use them can, for free.
2. At the same time, build more advanced tooling and sophisticated GraphQL infrastructure components (that would be costly for an individual organization to build and maintain themselves), that provide a way for businesses and organizations to effectively, efficiently, and securely manage their GraphQL based infrastructure. Give anyone the chance to use these more advanced tools/components for free up to a certain threshold, to see if they're a good fit and if they're worth the money. If all signs point to yes, we then start charging.
Our approach is fairly simple, and has been followed successfully by many companies before us (a simple plan is a good plan). We've been following this approach for a while (before this funding came into place), and things have been going extremely well.
I love the callout to how this is continuing the vision for improving application development started with Meteor -- it really does feel that way to me. Apollo, supported by GraphQL is IMO really delivering on the vision of making a lot of aspects of client-rendered app development much more straightforward than they have been in the past.
I have a lot of experience with JSON-REST APIs and RPC systems like gRPC and they both seem clearly superior (especially in tandem with code generators) where as GraphQL seems like a ton of extra work on the client and server side for little gain. When asked most developers say its because you can limit which fields you query, and I have to politely explain to them the existence of an SQL SELECT query...
`GET localhost/graphql`, with body
dogs {
name
location {
city
}
isAGoodBoy
}...and I get back:
dogs: [
{
Fido,
location: {
Boston
},
true
},
{
Spot,
location: {
Los Angeles
},
true
},
...
]No extra fields. My clients page doesn't care about the dog's UUID, weight, etc. No routes. Everything goes to `localhost/graphql`.
It makes writing clients an absolute joy, and it works gloriously with React. Tell the server exactly what you want, and get exactly that.
On the back-end, every field (name, isAGoodBoy) is a resolver. Maybe it's a simple database call to retrieve that field. Maybe it's some service that pulls crap from an S3 bucket. GraphQL doesn't care. So the level of difficulty of implementing a GQL server is dependent on your back-end. For most folks, you'll just be making calls to a database.
For me this is one of the biggest headaches I have with a new app I've been assigned to. By allowing all fields to be optional depending on the graphql query, there's no consistency in the objects floating around in your apps data store. When I reference a Person object in my view that I'm using, will phone number be there or not, who knows.
Maybe its better when every single page has to request it's own data, but when the model objects are cached to a data store in an app and shared between views, things get really dicey.
One of the places where it really shines is providing a queryable API entry point to a graph of interconnected data. This makes it ideal for generally reusable APIs for consumption by a variety of clients (e.g. GitHub's GraphQL API).
gRPC interfaces are typically use-case specific, and performance oriented (though GraphQL doesn't specify any sort of transport protocol, so you could always serialize GraphQL request/responses with protobufs to gain some performance over the wire), making them well suited for server-to-server communication, but not generally reusable.
REST is resource (i.e. nodes in a graph) based, but doesn't necessarily do a good job of making the relationships explicit and easy to traverse (I'm sure there are good HATOAES implementations out there that address this, but I haven't seen one).
Both REST and gRPC have their place, but I think GraphQL is a clear winner when you want to build a single API to service a large number of distinct clients. It really does offer a clear, easy-to-use API abstraction over where ever you might get your data from.
Also, since you call out code generation specifically; GraphQL provides a strongly-typed schema that can be introspected against, and the tooling to parse queries/schemas into abstract syntax trees. A large number of tools have been built with these capabilities including a number of different code generators. I've even used a GraphQL schema to generate a matching XSD (ugh) for import into an internal business rules engine. Made integration a breeze.
Say, for example, that you have a new UI on your app that requires some data stored on your db.
Without graphql, you:
A) Re-use existing REST endpoints and compose data that you need on the front end (but remember that browsers have a hard limit on the number of concurrent api requests. Not to mention that some requests can't be sent until others have arrived back with resource id's). So depending on what endpoints you currently have, this may not be a good option given the latency cost of composing many HTTP requests to get all the required data.
B) You tell your back end devs to create a brand new route that meets the data requirements of the new UI.
With GraphQL, my understanding is that there is zero back end work. You just tell the GraphQL engine what data you need and it magically arrives into your browser.
A good way to think about GraphQL is it’s data centric as opposed to operation centric. The unit you work with is the object instead of the operation.
Object level querying instead of operation level querying
Object level auth instead of operation level auth
I advocated for its use on several projects and was bitten by major performance bottlenecks and its over reliance on MongoDB. GraphQL implementation is great, but does it support relational dB's yet?
I am happy to hear that it is still doing well, and I may end up using it for some personal projects.
I believe that the problem it is trying to solve is worthwhile. However I became very frustrated when the push for monetization started while the framework itself still seemed like it was in the prototype phase.
Please correct me if I am wrong, but Meteor has a place in my memory similar to an ex that I really cared about but hurt me once more than I could stomach.
It is not being maintained by anyone as far as I can tell, more and more packages are breaking by the week it seems like, and the basic 'features' listed 'on the box' of Meteor have never worked.
Save yourself some headache and pick a stack with an active community.
I haven't used apollo-server but I wrote nodejs code for 8 years and I wouldn't trust it to scale without a lot of effort being put into your DevOps story.
> They're taking funding and attention away from other more deserving projects.
I've gotta say, I completely disagree with this statement. Meteor and Apollo have both helped thousands of developers do amazing things, for free. Yes, I work for Apollo, but I'll detach for a sec; I can't think of any open source software company on the planet that deserves this more than they do. I can tell you first hand that Apollo cares deeply about open source software (OSS culture is ingrained into the company right from the top), and goes to great lengths to make developers happy and provide ways for developers to use a large portion of the things it builds for free - no strings attached. When I encounter other companies that act like this, I instantly think they should get anything they need to help themselves flourish and thrive - Apollo is no different.
It's just a bunch of wealthy people using their money to force their opinions about software development onto as many developers as possible...
I can guarantee that there exists simpler solutions outside of the GraphQL bubble that far exceed what can be achieved with Apollo in terms of both flexibility and productivity. I could share some links if you are genuinely interested.
Have you quantified this? I'd be curious to see how much productive companies are using GraphQL when compared to creating, e.g., generic REST API's.
With that being said, I really hope Apollo will provide their iOS library some much needed love soon, or clearly imply they're not developing it anymore. They've mentioned they're hiring an iOS engineer maybe a year ago? but largely the repo has gone neglected. I've made some modest improvements for our sake, but PRs generally go unreviewed forever, so it doesn't seem worth writing the tests to get my work in a landable state.
Apollo's local state tools are bad in my opinion as well. It might work OK if you just want to keep a few global flags, but anything more, and it gets really verbose. Especially if you want to update state based on current state, you have to first manually fetch the current state, then update it, then save that object back, every time. On top of this, its often necessary to write mutations just to update local state, which are written as GraphQL strings - one mistake in this syntax and you can be stuck trying to debug it for a while. How any of that is easier than just having Redux I still don't understand.
Overall, Apollo feels like a worse version of Angular.js - an app framework thats trying to do way too much. If your app just made basic GET requests and had no other logic, I could see how Apollo could be useful (but why have a framework at all in this case?) However, if you have complex logic or local state, Apollo quickly becomes and opinionated, unwieldy piece of junk
> in reality, its a bad idea to have your view layer directly making API calls - those should be in some other module thats lower level, away from the view and easier to test.
Apollo doesn't force you to cram everything into your view layer. If you want full control over how your interact with your GraphQL backend, you can wrap "Apollo Client" in whatever layer you want. If you're using a view layer integration like "React Apollo", we try to help reduce some of the extra layer boilerplate that can come up, when integrating your view layer with other controller, model, business, etc. layers. Again though, none of this is mandatory, and it's important to understand that components in "React Apollo" aren't directly making API calls. Query, Mutation and Subscription components are just React components, that communicate with Apollo Client behind the scenes. Here, "Apollo Client" is the lower level module that you're referring to, that then takes care of API calls. As for testing, you can (and should if possible) test all parts of your application, be it view layer or lower level API integration points. We provide tools to help unit test React Apollo components with mock/fake data (that can be integrated with any popular React testing library), and there are lots of great ways to unit/integration test Apollo Client (and its associated libraries).
> But instead, people use these query components everywhere, and all of the sudden, the view balloons with logic like parameter validation, error handling, etc... Everything is weaved into the view and very hard to unit test.
React gives you a toolset to work with and manage components. Can you build an application that gets out of control using React? Absolutely. Apollo gives you a toolset that can be used to work with data. Can you build an application that gets out of control with Apollo? Most definitely. Just like the React team, we've taken a lot of steps to help developers avoid these application design pitfalls. We spend a lot of time working on our docs, routinely blog about best practices, and help developers whenever/wherever we can, through various social channels, meetups, conferences, etc. That being said, we've worked side by side with hundreds of developers who are using Apollo happily and productively, and if anything, have found that Apollo's view layer integration has helped them get their countless view layer data integration points under control (and made things easier to test).
> Apollo's local state tools are bad in my opinion as well. To update any state, you have to constantly fetch the current state and then make a modification.
This isn't accurate. Actually, in most cases saving and updating local state is as easy as just running a query/mutation - everything happens for you seamlessly. Apollo Client's local state capabilities have changed quite a bit as of version 2.5, so give a newer version a try (and see the updated docs) to see if that helps.
> This feels a lot more cumbersome than just having redux and reducers.
Redux can definitely come in handy, but it has its strengths and weaknesses (like all tech). One of the core tenants of Apollo Client's local state handling is that it knows how to work with GraphQL out of the box. This means AC's local state handling can be used to do all sorts of great things, that would require more work to accomplish with something like Redux. Things like working with a specialized cache that normalizes GraphQL query responses to speed up cache reading/writing, know how to merge local state with results returned from remote queries so applications get everything they need from local and remote after running a single query, replicate remote GraphQL resolver functionality locally to inject advanced data management techniques on the client side, etc.
> Overall, Apollo feels like a worse version of Angular.js - an app framework thats trying to do way too much. If your app just made basic GET requests and had no other logic, I could see how Apollo could be useful. But anything more complex, and the code becomes a weaving, untestable mess.
Some of the biggest companies on the planet (with amazingly complex applications and systems) are using Apollo and loving it. That being said, we're always striving to do better and welcome constructive feedback like yours. Please consider opening issues in any of our Github repos with your problems and suggestions regarding how we can help make things better.
You are glossing over the fact that there is a 3rd part, writing a reducer! This part is the most cumbersome in my opinion.
Lets say you wanted to keep a counter and increment it in your app. With Redux, you add it to your state, write an "increaseCounter" action, and then write a reducer. This reducer is just a plain function without any dependencies. A unit test for this reducer would just test that the count was updated.
However, with local state management with Apollo, you would either need to 1. write an incrementCounter mutation and an incrementCounter reducer. Inside that reducer, you would have to fetch the current count from the cache, update that count, and then write the results from the cache. 2. Just use `cache.writeQuery` or `cache.writeData`, but in either case, you need to fetch the current state of the cache, modify it, and then write the object back.
The problem with this is that any time you want to modify state, you need to always fetch the current state, and then write the state back. This is bad because
1. its super repetitive 2. it tightly binds the code of "how the state changes" to "how the state is queried and saved"
Overall, this whole approach of having to write a mutation and a reducer for every state change is annoying and verbose. Redux is just overall a better, more convenient pattern to incrementally update a piece of state.
We actually thought about adding a Redux layer on top of Apollo, so that we would just have a single "Redux" mutation that fetches the current state, passes it to a reducer, and then saves the transformed state in the cache to avoid all this fetching and saving, but then were afraid of potential performance issues of homerolling our own Redux, and went with actual Redux instead.
(maybe it doesn't, but at first glance it looks similar in a lot of ways to me)
Thank you for the insight!
Everybody knows there are exactly three hard problems in software development:
1. Naming Conventions
2. Off-by-one-Errors
GraphQL is a rabbit hole. Don't use it unless absolutely necessary or you have a small to mid-sized team for large scale projects. Atleast on Phoenix/Elixir side of things, it's just not worth the effort - you need to write resolvers apart from your schema/models, handle changeset errors in the frontend (which there is no way to deal with directly as of this comment) and if you're working with VueJS, then good luck. My package.json is so bloated that I am starting to feel it's all just a pack of cards. I can't stress enough how much valuable developer time I wasted getting all these bits and pieces working together. Usually, you can't use one because the other one is outdated, or has some weird Github issue you now need to address. And then that causes another probelm..and another one..[the rabbit hole goes deep]
"@babel/core": "^7.0.0",
"@babel/plugin-syntax-dynamic-import": "^7.2.0",
"@babel/preset-env": "^7.0.0",
"apollo-absinthe-upload-link": "^1.5.0",
"apollo-cache-inmemory": "^1.6.1",
"apollo-client": "^2.6.1",
"apollo-link": "^1.2.11",
"apollo-link-context": "^1.0.17",
"babel-loader": "^8.0.0",
"babel-preset-env": "^1.7.0",
"coffee-loader": "^0.9.0",
"copy-webpack-plugin": "^4.5.0",
"css-loader": "^2.1.1",
"file-loader": "^3.0.1",
"graphql": "^14.3.1",
"graphql-tag": "^2.10.1",
"mini-css-extract-plugin": "^0.4.0",
"node-sass": "^4.12.0",
"optimize-css-assets-webpack-plugin": "^5.0.1",
"resolve-url-loader": "^3.1.0",
"sass-loader": "^7.1.0",
"script-loader": "^0.7.2",
"style-loader": "^0.23.1",
"uglifyjs-webpack-plugin": "^1.2.4",
"vue-apollo": "^3.0.0-beta.30",
"vue-loader": "^15.7.0",
"vue-template-compiler": "^2.6.10",
When DHH ranted about these, I never believed him and I always thought he was not upto par with JS frameworks. But turns out, everything he said was true. Turns out, you don't need GraphQL at all for most use cases when you can simply get away with something like Tubrolinks or LiveView.Does this mean Meteor is dead?
Also, the end paragraph mentions some cloud-based graph management system. Is there any chance they could do a decentralized graph management system (something like https://github.com/brysgo/graphql-gun ) instead of some centralized solution?
I don't want my GraphQL data getting locked in to some vendor. Any reason why I shouldn't worry about this? Thanks!
I would add: now it's everyone else's job to make those smaller, more focused libraries work together. The time wasted is unfathomable, but the blame for misconfiguration now falls on individual developers, rather than monolithic frameworks. Progress?
Absolutely not! We depend on it internally (engine.apollographql.com is a Meteor app), and Galaxy hosting revenue is THE reason we didn't have to raise money until we felt like it, which is why we got to pick our investors in this round.
Behind the scenes, as the lead developer for both Apollo Client and Meteor, I am constantly borrowing technologies from one to benefit the other. Meteor may move more slowly these days, but that's because it's relatively mature. Apollo has to move more quickly because we're still making (and remaking) fundamental decisions.
Even as community enthusiasm for Meteor has slowed, Galaxy revenue has not, and it's honestly not the worst thing for an open-source project if people who came for the hype either (a) find real reasons to stay, or (b) take their hype-thirst elsewhere.
I have some ideas for increasing Meteor contributor engagement that I'll be giving a talk about at the next Meteor Night (tentatively July 9th in SF).
I love meteor, and don't really want to move our stack off it but it's becoming a more real thing that we have to face in the near future as it's hard to see how it can grow with us!
I can only imagine the reason galaxy revenue is increasing is that the companies started off Meteor 2-3 years ago are now becoming real. I know a few companies in our YC batch that use Meteor.