How to make GraphQL efficient in terms of serverdatabase communication

How to make GraphQL efficient in terms of serverdatabase communication


0

I am relatively new to GraphQL. Although, I see the next issue in this api building approach.
GraphQL allows efficient communication between client and server because the client could select the bare minimum required fields and server sends just these fields and nothing more. That reduces a client-server bandwidth. That’s a pros. Although, for server to have a possibility to return back everything the client asks for, the server needs to be prepared for all cases. That means the server loads every single field from the database to be prepared for a client request. Next, the server filters information that it got from the database and returns whatever the client asked for. So, that’s a cons.

So, the question is. Don’t people care about server<->database bandwidth because these are server components and bandwidth could be bought and here we don’t adopt to the client’s slow internet or whatever problem the client may have? Server<->database communication problems are website owner’s troubles. Are there any ways to move that GraphQL filtering from server side to the database side, so, filtering could live in a proper place and then we would get minimal bandwidth between all parts of our applications?

I know about Hot Chocolate lib for .net. It is somehow connected with entity framework, so, GraphQL queries are run on the database. Although, is this thing an industry standard? Do similar libraries exist let’s say for Node.JS. Do people care at all about server<->database bandwidth?

1

  • "the server loads every single field from the database to be prepared for a client request" is incorrect. A typical GraphQL query "fans out" into multiple SQL queries running in parallel. If the GraphQL query omits fields or sub-types the corresponding SQL queries are skipped.

    – Michel Floyd

    just now


Load 7 more related questions


Show fewer related questions

0



Leave a Reply

Your email address will not be published. Required fields are marked *