Reputation: 962
We use one endpoint that returns massive size of data and sometime the page would take 5-10s to load. We don't have control over the backend api. Is there a way to reduce the size that's going to be downloaded from the API? We have already enabled compression. I heard GraphQL could make a data schema before query it. Would GraphQL help in this case?
Upvotes: 1
Views: 2111
Reputation: 84687
GraphQL could help, assuming:
Your GraphQL server would have to expose a query that would make a request to the REST endpoint and then cache it server-side. The cached response would be used upon subsequent queries to the server, until it expires or is invalidated. Caching the response is key, otherwise simply proxying the request through the GraphQL server will simply make all your queries slower since getting the data from the REST endpoint to the server will itself take approximately the same amount of time as your request does currently.
GraphQL can then be used to cut down the size of your response in two ways:
Note: the latter can be a significant optimization, but can also be tricky if your cache is frequently invalidated
Upvotes: 2