Abstracting REST API calls with Query Component pattern

Being inspired by Apollo’s Query component and the way it is abstracting away all internals from presentation, I tried to adapt their solution to make it easier to make REST API calls.

In my example I will fetch for a GitHub user’s repos. Here is how Query component will look like:


And here is this query component usage:


Here is the codesandbox demo:

Query component pattern is based on render prop pattern, more details here.

This pattern can also be used in different cases, not just data access.

Leave a comment