3 ms·
I believe that article is referring when you need to fetch the data in differents places. Of course in your design, a single SQL query to you database would res
by fefb 8y ago
I believe that article is referring when you need to fetch the data in differents places. Of course in your design, a single SQL query to you database would resolve it, probably you would use the same query for a Graphql resolve. But when a field need to be fetched from another database or document in a nosql, for example, graphql tends to be more organized, of course in a restful APi you would run some concurrents jobs and have the same result.
I believe that best benefits that I got from graphql is flexibility in the endpoint with some basic validation data type and a good structure in the backend. However, about performance is debatable.
- iEchoic 8y ago> probably you would use the same query for a Graphql resolve When you're hand-writing SQL for a specific client experience, you can make optimizations that GraphQL cannot make because you have knowledge about the constraints on the information in the given context that GraphQL doesn't have. This is a tradeoff that comes with querying information in a generic way vs. querying information in a way that is specifically tailored for the experience. As a result, you often end up with queries that are faster than can be assembled by GraphQL.
- fefb 8y agoWhat I meant is that you probably would use the same SQL script to fetch from your database the data. GraphQL is not responsible for talk to your database. If you have a SQL database, you must specify the SQL script to fetch the data as well as RESTFUL. Pay attention that GraphQL is not a database technology, Graphql is a query language for APIS.
- iEchoic 8y agoYeah, understood. I’m saying that you often don’t use the same SQL script you would if you were using GraphQL, because when you’re writing a SQL script for a very specific user experience you can often make optimizations that only work given the constraints of that experience and the data it needs.
- fefb 8y agoOh gotcha. Yes, agree. In general a rest system will be faster than GraphQL. The GraphQL abstraction layer decrease the response time. Another point against GraphQL is if the object design has much resolver fetching database style, it will make a bunch of requests to the database that can overload the system or increase your bill.