We are creating a highly requested API and are now considering using GraphQL, REST, or a combination of REST and GraphQL. We like the GraphQL approach, which the interface can decide which data is returned and see its benefits. But on the other hand, we are worried about caching due to the type of data we store (Product and Product Configurations). At the moment, we see the following options:
Only using GraphQL . It allows us to speed up the development of our interface and gives our API more flexibility for future implementation. But due to the large number of products we want to use the basic http caching ability and our CDN.
Only use of REST . Allows us to use a standard HTTP cache for each request, but a specific endpoint is required for each external request.
So basically, I want to know if GraphQL's caching ability is the same as REST?
As a plus, we thought about combining it. The reason for this is because we have a backend cache that caches data from our backend systems:
- Combine both . The idea is to have, for example, a JSON product behind the REST
product/1
endpoint that will serve the product data and all configurations. Then it is saved in our backend cache. Then GraphQL can be used by fontend developers to sort the parts of the configuration that a particular view needs (for example: product / 1? Query = SomeGraphQLQuery). Thus, the REST endpoint is for server caching and GraphQL for client caching.
Does this approach make sense in the world of GraphQL, or is it just a useless level of abstraction and doesn't provide any improvement?
source share