GraphQL vs REST: What's The Difference And When To Use Which?

  Рет қаралды 194,010

ArjanCodes

ArjanCodes

Күн бұрын

Пікірлер: 185
@ArjanCodes
@ArjanCodes 2 жыл бұрын
The first 1,000 people to use this link will get a 1 month free trial of Skillshare: skl.sh/arjancodes02221.
@motodew54
@motodew54 2 жыл бұрын
Thanks!
@kbcarte420
@kbcarte420 2 жыл бұрын
In the video you had a pop up note to not store passwords in the db. Did you mean don't store "plain text" passwords? I can't think of anywhere else to store them (encrypted of course)?
@emonymph6911
@emonymph6911 Жыл бұрын
If we are trying to query data from an existing microservice written in REST and fetch it with our own app written with GraphQL. Is that possible or are we forced to also build out a REST API in our own app to fetch from the third party REST API?
@Dpark6060
@Dpark6060 2 жыл бұрын
You are the link I've been missing between programming theory and programming practice. I can't tell you how much you've helped me improve my programming skills. Your examples are concrete and applicable, not too simple or too advanced. Thank you.
@1oveToLose
@1oveToLose 2 жыл бұрын
so true
@Exirel
@Exirel 2 жыл бұрын
> "There is no standard way of doing [controlling the fields you get]". Aside from the fact that REST isn't a protocol so "standard" is a hard thing to define here, there are many ways to overcome this issues, and all of them are standards in HTTP and pretty natural in REST design principles: - HTTP cache on GET request; which is always useful - Always return empty response on PUT/POST/DELETE request, with a location header if the resource modified is at a different location - Use content negotiation (request's ACCEPT header and response's Content-Type header) to return smaller response Most problem with "you can't control what you get" are coming from badly designed API and a lack of understanding of what HTTP has to offer. And also, most people don't know more than type-marshalling and think their internal datamodel is the same as the returned resources.
@warpmonkey
@warpmonkey 2 жыл бұрын
After developing some applications that store many millions of records, I can say that REST API's are the only way to go. The security issues around REST are easy to manage if you enforce Swagger definitions of what endpoints expose, as accidental leakage of data can be picked up through exceptions with the approved Swagger data structure. Also, GraphQL has huge performance issues, where you can't fine tune heavily indexed database queries to speed the query like you can with REST. With REST, you know how the data will be structured, so targeted database indexes can improve query performance from 10x to 200x faster. GraphQL may be good for small exploratory queries, but when writing a full stack application, you know exactly how the API's will be called, because you wrote the front end, so again, REST API's stand out as the preferred solution for a full stack application, or an application that consumes the APIs in a predictable way. I would only implement GraphQL if it was necessary to have a 'Supports GraphQL' marketing line on the product home page, otherwise, for me, it is a cool but inferior technology. There are many ways to solve the 'many API calls for REST endpoints' issue. The key with REST API's is, 'It's important to understand the intent of REST API's, so that you can break those rules in a consistent manner'. And yes, it's almost always necessary to break the hardline REST API rules for endpoints to get an application of even medium complexity to operate at speed.
@EnricoAnsaloni
@EnricoAnsaloni 2 жыл бұрын
@David Thomas Agree 100%... Also, it seems there's too much boilerplate code with GraphQL. After years of developing REST servers I've made my own set of libraries and servers that can work with any data model and provide most of the features that GraphQL does, and works well with million documents sized databases
@BuyHighSellLo
@BuyHighSellLo 2 жыл бұрын
Doesn’t literally Facebook use graphQL? You sound a little too sure that rest>graphql
@warpmonkey
@warpmonkey 2 жыл бұрын
@@BuyHighSellLo Absolutely, they have quite a lot more resources to optimize the delivery of their graphql tech too. GraphQL is fine for adhoc queries that don't see a lot of use, and as you can imagine, the high level of chatter between the GraphQL server and the database layer is a sub-optimal way to expand on queries. By far the fastest way to get data out of a database, in a predictable pattern, is to retrieve data with hard coded SQL(or whatever db language you use) queries, that are backed by intense performance testing, leverage database queries, and get all the data in a single db query. If Facebook is having amazing performance with GraphQL, it makes me think they are writing optimised queries that are triggered when specific shape GraphQL queries come in, and not using a generic GraphQL query engine that isn't able to properly leverage a single db query that triggers associated indexes. When you see the light and implement an optimised DB query to get data in a known shape, then you end up exposing that query via REST, hence, in the vast majority of cases for larger applications, REST >GraphQL, by far
@Celestialzzz
@Celestialzzz 2 жыл бұрын
@@warpmonkey great insight. Thanks!
@snowe..
@snowe.. 2 жыл бұрын
@@warpmonkey The issue here is that you're assuming you _can_ provide data in a known shape. GraphQL is designed for the opposite of that, when you don't know the shape. At my last company we used GraphQL to great success because it was a tiny startup with a massive data model, the frontend was evolving constantly, and backend needing to manage a brand new api endpoint every day is infeasible. Graphql provides a great solution. The biggest issue with your response is that you assume that a company has to be huge in order to optimize their performance with GraphQL, but not huge in order to do so with their db queries. In general, I don't know _any_ business developer that spends time optimizing db queries unless they get incredibly out of hand. That time is better spent actually delivering business value, which GraphQL allows you to do. Is graphql a good solution for everything? Absolutely not. I think it was good for that use case though. I just think a lot of the arguments in this thread are incredibly dismissive of the actual power of the tech. Just like anything, it depends. One thing that is very difficult with graphql is security. But, you balance the difficulty managing that vs the fact that you no longer need to manage frontend apis for however many UIs you have. Hint: at my last company it saved the backend over 40+ manhours a week just in new api calls.
@BobDobalena
@BobDobalena 2 жыл бұрын
After working in graphql for a year after working in rest for a ~decade, I am not even slightly sold on using graphql. Ignores how HTTP response codes work, every api call is made to /graphql, etc. I don't see a ton of scenarios. for the overfetching/underfetching problem.
@wizardfix
@wizardfix 7 ай бұрын
An excellent video tutorial as usual. Now, with a Flask/GraphQL/Ariadne backend, the question becomes, how to design and implement the front end, that will actually fire off the GraphQL queries and display, or otherwise handle, the results. As well as minimising database queries from the backend to the GraphQL server, requests to the backend from the frontend could also be reduced by smart caching of some kind.
@InkaStudios
@InkaStudios 2 жыл бұрын
I liked the content, however I have to disagree, that is why we have the concept of DTOs inside endpoints when using restful api, because you do not send all the object, you can send a partial object, you might not be allowed to send certain fields or receive them in the request. So this precise security issue would be more from the bad design rather than restful functionality.
@paleocomburo
@paleocomburo 2 жыл бұрын
When this REST "problem" was mentioned, it was exactly the first thing I thought. Are using DB objects directly in the API interface? That is just bad architecture. You always abstract the interface objects. This is a contract. And it shouldn't change when you optimize the database.
@TrippleMYouAlreadyKnow
@TrippleMYouAlreadyKnow 2 жыл бұрын
100% agreed on NEVER sending the raw db objects back to the caller of the api. I like to create dedicated response models with Pydantic (ex. GetBlogsResponse). Then convert that response model to json (automatic in FastAPI ftw!) before returning the data to the caller.
@InkaStudios
@InkaStudios 2 жыл бұрын
I usually even have 2 or more DTOs for a DB entity, the basic one has a requestDto and a responseDto, that is the most basic structure, because you never share your entities structure publicly.
@a-rezhko
@a-rezhko 2 жыл бұрын
REST + ODATA is really powerful and perfectly exposes data layer as API.
@dustinwilliams448
@dustinwilliams448 2 жыл бұрын
Yeah it was... 15 years ago... 🤣
@a-rezhko
@a-rezhko 2 жыл бұрын
@@dustinwilliams448 so what? http is 30 years old :)
@dustinwilliams448
@dustinwilliams448 2 жыл бұрын
@@a-rezhko sorry but you're incorrect.. HTTP has been replaced 3 times.. Google wrote spdy which became v2, the v3 gave us QUIC, v4 was drafted in 2020. So the current live version is only 7 years old and the latest is not even 2. OData was always niche and now its in rapid decline as companies EOL legacy apps.. you might as well be advocating for VT100, sure it's still out there but it's a dead end..building anything new on it means apps are obsolete on launch.
@dkucal
@dkucal 2 жыл бұрын
Odata also perfectly exposes unsolved issues known for years 😁
@astronemir
@astronemir 2 жыл бұрын
Would be interested in you talking about “database stuff” especially with how to interface with some different ones using python. Thanks again Arjan!
@jakefischer8281
@jakefischer8281 2 жыл бұрын
Love to see how much the channel as grown! You da man Arjan
@ArjanCodes
@ArjanCodes 2 жыл бұрын
Thank you Jake, glad you liked the video!
@doctorpex6862
@doctorpex6862 2 жыл бұрын
For newbies: newer return all blogs, always return paged data
@RogerDOdipo
@RogerDOdipo 14 күн бұрын
The intro is GOATED
@Archfile375
@Archfile375 Жыл бұрын
This was an excellent explanation of the difference between GraphQL and REST, very nice, Thank you!
@ArjanCodes
@ArjanCodes Жыл бұрын
Glad you enjoyed it!
@marookegberosamuel
@marookegberosamuel 2 жыл бұрын
Just found your channel and I just know it's uphill from here for me. Thank you ArjanCodes! 💖
@MakkyNZ
@MakkyNZ 2 жыл бұрын
If you use ODATA for REST you typically wouldn't need to make separate calls to get related objects. e.g Author details of the Blog post. It has a keyword named "EXPAND" that your specify in the api call to do this.
@dimitro.cardellini
@dimitro.cardellini Жыл бұрын
There is a mistake in GQL Schema: 1. Never use [Type], because it means nullable array of nullable items of type T. The allowed values for this includes: null, [], [null] and [null, null] and so on. Use [Type!]! -- it includes an empty list bust the null for value and items is disallowed 2. Never use Type! as return type in queries if you are not sure that the corresponding value exists. blog(blogId: ID!): Blog -- returns Blog or null if blog couldn't be found by id 3. Never use GraphQL errors to pass business logic errors -- just because there is no way to describe the errors with the GraphQL schema.
@TheRadicalCentrist.1776
@TheRadicalCentrist.1776 2 жыл бұрын
Great video. I have the opposite conclusion. I think GraphQL works for small needs, but handcuffs you at scale. REST has more things to worry about initially, but you can control them in the end game when the requirements get nuanced and intertwined. We did extensive analysis of both for a major application, and went with REST over GraphQL precisely for the ability to maintain control at scale.
@alvin3171997
@alvin3171997 2 жыл бұрын
Could you elaborate more on graphql at scale problem? We are trying to pick graphql for our app.
@kp3845
@kp3845 2 жыл бұрын
If it is an mobile app, better don’t go for graphQL. Users hate frequently app updates just for fixing bugs. majority of business logic should stay in server and app just handle displaying.
@TheRadicalCentrist.1776
@TheRadicalCentrist.1776 2 жыл бұрын
@@alvin3171997 Look up "N + 1" with graphql and you'll find one aspect. The other is just the general lock-in of any library that takes over for you. It's easy at the start, but corners you in the end. It's not run time scalablity, as much as development time scalability--the ability of the developer to do advanced things toward the end of the effort.
@TheRadicalCentrist.1776
@TheRadicalCentrist.1776 2 жыл бұрын
@@alvin3171997 To elaborate a bit more on one thing. Suppose all the variables you need are not at rest, but must be calcualted at run time based on inputs. In REST, this is trivial. In GraphQL, becuse the libraries (including ORM) have taken over for you, it's hard.
@jordansilke3629
@jordansilke3629 2 жыл бұрын
Great video as always! I haven't had a chance to look into GraphQL yet, so I found the summary and comparison with REST here to be quite informative.
@ArjanCodes
@ArjanCodes 2 жыл бұрын
Glad you enjoyed it!
@stvv5546
@stvv5546 2 жыл бұрын
Great video Arjan! Concepts were explained very clearly with nice examples! I would also love to see a video on FastAPI!
@westonbarnes8120
@westonbarnes8120 2 жыл бұрын
I was already subscribed, but when you said that you are nuanced people, I hit the bell button. Great video!
@salvaje1
@salvaje1 2 жыл бұрын
When I used the api I had created for the frontend devs at our, I realized how difficult it is to use. I focused so much on the data structure and forgot about usability. I was considering migrating at least certain parts of the api to GraphQL and this video really helped me understand it. This video has helped me understand which parts are better left as REST.
@TehGaema
@TehGaema 2 жыл бұрын
In my experience, GraphQL is fantastic for the backend for frontend layer - just being able to request what you need is the largest selling point. There are other huge benefits: self documenting, type generation, great deprecation patterns, parallel queries, etc. The biggest issue I’ve seen in the field is that consumers aren’t willing to put in the work to understand how to use GraphQL and they end up treating it as a RESTful API and typically grab wayyyy more data than they need. Or worse, they over utilize the recursive nature of GraphQL rather than using dedicated queries to fetch the specific data they need.
@zackadam2598
@zackadam2598 2 жыл бұрын
what about read speed of repeated, simple queries? also what about hosting scalability relative to something like postgres?
@alexanderkovalev391
@alexanderkovalev391 2 жыл бұрын
Just for information - there is a bit abandoned evolution of classic rest called json:api. It has many interesting conventions for handling complex and dependent resources. I dont like graphql because of its unpredictable execution pipeline. I found a lot of similar concepts in json:api and it is a bit comfortable for me to handle
@GuRuGeorge03
@GuRuGeorge03 2 жыл бұрын
we are currently making this exact decision in our company. i really appreciate ur opinion, u r clearly very experienced
@bwill325
@bwill325 2 жыл бұрын
Great intro! We should all strive to be more nuanced and empathic to alternatives.
@briangbhawaii
@briangbhawaii 2 жыл бұрын
Love that you are using copilot!
@Kessra
@Kessra 2 жыл бұрын
This is unfortunately NOT what REST is or should be. While plenty of people seem to have such an understanding of "REST", this is basically just citing what others understood incorrectly in the past and is more or less just wrong or incomplete at least. View REST as a collection of indirection mechanism that help to decouple clients from services. In a REST architecture it is the job of the service to teach a client everything it needs to know to make further requests. It provides URIs the client can use to retrieve new resource' states expressed by a negotiated document type. But instead of using those URIs directly i.e. to determine its use, URIs are usually attached to link-relation names which allows to swap URIs out when needed while still being able to lookup the URI through its link-relation name. Media types are a major part of REST. Plain JSON does not provide a client any hint on that data, it doesn't even specify what a link is. Returning plain JSON is like returning a plain text document. Unless a client knows what type it received beforehand (which is already a hint on a tight coupling) it won't be able to make any sense of it. This ultimately leads to typed resources which REST does not have. Just read through what Fielding clarified on some of the common issues he has with people calling RPC-like services exposed over HTTP REST/ful: roy.gbiv.com/untangled/2008/rest-apis-must-be-hypertext-driven. Media types are nothing more than a human-readable description of what elements/components to expect within a document as well as the semantic description of what this field expresses and when it should be used. If a client is able to process such "documents" it is able to extract the data of it and it is then the job of the client developer to provide some mapping from the received representation payload to an object your application can work upon further. The media type de facto becomes the part both services and clients bind to. The contract if you will. This guarantees that messages/documents exchanged are always processable by the recipient if client and server could agree on a media type both support. In REST you could even have various media types the state of the resource could be expressed in and as such the more media types your client and server support, the more likely they become to interoperate with other services out of the box. In regards to sending data to the service, a typical client interaction here should look like this: clients looks up the URI of an exposed "form" link relation and requests that representation. It will receive a form-based representation format that follows a well-defined document type that defines the respective parts of a form. That definition will specify that there will be a certain property responsible for defining the HTTP operation to use upon submitting the form, the media type to represent the data in upon sending as well as a target URL to send the data to. Besides that the respective components the form contains will lay out the structure of the properties the target resource has and that are expected by the server. There is no need to contact any other information than that to generate a request. This is HATEOAS applied. You use the hypermedia controls defined by the media type and utilized in the response to allow clients to progress their task further. How a client is supposed to know what to do next is a bit out of scope here. Though as Jim Webber mentioned in his great talk back in 2011 ( kzbin.info/www/bejne/l4K5hK2Di513jcU ) you should basically create a "domain application protocol", similar to how shopping cart and checkout are done on Amazon or elsewhere, where a client is following a predefined interaction protocol until either the task is complete or the task was aborted mid ways for some unknown reasons. This can be done by designing the whole interaction as part of a state-machine the client is following along until it completed its task. Granted, all of those indirection mechanisms add up quite some complexity which are not needed if you are just interested in interacting with your mobile app clients that are fully under your control. REST should be used only if you want/need a service that has to run for decades and thus supports new stuff over time and/or if you have plenty of clients connecting to your services that are not under your control. While every peer in such a network should act on the same premises, if a client violates some of the requirements it is its own fault similar to how HTTP clients can not be made accountable if a server updates states on GET operations. If you don't need services to coop with change or don't need clients to be able to interoperate with other services except for yours, don't do REST.
@syberen
@syberen 2 жыл бұрын
One of the biggest challenges for me with graphql (and to a lesser extent with REST) is how to return errors to the client. The "happy flow" is standardized very nicely I think, but "unhappy flow" is all over the place. Would be curious to hear your take on that.
@mymawazo1449
@mymawazo1449 2 жыл бұрын
Have your API throw an error and return a standardized error message with a relevant HTTP Error Code?
@syberen
@syberen 2 жыл бұрын
​@@mymawazo1449 That would be one way of handling it, but by default most GraphQL packages use the HTTP 200 status code regardless of whether an error was returned or not. This is because you can query / mutate several fields in one query, some of which may be successful and some of which may return an error.
@syberen
@syberen 2 жыл бұрын
When part of the data is queried succesfully, you might want to show that data to the client, while handling the errored out data in some other way. Also errors have no typing by default in the graphQL packages I've worked with in contrast to the data. How do you handle this when using typescript for example? So in short, yes you could just modify your package to throw a status 400, I've done that in one project, but it's not a very elegant solution. That's why I'm asking for Arjan's take
@peterlarsson4875
@peterlarsson4875 2 жыл бұрын
Easiest would be to check length returned error array and treat it as a failed response if its gt 0. Any controlled throws at server is caught that way. Connection errors is upto client and or client library to handle in choosen way. If you want to be able to use partial results its a bit more work though.
@TheDolmant
@TheDolmant 2 жыл бұрын
I enjoyed this breakdown. My personal experience with GraphQL has me putting it in the bin, probably permanently. The N+1 problem and subsequent design limitations have been such a gigantic issue that I would sooner code my own custom batch endpoint than use graphql. It is a nice idea though, I am sure it works very well for lots of applications that don't come up so hard against the limitations.
@TrippleMYouAlreadyKnow
@TrippleMYouAlreadyKnow 2 жыл бұрын
The odd IDE errors and brushing over some important points were distracting me a lot but overall the main content here was great. Thank you Arjan!
@walid7189
@walid7189 11 ай бұрын
where do you save passwords (hashes) if not in the database?
@Fleebee.
@Fleebee. Жыл бұрын
You can return related data in one request in API using data serializers
@damianrecinski7329
@damianrecinski7329 Жыл бұрын
9:24 WTF so where should I store passwords if not in the database?
@billiardoxx
@billiardoxx 2 жыл бұрын
You should try Postgraphile, it's not perfect but it resolves some of your concerns...
@1oglop1
@1oglop1 2 жыл бұрын
Still the worst thing about using QraphQL in Python is that you have to write "strings" or dicts which completely eliminatas the advantage of syntax highlight, intelli sense and other IDE features. I love Python but if I'm to work with GraphQL project I'd chose TypeScript any day.
@smashmaster1000
@smashmaster1000 2 жыл бұрын
I was actually kind of surprised he used this library. The Strawberry library works with dataclasses, which I found to be much more convenient.
@RogerValor
@RogerValor 2 жыл бұрын
this is a bit lopsided on the rest side, as it shows a barely correct example of using POST to update an existing resource, and the issues with security are not specific to rest here either, and like using ariadne for graphql, you would just use a rest framework for rest, having usually the same amount of predefined utilities, that allow you to create data serialization and deserialization, validation etc. so it becomes more a question of predefined architecture: ariadne forces you to connect to some architecture, but while rest apis often have shortcut pass through solutions, it really also depends on how you layer it - and there rest apis can also already have predefined "ways" to do. in a way, rest is simply more "bare bones", while graphql is specifcly created to host an api, that has a strong independent app mindset. it is easy to create a rest endpoint that returns some custom dataset, or to govern how much data each request really gets, making rest usually a backend heavy development type, and usually, with the need to have apps, that are quick, and specialize in making the user happy, having the query decisions on the backend is often simply the more controllable, easier to finetune situation, if you don't run a platform which operates a large amount of independent and often thirdparty app logic.
@rtiodev
@rtiodev 2 жыл бұрын
Great content, can't wait for more!
@devilslide8463
@devilslide8463 2 жыл бұрын
9:16 regarding sending the data directly from the database using REST. I think that always we should use DTO and never expose our db entities. Entity should be isolated from client requests.
@lux-co3nl
@lux-co3nl 2 жыл бұрын
More videos like this please! I would also enjoy if you talked more about different types of databases and how to interact with them in Python :)
@MagnusAnand
@MagnusAnand 2 жыл бұрын
Have you tried hypermedia with htmx?
@mattpavord
@mattpavord 2 жыл бұрын
Great video! Would love to see a video on comparing the common GraphQL libraries
@Christian-op1ss
@Christian-op1ss 2 жыл бұрын
A big downside of GraphQL is that it breaks caching. This makes it unsuitable for external API's.
@perschonca
@perschonca 2 жыл бұрын
your code is so beautiful
@songokussj4cz
@songokussj4cz 2 жыл бұрын
In GraphQT, can you return Author name on the same level as Blog ID? Like {"data": {"blogs": [ {"id": "1", "authorId": "1", "authorName": "Author 1"} ] } }
@mediocre3171
@mediocre3171 2 жыл бұрын
Plz do a video on python debugging techniques in vscode
@ChrisHalden007
@ChrisHalden007 2 жыл бұрын
Great video. Thanks
@ArjanCodes
@ArjanCodes 2 жыл бұрын
You’re welcome, happy you enjoyed it!
@TheAshishJust
@TheAshishJust 2 жыл бұрын
Is GraphQL supports media types? We want to fetch and show video using graphQL which is in react application with Apollo client.
@wilhelmngoma9009
@wilhelmngoma9009 2 жыл бұрын
Excellent content! Thanks
@ArjanCodes
@ArjanCodes 2 жыл бұрын
Glad you liked it, Wilhelm!
@EduardoRodriguezRocks
@EduardoRodriguezRocks 2 жыл бұрын
All the stuff he mention about rest is all stuff much easier to implement in rest and much harder in hql
@yeahjustlikethat
@yeahjustlikethat 2 жыл бұрын
So either you define a ton of endpoints or you build complexity with graphql. I wonder if there is an equivalent for swagger for graphql
@ivan_toriya
@ivan_toriya Жыл бұрын
Thanks!
@ArjanCodes
@ArjanCodes Жыл бұрын
Thank you Ivan!
@skewty
@skewty 2 жыл бұрын
Is that an xor? Use both; each where it makes sense.
@Jankee187
@Jankee187 2 жыл бұрын
how can i get all tables in graphQL like in SQL SELECT * FROM * ??
@danielschmider5069
@danielschmider5069 2 жыл бұрын
what about documentation, like OpenApi docs? I just dont see how graphql would do this, is there a common way?
@ArjanCodes
@ArjanCodes 2 жыл бұрын
In part, the GraphQL schema is the documentation (and you can view it in the playground most GraphQL libraries offer). You can add comments to a GraphQL schema which will then be included in the documentation. Here's an example of a GraphQL library that uses this: dgraph.io/docs/graphql/schema/documentation/ (I haven't used this library myself, it's merely intended to show how documentation is handled).
@danielschmider5069
@danielschmider5069 2 жыл бұрын
@@ArjanCodes hehehe, is this a joke - or just coincidence? the link is down / doesnt exist
@Andremzsptm
@Andremzsptm 2 жыл бұрын
Great video, I really needed some GraphQL information. Thanks @ArjanCodes!
@ArjanCodes
@ArjanCodes 2 жыл бұрын
Glad it was helpful Andre!
@Purplehairedpimp
@Purplehairedpimp 2 жыл бұрын
I think you can have both!
@agonalia2796
@agonalia2796 2 жыл бұрын
Arjan, do you have in mind a video about sparql and rdflib for python? That would litterally save me 😆😆
@KinggimliderGamer
@KinggimliderGamer 2 жыл бұрын
Hi Arjan, you make great videos😀 . I like do build some bigger Applikation with a UI (PyQt, Tkinter, WX) but i have some trouble how i can build it with a MVC-Concept. I always get a big mess in the controller part. Do you have some hints? Maybe this is a idea for another great video .😅
@MarkWernsdorfer
@MarkWernsdorfer 2 жыл бұрын
thanks for the video! informative and entertaining as always! i'm not a friend of mixing different syntaxes... syntices (?)... in the same file. off the top of your head, do you know of any graphql libraries for python where you can define the graphql type definitions separately? i guess reading from a file always works 🤔
@augustusbatilojibba1405
@augustusbatilojibba1405 2 жыл бұрын
What can you say about FAST API?
@johnwilliams7999
@johnwilliams7999 2 жыл бұрын
I sometimes find it tiring to test complex graphql queries that’s my only gripe with graphql
@mrswats
@mrswats 2 жыл бұрын
Now I wanna try coding a GraphQL API to figure out how it works! However, I feel like there are some great frameworks that make creating REST APIs much easier (Django Rest Framework for example).
@ArjanCodes
@ArjanCodes 2 жыл бұрын
There are surely frameworks better suited for REST APIs. Haven't played around with Django REST, but it sounds interesting!
@EduardoRodriguezRocks
@EduardoRodriguezRocks 2 жыл бұрын
How to write 1000 lines to replace 1 in rest and call it better
@problema2000
@problema2000 2 жыл бұрын
I'd go with JSONPure
@alexanderkononov1113
@alexanderkononov1113 4 күн бұрын
Nice!
@Maric18
@Maric18 2 жыл бұрын
wasnt graphql involved with nvidias big leak?
@gibsosmart
@gibsosmart 2 жыл бұрын
25:56 what you are looking for
@piyh3962
@piyh3962 2 жыл бұрын
Your first two and a half minutes on "what is rest" put explicitly what tons of reading never provided me
@ArjanCodes
@ArjanCodes 2 жыл бұрын
Glad to hear it helped!
@AFE-GmdG
@AFE-GmdG 2 жыл бұрын
I do not know much about graphQL but isn't a API that allows the consumer to define the returned fields much more insecure than a REST API that only defines endpoints with data, the developer want to send to the consumer? Until now I only use REST APIs and I always define the data types for a specific end point in my backend (in my case .net Core 6)
@JoeHartzell
@JoeHartzell 2 жыл бұрын
Your schema is the "data types". The graphql schema defines what fields they are able to ask for as a caller. You can also very easily provide field level permissions since graphql somewhat native supports custom decorators (field level resolvers also help)
@jeromemeyers7079
@jeromemeyers7079 2 жыл бұрын
Why not both?
@basedmuslimbooks
@basedmuslimbooks 2 жыл бұрын
@ArjanCodes You look more comfortable and confident in your videos! you'll go 100K subscriber in no time
@ArjanCodes
@ArjanCodes 2 жыл бұрын
Thanks! Let's hope so! :)
@pranavnyavanandi9710
@pranavnyavanandi9710 2 жыл бұрын
Oh yes, glad I'm here early. The content is indeed a bit advanced and that's good.
@nwicakson
@nwicakson Жыл бұрын
where do you store passwords then? 9:24.5
@CalvinJKu
@CalvinJKu 2 жыл бұрын
I was just thinking, well shouldn't it be 256 shades of gray then I realized how amateur I was of course you have to subtract 0 and 255 as they are black and white.
@CF7_82
@CF7_82 2 жыл бұрын
thanks
@smakintel
@smakintel 2 жыл бұрын
RPC -> REST -> GRAPHQL -> ??? What's next ?
@fuhoo5836
@fuhoo5836 2 жыл бұрын
yet another thing about new tech that annoys me: facebook thought they hava a problem so they create graphql. does your company have facebook level problems? definitely not. ... so many programmer choices are driven by shiny toys. makes me sick.
@wtfenc0reenix
@wtfenc0reenix 2 жыл бұрын
I CANT use my car because my way to work is solved in 5 minutes on foot? or I shouldnt use my Mustang oder Dodge to drive to work if it can be done in smaller like Twingo or Chiquichento?
@RicardoValero95
@RicardoValero95 2 жыл бұрын
What about graphql subscriptions? Using sse or ws with the same api for real-time stuff is pretty cool
@auroragb
@auroragb Жыл бұрын
I'm not familiar with graphql at all, FaceTime this video, it feels like writing manual definition of data classes before the dataclass module. It makes you write more disciplined code, but inflexibility leads to limitation like the n+1 problem. Also, if the rest interface was created with fast API, lots of the testing issues go away because swagger docs are free in fast API. So graphql just seems like an expensive way of shifting API design further downstream
@markw.8455
@markw.8455 8 ай бұрын
Ah, what is flask? RPC?
@TheWolverine1984
@TheWolverine1984 10 ай бұрын
You know he knows what he's talking about because people who use Vim usually do.
@ArjanCodes
@ArjanCodes 10 ай бұрын
I guess that's one way to look at it? Ahah
@waytospergtherebro
@waytospergtherebro 2 жыл бұрын
GraphQL is great for 22 year old CTOs who say things like "Mongo just scales better" unironically.
@lincoln4926
@lincoln4926 2 жыл бұрын
255 shades of grey
@ed-ou812
@ed-ou812 2 жыл бұрын
Software development would be so much better if everyone worked together and stopped re-inventing the wheel. It makes open source bloated, confusing and overwhelming.
@rdean150
@rdean150 2 жыл бұрын
Clearly you haven't tried Wheel XI.1 Lollipop Leapord. They introduced an SDK for 3rd party plugin extensions, allowing for custom Roll interactions via subscription-based centripetal force engines and freemium features that allow affiliates to monetize their Rotate physics services through distributed blockchain transactions. All with extensive Analytics dashboards! Throw out your legacy wheel tooling, you won't need it. Also it won't be compatible.
@Simon-xi8tb
@Simon-xi8tb 2 жыл бұрын
stop worrying and just use Clojure
@ed-ou812
@ed-ou812 2 жыл бұрын
@@Simon-xi8tb Agreed! Clojure does not need to out-compete every other language out there to be successful. It just needs a community that’s big enough to make it sustainable in the web development space. There are plenty of people actively using Clojure for work, and the ecosystem is very robust. In short, I don’t think Clojure is in danger of going anywhere in the foreseeable future. Now let's see how many can make Clojure a standard and all agree to use it without re-inventing the wheel and confusing the open source space of options even more. See my point?
@Simon-xi8tb
@Simon-xi8tb 2 жыл бұрын
@@ed-ou812 You would have a point if Clojure was re-inventing , but it does a lot more inventing than re-inventing.
@ed-ou812
@ed-ou812 2 жыл бұрын
@@Simon-xi8tb just one more tool in the toolbox. There will be another 5 next week. All saying they have advantages over it. Maybe you can convince them to not re-invent Clojure. That was my point. Open source needs better teamwork across the spectrum. Not just for one tool for a short time. Build upon the tool and keep it going. Yes and a language is a tool.
@realfootball338
@realfootball338 2 жыл бұрын
I like OData
@anzei331
@anzei331 2 жыл бұрын
at kzbin.info/www/bejne/bZTGlYqnfMx7l68 you mention 'don't store passwords in the database' - where are you supposed to store passwords? Just to generalize a bit, looking at web development security, it's difficult to find easily digestible information. Maybe it would be interesting to do some videos showing real life exploits, as a suggestion. Thanks for your work!
@obudo
@obudo 2 жыл бұрын
I think in this case it means "don't store plaintext passwords in your database". There's a series of transformations that you should apply to the passwords before saving them on your database, so that they can't be retrieved in case there's a database breach
@rogertunnell5764
@rogertunnell5764 2 жыл бұрын
When user creates account, accept plaintext password in the request, then use an "industry standard" hashing function like bcrypt to create a hashed password string. Store only this hashed string in the database. When the user signs in, accept the plaintext password in the request, hash it again using the same hashing function, check if the recently hashed string matches the hashed string stored in the database for that user.
@baloney_sandwich
@baloney_sandwich 2 жыл бұрын
This is only 5 times easier to code in Python than with Java Spring
@rdean150
@rdean150 2 жыл бұрын
Only 254 shades of grey? Ah, right, because we're zero indexed and of course the final shade is reserved for the dirty bit. 😎
@rajveersingh2056
@rajveersingh2056 Жыл бұрын
No, in 8 bits, there can be 256 total shades example: 0,0,0 1,1,1 2,2,2 ..... 255,255,255 where 0 is black and 255 is white, remaining 254 are gray shades,
@rajveersingh2056
@rajveersingh2056 Жыл бұрын
@rdean150
@rdean150
@rdean150 Жыл бұрын
@@rajveersingh2056 That whooshing sound is the joke flying overhead
@javrin1158
@javrin1158 2 жыл бұрын
It always depends! 🤣
@vitusyu9583
@vitusyu9583 7 ай бұрын
Quite complicated as my first exposure to this…
@jonmichaelgalindo
@jonmichaelgalindo 2 жыл бұрын
254 shades?! Don't you mean 256? D-:
@ArjanCodes
@ArjanCodes 2 жыл бұрын
I don't count black and white as shades of grey ;).
@jonmichaelgalindo
@jonmichaelgalindo 2 жыл бұрын
@@ArjanCodes I was kind of thinking that, but since screens will never be able to display pure black, and a brighter light will always be "whiter", I would count both as gray. LOL philosophical binary claptrap. :-P
@efilson7581
@efilson7581 2 ай бұрын
Explain why these docstring-like typedefs aren't a ten-day-old fish code smell.
@fuhoo5836
@fuhoo5836 2 жыл бұрын
so with graphql you have to predefine queries... EXACTLY as you have to do with rest. acting like rest necessarily and literally means mapping table to api is just ... idiotic. want fast "rest" development? use rails.
@Jack9C
@Jack9C Жыл бұрын
Stating that Swagger sets "the standard" is at best propaganda and at worst misinformation. Swagger does not set the standard for REST protocols over HTTP. REST and HTTP Actions are SEPARATE ideas that have never worked very well in practice for anything beyond toy projects. In any project with dependencies, REST implementations are always dealing with exceptions and workarounds (which are all pointing to RPC) that make it obvious that REST is a failed approach. It's better than inheritance, because the ideas aren't coupled to bad design, but are poor targets for overall architecture. If you have an analytics system you'll be using an RPC API over GraphQL and any system less complex will be just fine with an RPC API without wasting effort on these terminal REST projects.
@ufckngsht
@ufckngsht 2 жыл бұрын
gRPC!!!
@DartMitai
@DartMitai 2 жыл бұрын
gRPC!
@jorgealarconalvarez
@jorgealarconalvarez 2 жыл бұрын
I love you man, heart my comment please!
@ArjanCodes
@ArjanCodes 2 жыл бұрын
Thanks and happy to oblige ;).
@AdventMoxy
@AdventMoxy 2 жыл бұрын
Really? Wrapping is the answer? Maybe good for pretenders
@ArjanCodes
@ArjanCodes 2 жыл бұрын
What would be a good alternative in your opinion?
@AdventMoxy
@AdventMoxy 2 жыл бұрын
@@ArjanCodes Data without logic is noise
2 жыл бұрын
Actually it is 255 shades of gray 💩☺️
@the-other-sunny
@the-other-sunny 2 жыл бұрын
I thought the same but the values 0 and 255 are black and white, the shades of grey are actually the values from 1 to 254. Pretty deep joke !
@ArjanCodes
@ArjanCodes 2 жыл бұрын
You got it Ryad ;).
@frozt86
@frozt86 2 жыл бұрын
no one is paying attention to JSONRPC
@Strikeviolet
@Strikeviolet 2 жыл бұрын
Fastapi graphql is better
Mermaid JS: Finally There's A Great UML & Diagram Drawing Tool
28:35
7 Python Code Smells to AVOID at All Costs
22:10
ArjanCodes
Рет қаралды 375 М.
黑天使只对C罗有感觉#short #angel #clown
00:39
Super Beauty team
Рет қаралды 10 МЛН
Увеличили моцареллу для @Lorenzo.bagnati
00:48
Кушать Хочу
Рет қаралды 9 МЛН
How To Easily Do Asynchronous Programming With Asyncio In Python
23:09
tRPC, gRPC, GraphQL or REST: when to use what?
10:46
Software Developer Diaries
Рет қаралды 90 М.
Should You Use gRPC Instead of REST?
19:11
ArjanCodes
Рет қаралды 14 М.
GraphQL vs REST: Which is Better for APIs?
7:31
IBM Technology
Рет қаралды 211 М.
Protocol Or ABC In Python - When to Use Which One?
23:45
ArjanCodes
Рет қаралды 205 М.
The Truth About GraphQL
12:06
Theo - t3․gg
Рет қаралды 103 М.
This Is Why Python Data Classes Are Awesome
22:19
ArjanCodes
Рет қаралды 816 М.
Uncle Bob’s SOLID Principles Made Easy 🍀 - In Python!
19:09
ArjanCodes
Рет қаралды 303 М.
PLEASE Use These 5 Python Decorators
20:12
Tech With Tim
Рет қаралды 123 М.