3 ms·
Can you explain it like I am 5 ?
by bilekas 4y ago
Can you explain it like I am 5 ?
- andsoitis 4y agoRaison d'être: https://graphql.org/ https://graphql.org/ Assumes you’ve done some API design, maintenance, and/or usage, to grasp benefits.
- gabereiser 4y agoGraphQL is a spec, not tech. The implementation of it (Apollo for example) is what you are probably after. GraphQL can exist on a multitude of services that support queries with the GraphQL spec. Like SQL, there are many databases that support SQL (in various forms).
- satvikpendem 4y agoExplain the spec, or the tech? Well the spec basically exists because some people at Facebook noticed that it's more efficient for the client to request exactly the data it needs than to have the server send everything and the client has to transform it. Yes, REST could work, but once you have more complex data structures, it becomes harder. For example with a todo list app, if you want a user's todos that are complete, your request might look like /api/todos/$userId/$completionStatus Now if you want the todo titles, completion status, and description, but don't want a field like subtitle, you could send the entire todo from which the client could extract the necessary fields, but why? That's extra data sent over the wire and extra computation done on the client, for basically no real reason. So maybe in your api, you do something like /api/todos/$userId/fields=title&$completionStatus&description Congratulations, you reinvented GraphQL.