Тёмный
No video :(

Why I Don’t Use GraphQL Anymore 

Harry Wolff
Подписаться 28 тыс.
Просмотров 70 тыс.
50% 1

Опубликовано:

 

21 авг 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 328   
@hswolff
@hswolff 4 года назад
If you have an interest in discussing this in more real time, then join my Discord server! discord.com/invite/6YbKq8R
@__hz__6983
@__hz__6983 4 года назад
I've only used GraphQL with AWS Amplify. It generates a lot of stuff that serves my current goals, but otherwise I don't think I'd use it. Rest may be more primitive but simplicity is more valuable to me nowdays.
@kalahaval
@kalahaval 4 года назад
I'm totally on your side. The company I'm working for is using GraphQL and I still don't get the benefits for this project. I do see advantages for various use cases, but I think often it's just overhead. Especially in a small team. And often I'm unsure if the way it's implemented (in our app) is really the right way of doing it. And that feeling leads to my opinion, that it could be better replaced with classic REST or other (simpler) abstractions.
@tommylemon4462
@tommylemon4462 3 года назад
Tencent/APIJSON is much better than GraphQL, especially on functions, safty and performance. And APIJSON is very easy to use because you don't need to write any code for API development. github.com/Tencent/APIJSON/blob/master/README-English.md
@sumitkachare6628
@sumitkachare6628 Год назад
Even I am having the same situation as you . We have a project using graphQL but there is a REST server between frontend and graphQL server . I mean whats even the purpose of graphQL if its not doing whats its meant for in my project.
@marcusrehn6915
@marcusrehn6915 11 месяцев назад
Have a similar issue where I work. I think the only benefit we get is that the schema is better than Open API. Also, if i need a mixed bag of values from different resources and it's better to do that in the backend, then I'll do that in the backend, Rest standards be damned. Although I might name it differently.
@rickvian
@rickvian 3 года назад
I have solution to all of this problem, introducing... REST API
@fuseteam
@fuseteam 4 года назад
well i suppose making one end simpler makes the other end more complex
@staenker1983
@staenker1983 4 года назад
Omg, that’s honest and you even mentioned that not everyone is Facebook or Netflix. Keep up that kinda work, I’m happily waiting for another gem like that one :)
@hswolff
@hswolff 4 года назад
Thank you for the kind comment!!
@qodesmith520
@qodesmith520 4 года назад
I work at FB, and let me tell you I struggle with Relay's complexity all the time! Not intuitive at all. Glad to see I'm not alone :) Great video! Keep these coming.
@hswolff
@hswolff 4 года назад
Great comment! Interesting to hear! And yes, I shall! Thank you!
@aberba
@aberba 3 года назад
Relay looks very over-engineered
@tommylemon4462
@tommylemon4462 3 года назад
Excuse me, would you like to share us how is the situation of GraphQL in Facebook now?
@qodesmith520
@qodesmith520 3 года назад
@@tommylemon4462 not sure exactly what you mean, but at Facebook we use GraphQL extensively. It's not going away any time soon.
@tommylemon4462
@tommylemon4462 3 года назад
@@qodesmith520 thank you~
@wolfymaster
@wolfymaster 4 года назад
Been using GraphQL the last 4 years. I went through all those same frustrations. Tried Relay for a little bit, but fell back to apollo.
@tommylemon4462
@tommylemon4462 3 года назад
Tencent/APIJSON is much better than GraphQL, especially on functions, safty and performance. And APIJSON is very easy to use because you don't need to write any code for API development. github.com/Tencent/APIJSON/blob/master/README-English.md
@TechdubberStudios
@TechdubberStudios 4 года назад
I am in the same position as you are regarding GraphQL, only I gave up on it a lot quicker. I tend to pick technologies that only make my job easier, not the other way around. Hence, I don't use TypeScript, Graphql, React. I will stick with Sapper/Svelte and Rest until something new, that makes me more productive and doesn't give me more things to worry about/ more "chores" shows up. In other words, makes me more productive than I currently am. It may be just me, but it feels like some of these technologies were created by some corporate employees whom are paid per time spent writing code, rather than productivity. I don't wanna be writing code for the sake of writing code. I wanna do things as fast as possible, both on time spent developing and application runtime.
@hswolff
@hswolff 4 года назад
I love some of the sentiments you shared! I agree that tech should ideally work for you and not the other way around. I will say that if you get past the onboarding of GraphQL then it can be super productive, but it can be a fairly steep climb. Also Sapper/Svelte rocks!
@cintron3d
@cintron3d 4 года назад
I haven't tried enough other frameworks to comment on react - I just personally love it. TypeScript however, while there is a little bit of a learning curve (less so if you already know C# since they are very similar in syntax) it absolutely makes me more productive. I can refactor code with more confidence, I can catch simple spelling mistakes as I write them instead of waiting to test in the browser and wondering why things are breaking. After switching to TypeScript, going back to vanilla JS feels like walking blindfolded in a thick jungle. I see junior developers getting hung up on the simplest things (misspellings, bad casing, missing arguments, wrong argument order/type) all because they don't have the IntelliSense or compile errors warning them. Then they spin their wheels trying to figure out what's wrong. Every time that happens I think inside - if only they were using TS we wouldn't be wasting time on these issues.
@TechdubberStudios
@TechdubberStudios 4 года назад
@@cintron3d your comment makes me re-consider my views on TypeScript. Thanks! I have worked with .NET C# on the back-end for a while, and I quite enjoyed. But I wouldn't pick it over NodeJS, personally.
@TechdubberStudios
@TechdubberStudios 4 года назад
@Christian Lewis Over-engineering is a curse, and TypeScript is over-engineered. That's my opinion. And yes, I completely agree with what you've stated.
@luisarias272
@luisarias272 4 года назад
I have the feeling that you are not using the real developer tools for graphql, you can even combine a rest server with a graphql schema 😒
@RedOchsenbein
@RedOchsenbein 4 года назад
Yeah, got the added complexity stuff. However it does not make you use everything, and depending on the scope of the project you probably should focus on the core of what you really need. I found this to be the best way to tackle GraphQL and so far it worked pretty well. I guess the biggest pitfall to look out for is really the n+1 problem. But the concept of dataloaders actually deals quite nicely with that.
@mearaftadewos8508
@mearaftadewos8508 Год назад
The same here, bro. We are not dating GraphQL that we need everything to be perfect. And no framework is perfect anyway. So why not use the part that's great and you need then fill the other part with other frameworks or tools. And move on with your life.
@_ericelliott
@_ericelliott 4 года назад
I love GraphQL for large, complex data models. It's amazing for Blockchain queries and enterprise software. Overkill for most small apps.
@hswolff
@hswolff 4 года назад
I agree! Thanks for joining the comment party Eric! 😀
@MDABDULMOMINRiyadh
@MDABDULMOMINRiyadh 4 года назад
I'm confused in between conversation 😂
@fateriddle14
@fateriddle14 4 года назад
Thank you, strong opinions are what I look for when deciding whether to use something :D I may not agree with you, but it's much more informative than those generic "pros & cons" type of video. Thanks for the great work.
@h0ph1p13
@h0ph1p13 3 года назад
You agreeing or not does not count as experience. This guy has some experience ;)
@fateriddle14
@fateriddle14 3 года назад
@@h0ph1p13 Do you just randomly say some shit in a random video? Please go on, I'm listening.
@derEarl
@derEarl Год назад
Thanks for your video! After years of successfully using REST I felt the pressure (from my younger colleges) of moving on to GraphQL :). So I started to get into it. I liked very what I learned see the benefits. But I felt that the two most weighted selling points of GraphQL doesn't pay out in my specific environment. Your video helped my to underline my opinion on that. So for know I looks like I will stop looking into graphql (for now) as It doesn't match my requirements despite of feeling more modern ;)
@ThisOneGoes211
@ThisOneGoes211 4 года назад
Fragments are hard to use? What?
@Martin_Adams
@Martin_Adams 4 года назад
Ahh dang, when Harry says GraphQL is out, you know you better pay attention 😂 I agree, GraphQL has a lot of complexity, but I've found it better than rest in the project I've been working on. It makes extending the application easier by knowing you have a strongly typed API schema. I've successfully implemented custom scalars, subscriptions for read-time updates, etc. I agree, it's very hard work to get there. My bugbears with GraphQL is inheritance and how it handles two child types using the same name property with different data types. And input types should support inheritance so you can pass in one generic object of different structures. They say there's a limitation because you don't know what type to expect, but it would be easy enough for the client to hint it in the __typename property. GraphQL is to Rest, what Kubernetes is to Virtual Machines. It doesn't make things easier, it just makes the impossible things now possible.
@hswolff
@hswolff 4 года назад
Great comment Martin! Always a delight seeing your input! Thank you!
@maurovalvano5707
@maurovalvano5707 4 года назад
We are using relay + graphql with the new backoffice of our software and we made a huge improvements with relay. No more repositories or manual ajax calls, no more defining endpoints, automatic component dependiances, Intellisense, type checks, auomatic query caches.... We got troubles too in some scenarios (e.g with a search bar in a parent component that will trigger two fetch the first time because we use the useEffect in the child to update the search results). But hey, 1 cons vs 100 pro.
@maurovalvano5707
@maurovalvano5707 4 года назад
@R S if you keep it too simple then you will have tons of boiler code, you also need something that help you on this. Most simple is not always the best.
@asfallion
@asfallion 4 года назад
@@maurovalvano5707 How big is the project? For myself I found that GraphQL was going super well and super at the start. The problems came later as the queries expanded and we had to deal with async loads, subscriptions which are still not first class citizens. @defer is still not mature.
@maurovalvano5707
@maurovalvano5707 4 года назад
@@asfallion our project is pretty big, but the graphql-relay is new but we already did pretty complex things. Nested fragments, etc... I will check what you you say about defers etc. Please note that we are using relay as framework that helps us a-lot.
@swyxTV
@swyxTV 4 года назад
Great vid! I would've mentioned dataloader and persisted queries for pple who want to learn more. there's also gqless which addresses the double declaration problem. I feel like you have been moving for forever!
@hswolff
@hswolff 4 года назад
Bahahah. Moved June, gonna move again next year when we (hopefully) buy a house
@swyxTV
@swyxTV 4 года назад
@@hswolff exciting! the american dream. hope to visit someday!
@ZiPMo85
@ZiPMo85 4 года назад
whoa! netlify guy appears!!! woohoo
@swyxTV
@swyxTV 4 года назад
@@ZiPMo85 haha I left in March. aws guy now
@cksmith007
@cksmith007 Год назад
I’ve been an app developer for over 25 years and my absolute overriding principle is KISS. Occasionally you encounter complex problems that require complex solutions but those are rare in my experience
@MasterTeeee
@MasterTeeee 3 года назад
... Weirdly, the only solid criticism that you've given is, "GraphQL is hard". That doesn't mean that it's not great. Just that the tooling isn't there yet. If a project doesn't require GraphQL, then it's probably fine to not bother, and stick with REST, as it'll likely result in a project being cheaper, just because of the developer time that needs to be spent on it's efficient implementation. However, if you NEED GraphQL's features, then you NEED them. Plain and simple.
@Khari99
@Khari99 4 года назад
As someone who is currently building applications with GraphQL, I can definitely sympathize with a lot of what you're saying. I would say REST is more suited for small scale applications while GraphQL is suited for much bigger ones. What matters is using something that allows you to get the job done efficiently. When it comes to learning, I say something is only worth learning if it solves your problems efficiently. If it does then I recommend being prepared to learn a lot of new material. If it doesn't then use something simpler. There'll definitely a learning curve to GraphQL. You have to determine if you are moving enough data for it to be worth it.
@chinyun1526
@chinyun1526 2 года назад
I totally agree as a fullstack dev. There is not only a lot to learn, but also easier to miss some important things to implement. It's really hard to take care of: error handling, cache, query optimization with db(mongo especially), authorization. All the stuff are different big topic, and need to watch and implement carefully. I will never use graphql in my project next time unless easy and no-authorization project.
@alexisdvt
@alexisdvt 4 года назад
I'm with you, I think part of the job of a senior dev is to choose what tool does the job in an easy and fastest way, and sometimes the old but reliable tech is the solution that's why PHP and others are in the business.
@hswolff
@hswolff 4 года назад
Very true!
@fdg6935
@fdg6935 2 года назад
@@smthngsmthngsmthngdarkside true
@s1nistr433
@s1nistr433 Год назад
Virgin: You need to know React, Graphql, Node, Jabbascript and a million frameworks to be a good web dev Gigachad: Use PHP and a little bit of jquery
@danielkurz7806
@danielkurz7806 4 года назад
The n+1 problem is solved by most popular graphql frameworks / libaries and people are very aware of it.
@remedygrime
@remedygrime 3 года назад
e.g. dataloader
@user-wg1zf3cn9z
@user-wg1zf3cn9z 3 года назад
I am using Apollo federation with microservices in my workplace and till now we are able to implement composition of data with N async requests, it is not free lunch to learn it on the other hand
@alanhoff89
@alanhoff89 2 года назад
Yup, we just use dataloaders
@WebDevCody
@WebDevCody 4 года назад
I don’t even know what the issues are with restful apis.. I tried graphql and wasn’t sure what it really solved.
@BobbyBundlez
@BobbyBundlez 3 года назад
im a noob. but i can see the constant requests being a problem. also state management tools like apollo allow for caching of data which saves a lotttttttt of expensive shit Broooo blaze 420 dude
@henrikholst7490
@henrikholst7490 4 года назад
I liked the format! Please make a video in this format on more technology. Kubernetes which is very hyped would be one obvious one fitting the same kind of rant, and the boxes fit right in for a container orchestration metaphor. 😉
@Developerish
@Developerish 2 года назад
I explored GraphQL in its early days, and it’s pretty remarkable to see the progress and adoption it’s made. My personal philosophy has always been to be technology agnostic, and use the tools best fitted for the job. The magic of its resolving nature is like you mentioned, it’s strongest strength. When you have an application with data that have complex relationships, most likely you’ll benefit from GraphQL. In my case, I was using it to interact with data centers, which have complex topologies that can change at any given state, was incredibly challenging with custom logic. If the overhead is too much, it’s a good time to re-asses why it’s being used in the first place, and if new or bespoke solutions are better suited. Reminds me of the Redux hype for several years, that was fun in React circles for a long time 😂.
@silver12151
@silver12151 3 года назад
Docker... another video where you can use boxes as a metaphore. And thanks nice video and information.
@marcusorelius8090
@marcusorelius8090 3 года назад
I personally feel that each technical solution has its pros and cons and as a technologist our job is to choose least worst solution. There are use cases where graphql would be good but there are times it may not be optimal solution. We can go for hybrid situation based on the problem domain, use rest api where it make sense and grapqhl for situation where it is optimal. There is no one size which fits all, BTW great video. Thanks
@ApichartNakarungutti
@ApichartNakarungutti 4 года назад
I only use a portion (strongly types, self-document, responded filter) of GraphQL, because its complexity, I tried other options but fall back to GraphQL, feel like love-hate situation :/
@djordjenikolic6560
@djordjenikolic6560 4 года назад
Agree 100%. I think biggest weakness is DataLoader and optimizing dynamic fields. It's like ur hacking.. almost impossible to run it fast, because you need those DB calls... But they say it's a strength, cause u easily return data.. u get hyped, but in background that graph is a way heavier than it should. I honestly think web grpc is the next step.. Also typed, but faster
@tommylemon4462
@tommylemon4462 3 года назад
Tencent/APIJSON is much better than GraphQL, especially on functions, safty and performance. And APIJSON is very easy to use because you don't need to write any code for API development. github.com/Tencent/APIJSON/blob/master/README-English.md It supports APP JOIN which likes another kind of DataLoader while coding free. SQL Joins were provided as well, such as LEFT JOIN, RIGHT JOIN, INNER JOIN and so on. github.com/Tencent/APIJSON/blob/master/Document-English.md#2-keyswords-in-url-parameters
@alanhoff89
@alanhoff89 2 года назад
@@tommylemon4462 too bad I don't touch Chinese software
@eugenpaval
@eugenpaval 2 года назад
N+1 problem appears only because developers do not put the effort to implement a GraphQL server without it. It is definitely possible as demonstrated in Hasura and Postgraphile.
@dstudio1011
@dstudio1011 Год назад
I'm looking forward to using GraphQL -- but after a couple of hours just doing the tutorials found online (did not finished - head aches) I tried to read more how useful GraphQL is out there when I came across a couple of vlogs that 'hates' GraphQL. I decided to watch one - (this one) I begin to understand something about GraphQL, and put GraphQL into perspective. Doing full stack alone means projects are not that complex (I guess) so I'm not moving into GraphQL for now and REST it is. Thank you for this vlog - it's presented so that a 5 yo can understand. Also the comments helps a lot.
@puyanwei
@puyanwei 4 года назад
Great vid, would love to see a code comparison/example on how your using REST to do typical GraphQL stuff. I do mostly agree, the learning curve and setup is quite a lot, and with our codebase we ended up over abstracting which ended up making some things confusing.
@hswolff
@hswolff 4 года назад
Interesting question! I'm being very care free about my endpoints. Not even sure they're following REST tbh - just exposing what data I need.
@michaelslattery3050
@michaelslattery3050 2 года назад
I'm using Hasura which I *think* mitigates many of these server-side issues, although you must buy into its way of mapping data.
@nfh3
@nfh3 3 года назад
JSON:API solves the catchability issue, while retaining the ability to specify partial objects, dependants etc
@tommylemon4462
@tommylemon4462 3 года назад
Not JSONAPI, it's APIJSON, lol. github.com/Tencent/APIJSON/blob/master/README-English.md
@Ninja-qk5gf
@Ninja-qk5gf 3 года назад
I love that you mentioned these tools have a problem they solve for Facebook...but "do I have those problems??". Nice.
@henrikholst7490
@henrikholst7490 4 года назад
You mention strongly typed schema in GraphQL as a benefit over an Rest API. But for Rest we have OpenAPI... Doesn't that solve the problem in some sense?
@darkasblue
@darkasblue 2 года назад
so you say openapi is better than graphql ?:)))))))
@gfinzer
@gfinzer 2 года назад
I see a lot of developers chasing shiny things which usually correlate to more complexity. In a way we are creating job security since it takes an inordinate amount of time to maintain the codebase. How I wish we would adhere to the KISS principle.
@amirnoorani5017
@amirnoorani5017 Год назад
amazing topic which is not discussed anywhere but I was looking for
@malikbrahimi7504
@malikbrahimi7504 3 года назад
Honestly, because GraphQL is a graph of nodes as it's name implies you essentially end up making resolvers which in turn ends up resembling REST business logic except you have to do the heavy lifting on the backend to create this "only get what you need" environment running. It's like creating a complex linked list and setting a .next attribute between resolvers so to speak. While it does have some benefits on the frontend it's a huge trade off on the backend in terms of the learning curve and development time. Honestly, what's stopping anyone from creating a helper function for DRY and accepting an argument? APIs getUsers and getUsersWithPosts isn't all that different aside from a simple conditional which you can limit repetition with helper functions, in which case GraphQL is just overkill. If you're going to use GraphQL low key just let Prisma do the heavy lifting. Hell use Prisma for REST too! I wouldn't exactly consider it production ready yet because migrations are still experimental but once that's taken care of my workflow is going to be amazing.
@zomakaja
@zomakaja 4 года назад
As a beginner, it literally took me weeks to get GraphQL, Nextjs, Apollo Server and Client, and Postgres all working together. The complexity is real. Or maybe I'm the only one.
@adamtak3128
@adamtak3128 4 года назад
You're not the only one. Getting ApolloClient to work with Next.js was so annoying...
@axelreefman
@axelreefman 4 года назад
I use strapi cms running in a docker container. It auto generates the api for you with both REST and GraphQL available. It can use Postgres as it's Database. strapi.io
@m-zelinka
@m-zelinka 4 года назад
@@adamtak3128 only because next.js is a hybrid framework, that means you need to configure ApolloClient work both on the server-side and client-side. This should be solved, once plugins are here!
@adamyee523
@adamyee523 4 года назад
Caching is only part of the solution when addressing the N+1 and naive data resolution. DataLoader can solve many inefficiencies in a graph without introducing caching. DataLoader isn't just for GraphQL - I would use it in any aggregating server (BFF). Typically, GraphQL aggregates on top of REST, which is easier to cache. Even when GraphQL directly resolves from a database, it's pretty standard to have a cache layer supporting db access for performance. I think over time these become necessary complexities for a well balanced and healthy application.
@adamhenriksson6007
@adamhenriksson6007 3 года назад
Not sure why you would say that GraphQL API's gives you a lot of features that you otherwise have to implement manually and then say that it's complicated like it's a downside. The alternative is worse. The N+1 database problem is very easily solved, while the query is basically impossible in REST. Instead of stampeding your DB you stampede your network. This is just like deciding to use vanilla JS on an interactive/SPA site because "React/Vue requires that you learn a lot and it's hard". I get that GraphQL can be overkill on a vast majority of projects if you don't know what you are doing, but that argument was basically a footnote in this video where most screen time was "Wow, all these features that are virtually impossible to implement yourself in a commercial application are hard to learn". A framework is not a religion, it's a set of tools you can use to make your life easier when you need it. I know that you made this video for yourself and fans to explain why you don't use GraphQL anymore, but in reality you can change the title from "Why I Don’t Use GraphQL Anymore" to "Why I Don’t Use GraphQL Anymore, And Why You Should Too", because that is how most people will read it. Most people want to learn when watching tech RU-vid, especially if you include tech keywords in the title.
@gordonjohnston8321
@gordonjohnston8321 4 года назад
Interesting video. I would agree with the concerns about complexity particularly if you are attempting to build your own server. I think where GraphQL really shines is in solutions like Hasura and Postgraphile where the schema is very tightly coupled to a database. The coupling means you get optimised SQL queries that avoid the N+1 query problem.
@closure4791
@closure4791 4 года назад
Agreed! A lot (most?) of the problems highlighted in the video are solved by moving to a higher abstraction like Hasura or Postgraphile. Writing all your own resolvers is where a lot of the pain has been, I think. Postgraphile is so underrated, using it in production right now and wondering why it's not more popular. Postgraphile's plugin system has a surprisingly large surface area which makes it way more useful than just auto-generating CRUD resolvers. I think Postgraphile needs more advocates.
@hswolff
@hswolff 4 года назад
Yeah other solutions are great, but it's another layer of abstraction on top of GraphQL. So even more to learn and more to maintain! Which...may be fine, but I like to be honest with how many dependencies I'm adding to solve the problem at hand. Postgraphile looks very interesting! Thank you for sharing!
@JeffBarczewski
@JeffBarczewski 4 года назад
Configuring a server on how to resolve graphql queries is not really an abstraction, it's an implementation detail. You have to learn how to configure any graphql server. A small amount of configuration enables a ton of functionality.
@mage1over137
@mage1over137 2 года назад
So I think a better way to put it is graphql is probably the best solution to all your problems, but you have to set it up properly and there are a lot of knobs, and certain edge cases causes issues. But if you do it right, you'll minimize your tech debt, on the other hand if you do it wrong you'll have rewrite at some point and do it "right" this time (I highly recommend do this sooner rather than later). It's like digging a hole, most holes you need to dig, a shovel is fine. On the other hand sometimes you need to replace a septic tank, which I would recommend a backhoe but only operate if you're properly trained to. (Though I suppose a test drive to get feel won't hurt.)
@tonyhill5966
@tonyhill5966 4 года назад
Love the paradoxical objective and subjective views. Are you concluding that it all comes down to the specific use case? I'm currently deciding if I should implement Gql and I have just come across having to implement caching and a slew of other mechanisms.
@aaronrs2002
@aaronrs2002 3 года назад
May I ask why not simply filter the keys & values you need out of the data before sending it back to the client using basic javascript/node.js?
@marionocnik9378
@marionocnik9378 2 года назад
So, you removed your AC by now, because installing it was very complicated? My Company runs a small DWH for a customer and I provided the GraphQL-Endpoint. Yes, it was some work, but I think, its better than plenty of rest-endpoints.
@marionocnik9378
@marionocnik9378 2 года назад
Btw. I do Java 😃
@shane3744
@shane3744 4 года назад
Great perspective, many of your concerns are active problems which will hopefully continue to be addressed and improved upon. In regards to complexity, specifically with how GraphQL does error handling, I totally agree with your points. It's one of the main issues client devs have that consume the GraphQL server we build/maintain at work. There's some interesting ideas developing in the space around better error handling (Sasha Solomon has some really interesting ideas she developed as an engineer at Medium, check it out if interested), but they of course just add further complexity and learning what isn't inherent to the spec. Custom directives are... yeah, still nascent. Really interesting and have the promise to allow so much flexibility when interacting with a data graph. But they're just too unwieldy to build with today's libraries and most that I've seen only offer limited "cosmetic" functionality in queries (@deprecated, @formatDate, etc.). N+1 problem is mostly handled with DataLoader on GraphQL servers which functions as a pre-request cache/batcher. We (and many others) also implement query depth limiting, where we artificially limit the nested depth of a given query to mitigate the issue of excessively large queries. This problem is largely solved, but I think you're right that it is just another step to learn and the spec could be more opinionated on it. One of the biggest benefits of GraphQL for us has been the ability to act as an API gateway for our client apps. As we moved from a monolithic REST API to a microservice architecture, having a GraphQL API sit between our client apps and the backend has made the shift so much more seamless. While REST addresses and the data they serve change, the data graph remains the same and the client devs don't need to care about where the data is coming from, so long as the data contract is respected. This, along with client-driven queries and a statically typed data graph that you mentioned, is where the technology truly shines.
@fateriddle14
@fateriddle14 4 года назад
Can you talk a bit more specific about error handling complexity? I'm about to jump on this train, and only have a general idea of the frontend part, we are planning to build the graphQL layer with serverless functions using nodejs btw. I really want know more before fully commit to it.
@shane3744
@shane3744 4 года назад
@@fateriddle14 Sure, so in my experience, the main complaint with GraphQL error handling is that a response doesn't utilize status codes (all responses are 200 responses, regardless of whether they contain errors). For our client devs, it was a difficult shift to not just receive a a status code communicating the problem and, instead, traverse through an array of errors as is the convention in a GraphQL response. Speaking personally, I enjoy error handling in GraphQL and I don't really find http status codes to add much more value than a simple, readable error message could give me. But the main point is that the http ecosystem is built around the use of REST APIs without some of the conventions of GraphQL in mind. This forces developers who may not necessarily care if their data comes from REST or GraphQL to understand how the different methodologies handle errors from the API. I don't want to make it sound like GraphQL doesn't have a fleshed out error handling mechanism. It certainly does and I believe is even more flexible than what can be achieved when adhering to a status code system. If you're willing to put in the time to learn a bit about error handling with GraphQL, it will definitely meet your needs. Just keep in mind that if you have a large technology department and API consumers have a lot on their plate, a switch to GraphQL will add something new to contend with to their domain.
@eugenpaval
@eugenpaval 2 года назад
I implemented directives allowing query persistence on the server side. Then a client uses an identifier and a set of parameters to execute the query. Query now is shorter and faster to execute since it is persisted in a compiled form.
@eugenpaval
@eugenpaval 2 года назад
@@shane3744 A middle ware can actually set the http status code to the expected values. It s not in the specification that error conditions need be sent via 200.
@elliottmarshall1424
@elliottmarshall1424 Год назад
I implemented this today, didn’t seem all that difficult. There was a react client component npm install bla bla, was super simple. Just add it to the page and it’s now part of the application. Back end just took our already generated table definitions that match the db and use them to generate the schema and link into the correct backend model, add a permission layer and it all just worked… I treated graphql as just another layer between the client and our backend.
@bestcoders
@bestcoders 3 года назад
nice and educative but the n+1 problem is not specific to grapql.. you must always take care of that in every server you build be it rest or graphql
@osazemeusen1091
@osazemeusen1091 Год назад
its easier to solve n+1 problems in REST IMO
@theories1972
@theories1972 3 года назад
Isn't the dataloader provides caching that solves the N + 1 issue?
@_shulhan
@_shulhan Год назад
I am happy that I found voice in my head.
@user-js7ud9du2y
@user-js7ud9du2y 2 года назад
what i really wanted from graphql is just a json manipulator that is schema-less select queries . i don't care if i have to call differently for doing insert or updates
@exactzero
@exactzero 4 года назад
Another great video. As a solo dev, I am more productive building REST APIs. Btw, can we expect more Next.js vids? :)
@hswolff
@hswolff 4 года назад
Maybe >:D
@ivanmarinkovic
@ivanmarinkovic 4 года назад
Obiously, you’ve never tried AWS Amplify. All those issues have been solved.
@RakeshWaghela
@RakeshWaghela 4 года назад
Comes with dollor bills and hard dependency of AWS.
@kristiqntachev7139
@kristiqntachev7139 4 года назад
@@RakeshWaghela if you have an MVP spawn some VPS and put server on it. When the time comes and this VPS is no longer capable of providing data to all requests just scale it and then transfer your project to lambdas and microservices. You can use Amplify when this time comes without much effort. Regards!
@RakeshWaghela
@RakeshWaghela 4 года назад
@@kristiqntachev7139 still AWS owns you. You don't own AWS. Can't move the full application elsewhere. if the need be.
@kristiqntachev7139
@kristiqntachev7139 4 года назад
@@RakeshWaghela It depends on the code implementation. U can write application with single codebase and run it in every environment. Thats not true that you are locked if you are smart.
@rtnjo6936
@rtnjo6936 3 года назад
omg, i'm currently learning graphQL, and it's HRD! soo many thing you should do, when you go to apollographql.com there is tutorial which says : 15 min read this page... i trying to link all what they want from me for about an hour
@allanpimble7198
@allanpimble7198 3 года назад
15 minute read? Yes. 15 minute do? NO!
@paulholsters7932
@paulholsters7932 2 года назад
Good video. I use graphQL for the first time now for the node framework I am building. So far it seems like I’ve made the right choice.
@khandoor7228
@khandoor7228 4 года назад
Agree with you Harry! Thanks for saying it!
@hswolff
@hswolff 4 года назад
Thanks for watching!
@rickvian
@rickvian 3 года назад
Thanks! Enjoyed your video, definetly will learn more from you Wolff!
@KeyKeeper86
@KeyKeeper86 3 года назад
If I understand correctly, your point is that while GraphQL offers benefits, it also comes with own problems AND steep learning curve. These are some good reasons to consider avoiding GraphQL. However, as someone who's unfamiliar with GraphQL I am not convinced that these claims are justified. Every single tech has drawbacks, so expecting GraphQL to not have any weak sides whatsoever would be strange. The only question is whether the benefits overweight the drawbacks. Things like strongly types API scheme, schema stitching, and others are HUGE. I didn't quite get the drawbacks are really as bad as the benefits. Even the example with a need of cache in front of a backend/db is not very persuasive because it's more of a corner case in my view. As far as the steep learning curve goes. I only know a handful of techs that have really nice ROI when it comes to learning. React is a great example. But again, every dev expects perpetual learning. It's inevitable.
@eugenpaval
@eugenpaval 2 года назад
Well put!
@camelcai
@camelcai 3 года назад
I use gRPC. I feel there's too much magic in GraphQL.
@alexandersumer4295
@alexandersumer4295 3 года назад
gRPC is designed for service-service communication, not client-server communication. GraphQL is designed for client-server. Apples and oranges.
@avi7278
@avi7278 3 года назад
a "smart box" ... you mean a box with what's inside of it written in marker on it?
@-_-unseen-_-
@-_-unseen-_- 2 года назад
I plan to implement GQL and REST together. GQL seems to be great for queries but I can use REST for the mutations create, update, delete keeping things simple.
@zomakaja
@zomakaja 4 года назад
Thanks for the video. It was well reasoned.
@freemind108
@freemind108 3 года назад
Well Great Info, Exactly what i was thinking of it from server point of view. considering the n+1 problem i better rest with REST and don't want to bring so much of Heat to QraphQL server, as i don't know much about qraphQL advanced part.
@usmanmughal5916
@usmanmughal5916 3 года назад
Yea just stick with REST.
@nicolasdelfino1
@nicolasdelfino1 4 года назад
About time someone blows the whistle on this! 😊
@TroyCSchmidt
@TroyCSchmidt 4 года назад
The flexibility in a typed API that can handle dynamically determining fields returned is worth the additional complexity. The performance I have seen implementing GraphQL with smaller more discreet queries instead of trying to find one size fits all larger queries has been night and day. Also with smaller queries and more executing it makes it possible to do incremental loading of the UI easier.
@sitcomrave
@sitcomrave 4 года назад
I got almost impression and started using hasura on backend and mst-gql on client. And things just got fine. If you want more control on backend replace hasura with own server.
@hswolff
@hswolff 4 года назад
Yeah, Hasura is great! I just don't like that it's vendor lockin and also requires you to do things the Hasura way...which isn't GraphQL anymore.
@koistya
@koistya 4 года назад
Right, vendor lock in is not a joke. Building a GraphQL API server using graphql.js is pretty simple. See github.com/kriasoft/nodejs-api-starter
@bkc3546
@bkc3546 4 года назад
Can you specify what vendor lock in? I just started using it
@JeffBarczewski
@JeffBarczewski 4 года назад
Hasura solves most of what you complained about. It is open source and works with other graphql servers or even REST besides Postgres. It's not any more lock in than using something like Apollo.
@hswolff
@hswolff 4 года назад
I’d say it is more of a lock-in due to it being written in Haskell, making the cost to fork way higher than Apollo.
@Kim-by5uy
@Kim-by5uy 2 года назад
I think apollo server has adressed a lot of these problems
@RS-sk7bp
@RS-sk7bp Год назад
Misleading, 'click-baity' title aside, this is a good video for someone new to GraphQL and not sure of the pros and cons. You walked through what life with GraphQL could look like compared to REST.
@jakeave
@jakeave 3 года назад
Yeah, relay and graphql, postgraphql, it just means it takes me updating 3 repos to get a one line change done.
@RedCloudServices
@RedCloudServices 2 года назад
how does REST accomplish subscriptions or single UI to federated schema? It would have been fair to compare each pain points w gql to it’s rest counterparts?
@craigmjackson
@craigmjackson 4 года назад
I was also drinking the graphql kool-aid, until I discovered the n+1 problem. I didn't discover it by reading about it, I discovered it by seeing these massive numbers of requests for the same thing. I really didn't want to hack around it, and this was exactly when I gave up on it. Since I generally own the frontend and backend, I see no reason why REST can't get me exactly what I need, with the exactly optimized database queries I need for a particular URL and parameters. I see only one use case for this, to provide a self-documenting client-side experience at the extreme expense of the backend complexity and over-engineering.
@tommylemon4462
@tommylemon4462 3 года назад
But you need to write schemas and types for getting the documents, that's another kind of workloads and I don't think it's easier than writing regular API documents manually.
@MrSandeep1992
@MrSandeep1992 4 года назад
Agree with most of it, but I think subscriptions are very easy to setup with GraphQL especially if you are using client library like Apollo vs setting up web sockets manually
@shamim083
@shamim083 2 года назад
Excellent video Harry.
@horacioh
@horacioh 4 года назад
I blame @benawad on this one... XD
@hswolff
@hswolff 4 года назад
Haha! Yes :D
@andrewobrigewitsh
@andrewobrigewitsh 11 месяцев назад
The biggest advantage is actually the data Graph, 2 is its typing, 3 is getting exactly what you need. The problem with GraphQL is that the main frameworks don't have strong opinionation, this leads to unneeded complexity and people doing things in very weird ways. I think code first is also better for beginners as the schema is radially just a duplication of your resolvers.
@philipfwilson
@philipfwilson Год назад
Great Job !! Very clear
@gsgmedina
@gsgmedina 3 года назад
Excellent video! What is your opinion about OData?
@veeracs
@veeracs 2 года назад
The background doesn’t matter to me it’s the content that’s the king 🤴
@mohamedgaber5533
@mohamedgaber5533 3 года назад
I wondering and not found any answer about Graphql makes me fetches all data from database e.g mongoose model and select data after this fetching from the client side, this is bad for performance true or not ?
@MrEnsiferum77
@MrEnsiferum77 4 года назад
It's not the problem in Grahql or Rest, it's problem of solving business domain problem wtih technical thinking in mind. If u do DDD and unit tests u can have everything prepared well without rest or graphql, and of top of that u can then think of what is best suitable for u. but lead developers and clients are nuts, so DDD doesn't make sense, we are just stuck forever with this frameworks, for re-building same and same apps. oh yeah we have docker now, woooo
@kasvith
@kasvith 4 года назад
To solve under fetching/over fetching you gonna spend a whole lot of time and make your app more and more complicated. I'm on your side too. We tried to move our REST to GraphQL and realized that we gonna add whole bunch of dependencies like Apollo Server etc and gonna be bound for it for eternity. No that's not gonna happen.
@mberoakoko24
@mberoakoko24 4 года назад
Challenge accepted , basically everything is hard for me , so this will also be learnt like the rest.
@moshericoe
@moshericoe 4 года назад
hahaha "...like the rest"
@victorbrylew1775
@victorbrylew1775 3 года назад
I don't get flexible schema as advantage. For example we have huge schema with several nesting levels and hundreeds of arguments/fields. This schema make possible usage of millions of different requests to backend. Meanwhile in reality we will use tens or hundreeds of requests from this huge set. So we are paying by all server side complexities for nothing. Or maybe it will be more correct to say that by price of hell on server side we buy client side ability to switch from one attribute fetching to other. I'm happy for JS-friends but isn't this price too big? Isn't it like buying wonderful lamp for $10000?
@lightningspirith
@lightningspirith Год назад
Would like to watch you talk about what differences or improvements GraphQL shows over SOAP webservices.
@greendsnow
@greendsnow Год назад
Since RU-vid made the Dislike data invisible to the viewers... Such videos can make into unsuspecting devs' playlist... This is your fault RU-vid!
@joelei4179
@joelei4179 4 года назад
Hey Harry, have you looked into using Prisma 2.0 with an SQL database? It gives you typed database queries and you can use it REST style.
@nikunjchaudhari9064
@nikunjchaudhari9064 3 года назад
I mostly use prisma2 with Gql
@sariksiddiqui6059
@sariksiddiqui6059 4 года назад
You are right..they try to present the advantages assuming you have already setup the graphql endpoint...though wrappers around DBs help..like postgraphile which spins up a graphql server on top of postgres,working beautifully with foreign keys and all
@appl3s0ju
@appl3s0ju 2 года назад
10:26 lol sorry, can i get you started on the graphql subscription? im curious..
@asdqwe4427
@asdqwe4427 Год назад
I think t that most people really use it for the schema. It was invented at Facebook too that they didn’t have to write a backend for fronend for each client. Most of us only have one client. I’m happy making a non-standard http endpoint on my test api if there is a use case for it, I’ll do that a few times before reaching for gql
@Joengethe
@Joengethe 4 года назад
The solution for N+1 is using data loaders. Caching can solve it but caching it's not the recommended way for this particular problem.
@js_programmer8423
@js_programmer8423 2 года назад
For me graphql is easier than rest , but I somewhat agree because you are suppose to set your own Apollo server error codes manually which should automatically be done
@htmlfivedev
@htmlfivedev 2 года назад
Very honest and very funny ... (some how)
@Nkraka
@Nkraka Год назад
So what are you using now if not graphql?
@benjamingyuro5584
@benjamingyuro5584 3 года назад
My biggest pain with GraphQL was directing the queries to the correct services. With Rest I can easily set up these rules based on the URL path. With GraphQL these queries need to be unfolded and well understood before they even hit the service which supposes to handle the business logic. GraphQL looks amazing from React POV, no need to transform data, reduce the number of calls from the client etc. But the way it does that isn't free. Those data transformations, multiple queries to different services are still needed to be done somewhere. It could hide, in which case can cause huge performance issues. Sometimes developers tend to lean to these hidden solutions because those seem simpler and nicer on the PR. Hidden solution = complexity out of control. Also with GraphQL, it is really easy to "accidentally" handle business logic on the client-side. 😱
@MascleGinger
@MascleGinger 2 года назад
I started to learn graphql but you mentioned about inability to cache post requests on the client and n +1 problem and it's a big drawback, but graphql is great nevertheless
@armandorueda8988
@armandorueda8988 4 года назад
Yes GraphQL and Relay are overkill for personal projects for example. And learning all their abstractions is insane for simple projects.
@tommylemon4462
@tommylemon4462 3 года назад
GraphQL solves some small problems while brings more difficult problems. I think it could be used as a gateway for reducing the workloads of aggregating APIs. While it's definitely not suitable for neither RDBMS(MySQL, PostgreSQL, Oracle, DB2...) or static typing languages(Java, C#, Go...). Here is a much better solution by Tencent. APIJSON has much more functions, performs better and is safer than GraphQL. You don't need to write schema, type, resolvers, etc. Actually you don't need to write any code for CRUD functions with databases. github.com/Tencent/APIJSON/blob/master/README-English.md
@n1ru4l
@n1ru4l 4 года назад
The problem with subscriptions is that most people who use them should actually be using live queries. Updating the cache manually sucks. Unfortunately, there is no major "open-source" solution for live queries that do not lock you into using a specific type of database that I am aware of.
@hswolff
@hswolff 4 года назад
Yes! Thank you!
@jporfirio
@jporfirio 4 года назад
I would love to hear about your problems with rest and why graphql doesn't solve them.
@elephant_888
@elephant_888 4 года назад
He already discussed the problems in the video. E.g. the non-trivial n+1 query problem 6:45
@highmastdon
@highmastdon 3 года назад
​@@elephant_888 But is this really the problem? If you have REST and you actually do resource oriented API design, you'd have the N+1 problem in the client... What you can do is instead of having this caching layer, or data loaders, is checking in the queryContext whether it requests the nested stuff and branch accordingly. No need to overload the db or keep stuff in memory and do N-more queries in your backend
@nikunjchaudhari9064
@nikunjchaudhari9064 3 года назад
@@elephant_888 data-loader 🤔
@elephant_888
@elephant_888 3 года назад
@@nikunjchaudhari9064 sure. The speaker’s point was that graphQL wasn’t magic and there are a good number of things to think about that can make it complex if you’re coding it from scratch. Today a lot of these problems have been obviated by tools like Postgraphile and Hasura, but it’s still a fact that REST endpoints are easier to get off the ground. I love graphQL and I use it for most of my organization’s projects. However if you’ve only got a tight deadline, it would be silly not to consider REST.
@lardosian
@lardosian 4 года назад
I think DataStore from AWS is another alternative to Apollo but I'm fairly new to the game so I'm no expert. I'm in my first dev job (solo!!) using AWS Amplify framework which uses graphql heavily, but Amplify does a lot of the heavy lifting. You write the database schema in graphql and Amplify then creates all the CRUDL for you. Because I'm making a PWA with React I chose to use this new DataStore database from AWS which is an offline first approach. DataStore creates a local db on the client and synchs with the DataStore database in the cloud. So to get data from the back end I just query the local database which is quite straight forward and the the graphql stuff is taken care of for me with DataStore. Man I hope what I'm doing is correct because I'm on my own in a startup. I made the decision to go with DataStore after watching some AWS videos. One thing that is difficult is pushing database schema updates, when the database synching breaks thats when the fun starts...yikes.
Далее
REST vs. GraphQL: Critical Look
33:06
Просмотров 61 тыс.
The Truth About GraphQL
12:06
Просмотров 98 тыс.
Ik Heb Aardbeien Gemaakt Van Kip🍓🐔😋
00:41
Should You Use TypeScript? 5 Reasons You Shouldn't!
8:43
tRPC, gRPC, GraphQL or REST: when to use what?
10:46
Просмотров 78 тыс.
What Theo Won't Tell You About Next.js
8:37
Просмотров 86 тыс.
I Am Done With Graph QL After 6 Years
31:41
Просмотров 138 тыс.
The Hidden Cost Of GraphQL And NodeJS
28:35
Просмотров 189 тыс.
tRPC - GraphQL KILLER??!
11:24
Просмотров 99 тыс.
BFF VS GRAPHQL
9:11
Просмотров 12 тыс.
What is happening with Flutter
3:41
Просмотров 147 тыс.
Turns out REST APIs weren't the answer (and that's OK!)
10:38